client.py
"""
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
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "agno[mcp]" groq
3
Export your Groq API key
export GROQ_API_KEY="your_groq_api_key_here"
$Env:GROQ_API_KEY="your_groq_api_key_here"
4
Run the example
Save the code above as
client.py, then run:python client.py