Skip to content

edeesdar/MCP

Repository files navigation

MCP Agent Demo (OpenRouter)

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).

🚀 How to Run

1. Run the AI Agent (Main)

This runs the interactive agent using uvicorn to serve the FastAPI backend.

uv run uvicorn main:app

The server will start at http://127.0.0.1:8000. You can interact with it via the /chat endpoint.

2. Run the Tool Tester (Debug)

This runs a simple script to verify the tools are working without invoking the LLM.

uv run mcp_client.py

⚙️ Configuration

Environment 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).

🔍 Observability

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.

📝 Components

  • 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 the mcp library.
  • mcp_client.py: A standalone test script to verify tool functionality.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages