Copy
Ask AI
"""
Client
=============================
Demonstrates client.
"""
import asyncio
from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.mcp import MCPTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
async def run_agent(message: str) -> None:
# Initialize the MCP server
async with (
MCPTools(
"fastmcp run cookbook/90_tools/mcp/local_server/server.py", # Supply the command to run the MCP server
) as mcp_tools,
):
agent = Agent(
model=Groq(id="llama-3.3-70b-versatile"),
tools=[mcp_tools],
markdown=True,
)
await agent.aprint_response(message, stream=True)
# Example usage
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
asyncio.run(run_agent("What is the weather in San Francisco?"))
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools/mcp/local_server
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python client.py