Prerequisites
fastmcpis required for this demo.
Copy
Ask AI
uv pip install fastmcp
- Run demo server:
fastmcp run cookbook/90_tools/mcp/local_server/server.py
Copy
Ask AI
from fastmcp import FastMCP
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
mcp = FastMCP("weather_tools")
@mcp.tool()
def get_weather(city: str) -> str:
return f"The weather in {city} is sunny"
@mcp.tool()
def get_temperature(city: str) -> str:
return f"The temperature in {city} is 70 degrees"
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
mcp.run(transport="stdio")
~~~
## Run the Example
```bash
# 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 server.py