How kapoorashish474/mcp-agent works
Project Type & Purpose
• It’s a modular, backend-centric AI assistant with a CLI (and optional Web UI) that fetches live weather, news, and stock data via distinct “tool servers,” then synthesizes results through Google’s Gemini LLM using the MCP protocol.
File Structure
• Top-level:
• src/main.py – CLI/Web UI entrypoint and command router
• src/mcp_client/ – handles Gemini LLM integration and MCP protocol orchestration
• src/mcp_servers/ – three micro-service modules: weather_server, news_server, stock_server
• src/tools/ – implementations of external API adapters (OpenWeatherMap, NewsAPI.org, yfinance)
• docs/design.md and docs/TODO.md contain requirements and high-level design notes.
• requirements.txt lists key frameworks: google-generativeai, httpx, yfinance, python-dotenv, pydantic.
README for Architectural Insights
• The README outlines a layered architecture (Presentation, Business Logic, Data Access) and a microservices view (Weather/News/Finance services behind an MCP Gateway).
• Emphasized: asynchronous API calls, modularity, error-handling, extensibility.
Main Components & Interactions
a. User Interface (Presentation Layer)
– CLI App (src/main.py) +/- optional Web UI or HTTP API endpoints.
b. Business Logic Layer
– MCP Client:
• gemini_client.py: wraps Google Gemini LLM calls
• mcp_handler.py: implements the Model Context Protocol, orchestrates concurrent tool requests
c. Tool Servers (Microservices)
– weather_server.py → WeatherTool (src/tools/weather_tool.py) → OpenWeatherMap API
– news_server.py → NewsTool (src/tools/news_tool.py) → NewsAPI.org
– stock_server.py → StockTool (src/tools/stock_tool.py) → Yahoo Finance (yfinance)
d. External Services (Data Access Layer)
– OpenWeatherMap, NewsAPI.org, Yahoo Finance endpoints (REST/HTTP)
Architectural Patterns & Principles
• Layered Architecture: clear separation between Presentation, Business Logic, Data Access
• Microservices: each data source encapsulated as an independent MCP server
• Async Processing: use of httpx for concurrent calls to external APIs
• Protocol-Oriented Design: MCP handler abstracts interaction pattern between LLM and data sources
• Extensibility: adding a new data source requires adding a new tool + server module