Skip to content

Commit 8a0f4a5

Browse files
committed
update mcp library for gibsonai tool
1 parent e34f046 commit 8a0f4a5

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

cookbook/tools/mcp/gibsonai.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,40 @@
4343
from agno.tools.mcp import MCPTools
4444

4545

46-
async def run_gibsonai_agent(message: str) -> None:
46+
async def run_gibsonai_agent(message: str):
4747
"""Run the GibsonAI agent with the given message."""
48-
async with MCPTools(
48+
mcp_tools = MCPTools(
4949
"uvx --from gibson-cli@latest gibson mcp run",
5050
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)
7077

71-
# Run the agent
72-
await agent.aprint_response(message, stream=True)
78+
# Close the MCP connection
79+
await mcp_tools.close()
7380

7481

7582
# Example usage

0 commit comments

Comments
 (0)