|
43 | 43 | from agno.tools.mcp import MCPTools |
44 | 44 |
|
45 | 45 |
|
46 | | -async def run_gibsonai_agent(message: str) -> None: |
| 46 | +async def run_gibsonai_agent(message: str): |
47 | 47 | """Run the GibsonAI agent with the given message.""" |
48 | | - async with MCPTools( |
| 48 | + mcp_tools = MCPTools( |
49 | 49 | "uvx --from gibson-cli@latest gibson mcp run", |
50 | 50 | timeout_seconds=300, # Extended timeout for GibsonAI operations |
51 | | - ) as mcp_tools: |
52 | | - agent = Agent( |
53 | | - name="GibsonAIAgent", |
54 | | - model=OpenAIChat(id="gpt-4o"), |
55 | | - tools=[mcp_tools], |
56 | | - description="Agent for managing database projects and schemas", |
57 | | - instructions=dedent("""\ |
58 | | - You are a GibsonAI database assistant. Help users manage their database projects and schemas. |
59 | | -
|
60 | | - Your capabilities include: |
61 | | - - Creating new GibsonAI projects |
62 | | - - Managing database schemas (tables, columns, relationships) |
63 | | - - Deploying schema changes to hosted databases |
64 | | - - Querying database schemas and data |
65 | | - - Providing insights about database structure and best practices |
66 | | - """), |
67 | | - markdown=True, |
68 | | - show_tool_calls=True, |
69 | | - ) |
| 51 | + ) |
| 52 | + |
| 53 | + # Connect to the MCP server |
| 54 | + await mcp_tools.connect() |
| 55 | + |
| 56 | + agent = Agent( |
| 57 | + name="GibsonAIAgent", |
| 58 | + model=OpenAIChat(id="gpt-4o"), |
| 59 | + tools=[mcp_tools], |
| 60 | + description="Agent for managing database projects and schemas", |
| 61 | + instructions=dedent("""\ |
| 62 | + You are a GibsonAI database assistant. Help users manage their database projects and schemas. |
| 63 | +
|
| 64 | + Your capabilities include: |
| 65 | + - Creating new GibsonAI projects |
| 66 | + - Managing database schemas (tables, columns, relationships) |
| 67 | + - Deploying schema changes to hosted databases |
| 68 | + - Querying database schemas and data |
| 69 | + - Providing insights about database structure and best practices |
| 70 | + """), |
| 71 | + markdown=True, |
| 72 | + show_tool_calls=True, |
| 73 | + ) |
| 74 | + |
| 75 | + # Run the agent |
| 76 | + await agent.aprint_response(message, stream=True) |
70 | 77 |
|
71 | | - # Run the agent |
72 | | - await agent.aprint_response(message, stream=True) |
| 78 | + # Close the MCP connection |
| 79 | + await mcp_tools.close() |
73 | 80 |
|
74 | 81 |
|
75 | 82 | # Example usage |
|
0 commit comments