Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Multi-Server MCP Agent

A production-style Model Context Protocol (MCP) system that demonstrates how to build a modular AI agent capable of orchestrating multiple specialized servers through a single intelligent client.

The system integrates tool-based reasoning, RAG, web search, financial data, weather APIs, and mathematical computation under a unified agent powered by LangGraph and Gemini.


✨ Key Features

  • 🧠 Multi-Server MCP Architecture
  • 🤖 LangGraph ReAct Agent with Tool Calling
  • 💬 Persistent Conversation Memory (Checkpointer)
  • 🔄 Multi-step Tool Chaining
  • ⚡ Streaming Responses
  • 🎨 Rich CLI Interface with Tool Tracing

📚 Retrieval-Augmented Generation (RAG)

  • Local document-based knowledge system
  • Built using LangChain + ChromaDB
  • Embeddings powered by Ollama (embeddinggemma)
  • Semantic retrieval over multiple knowledge collections
  • Hybrid ingestion pipeline with crawling + PDF parsing

🌐 Web Search

  • Real-time web search using Tavily API
  • Used for up-to-date information retrieval
  • Integrated as MCP tool for dynamic reasoning

📈 Market Data Server

  • Powered by Yahoo Finance (yfinance)

  • Tools:

    • search_symbol
    • get_market_data
    • get_historical_data

Supports stock analysis, historical comparisons, and ticker resolution.


🌦 Weather Server

  • Built with Open-Meteo API

  • Provides:

    • Current weather
    • Forecast data
    • Historical weather analysis

🧮 Math Server (Extended Tool Set)

A full-featured mathematical computation server supporting:

  • add
  • subtract
  • multiply
  • divide
  • power
  • sqrt
  • factorial

Used as a deterministic reasoning tool for arithmetic and symbolic operations.


🏗 Architecture

                 +----------------------+
                 |   AI Client (CLI)    |
                 | LangGraph + Gemini   |
                 +----------+-----------+
                            |
                     MCP Protocol
                            |
   -----------------------------------------------------
   |        |          |          |          |         |
   ▼        ▼          ▼          ▼          ▼         ▼
 Math   Market     Weather    Search      RAG     (Tools)
 Server  Server     Server     Server     Server

Each server is fully independent and communicates via the MCP protocol.


🧠 RAG Pipeline Details

The retrieval system is built using:

  • 🧬 Ollama Embeddings

    • Model: embeddinggemma
  • 🗂 Vector Database:

    • ChromaDB (persistent storage)
  • 📄 Document Sources:

    • PDF files
    • Crawled web documents
  • 🔍 Retrieval:

    • Semantic similarity search over chunks
    • Multi-collection support

🧰 Tech Stack

  • Python 3.11+
  • MCP (Model Context Protocol)
  • LangGraph
  • LangChain
  • Google Gemini
  • Ollama (EmbeddingGemma)
  • ChromaDB
  • Tavily Search API
  • Yahoo Finance
  • Open-Meteo API
  • Rich (CLI UI)

📁 Project Structure

multi-server-mcp-agent/

├── client.py
├── ingest.py
├── crawl.py
├── .env
│
├── knowledge_base/
├── vector_db/
│
├── servers/
│   ├── math_server.py
│   ├── market_server.py
│   ├── weather_server.py
│   ├── search_server.py
│   └── rag_server.py
│
└── utils/
    └── cli.py

🚀 Installation

git clone https://github.com/Hosein541/multi-server-mcp-agent.git
cd multi-server-mcp-agent
poetry install

🔐 Environment Variables

GOOGLE_API_KEY=...
TAVILY_API_KEY=...

▶️ Running the Project

poetry run python client.py

💡 Example Queries

Compare Tesla and Apple stock over the last month.

What is the weather in Tokyo tomorrow?

Solve factorial of 10.

Search latest AI news.

Explain Model Context Protocol.

Summarize retrieved documents about LangChain.

🔮 Future Improvements

  • Multi-agent orchestration layer
  • Tool ranking / reranking (Router model)
  • Distributed MCP servers
  • Dockerized deployment
  • LangSmith observability
  • Web UI (Streamlit / React)
  • Authentication layer for MCP servers

🧠 What Makes This Project Special

This project demonstrates a real-world implementation of:

  • Modular AI systems using MCP
  • Tool-augmented LLM reasoning
  • Retrieval-augmented generation with local embeddings
  • Multi-step agent execution
  • Real-time tool orchestration
  • Production-style AI system design

It is not just a demo — it is a blueprint for building scalable AI agent systems.

About

Multi-server MCP-based AI agent with LangGraph, supporting tool-augmented reasoning, RAG (ChromaDB + Ollama embeddings), web search (Tavily), market data (Yahoo Finance), weather APIs, and a modular multi-server architecture.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages