This project demonstrates an AI Agent powered by OpenRouter (Meta Llama 3.3) that uses the Model Context Protocol (MCP) to access external tools (Weather and Web Search).
This runs the interactive agent using uvicorn to serve the FastAPI backend.
uv run uvicorn main:appThe server will start at http://127.0.0.1:8000.
You can interact with it via the /chat endpoint.
This runs a simple script to verify the tools are working without invoking the LLM.
uv run mcp_client.pyEnvironment variables are loaded from .env:
openrouter_api_key: Required for the LLM (OpenRouter).OPENWEATHER_API_KEY: Required for weather data.TAVILY_API_KEY: Required for web search.LANGFUSE_PUBLIC_KEY: Required for Langfuse observability.LANGFUSE_SECRET_KEY: Required for Langfuse observability.LANGFUSE_HOST: Langfuse host (e.g.,https://cloud.langfuse.com).
Integration with Langfuse provides full tracing of agent execution and tool calls.
- Traces are automatically flushed on shutdown.
- Visit your Langfuse dashboard to view traces.
main.py: A FastAPI application serving the agent via HTTP endpoints (e.g.,/chat).gemini_agent.py: The core logic. Initializes the OpenRouter client, connects to the MCP server via Stdio, and manages the conversation loop.mcp_server.py: Defines the tools (get_weather,web_search) using themcplibrary.mcp_client.py: A standalone test script to verify tool functionality.