MCP-Server
Demonstrates integrating multiple MCP servers (arithmetic and weather) with a LangGraph ReAct agent using Groq, enabling an LLM to dynamically discover and consume tools across different transport protocols.
README
Multi-Server Model Context Protocol (MCP) Demo
A complete demonstration of building and integrating multiple Model Context Protocol (MCP) servers with a LangGraph ReAct agent powered by Groq and real-time OpenWeatherMap data.
This project showcases how an LLM agent can dynamically discover and consume tools across different MCP servers and transport protocols (stdio and streamable-http) in a single unified workflow.
๐๏ธ Architecture
flowchart LR
subgraph Agent["LangGraph ReAct Agent (client.py)"]
ChatGroq["LLM: Groq (Qwen / ChatGroq)"]
MultiMCP["MultiServerMCPClient"]
end
subgraph MathServer["Math MCP Server (mathserver.py)"]
MathTools["Tools: add, sub, mul, div"]
end
subgraph WeatherServer["Weather MCP Server (weatherserver.py)"]
WeatherTools["Tool: get_weather (OpenWeatherMap API)"]
end
MultiMCP -- "stdio transport (subprocess)" --> MathServer
MultiMCP -- "streamable-http (http://127.0.0.1:8000/mcp)" --> WeatherServer
Components
-
Math MCP Server ([
mathserver.py](file:///c:/Users/SREESHANTH_K/Desktop/Mcp_demo/mathserver.py)):- Built with FastMCP.
- Runs over
stdiotransport. - Exposes arithmetic tools:
add,sub,mul,div. - Automatically launched as a background subprocess by the MCP client.
-
Weather MCP Server ([
weatherserver.py](file:///c:/Users/SREESHANTH_K/Desktop/Mcp_demo/weatherserver.py)):- Built with FastMCP running over
streamable-httptransport athttp://127.0.0.1:8000/mcp. - Uses
httpxto fetch live meteorological data from the OpenWeatherMap API. - Exposes the
get_weathertool (returns temperature, weather description, feels like, and humidity).
- Built with FastMCP running over
-
Orchestrator Client ([
client.py](file:///c:/Users/SREESHANTH_K/Desktop/Mcp_demo/client.py)):- Connects to both MCP servers simultaneously using
MultiServerMCPClientfromlangchain-mcp-adapters. - Assembles the tools and powers a LangGraph ReAct agent using Groq's fast LLM inference (
ChatGroq).
- Connects to both MCP servers simultaneously using
๐ Project Structure
Mcp_demo/
โโโ client.py # ReAct Agent & Multi-Server MCP client orchestrator
โโโ mathserver.py # FastMCP server running on stdio transport
โโโ weatherserver.py # FastMCP server with OpenWeatherMap API on HTTP transport
โโโ requirements.txt # Python package dependencies
โโโ pyproject.toml # Project configuration & metadata
โโโ .env.example # Environment variables template
โโโ .gitignore # Git ignore rules (protects .env and caches)
โโโ README.md # Project documentation
๐ Getting Started
1. Prerequisites
- Python 3.10+
- Groq API Key
- OpenWeatherMap API Key (free tier)
2. Installation
Clone the repository and install dependencies:
git clone https://github.com/sreeshanthkprakash-stack/MCP-Server.git
cd MCP-Server
# Create and activate virtual environment
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Linux/macOS:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
3. Environment Configuration
Create a .env file in the root directory (or copy from [.env.example](file:///c:/Users/SREESHANTH_K/Desktop/Mcp_demo/.env.example)):
GROQ_API_KEY=your_groq_api_key_here
OPENWEATHER_API_KEY=your_openweather_api_key_here
๐งช Running the Application
Step 1: Start the Weather MCP Server
Since the weather server communicates over HTTP, start it first in a terminal:
python weatherserver.py
The weather server will start listening at
http://127.0.0.1:8000/mcp.
Step 2: Run the Agent Client
Open a second terminal window (ensure your virtual environment is active), and run:
python client.py
Expected Output Example
math_response The result of the expression ((15*20)+200)/4 is 125.
weather_response Weather in Hyderabad: haze, temperature 29.5ยฐC (feels like 32.1ยฐC), humidity 65%
๐ฆ Dependencies
mcp: Official Model Context Protocol SDK (FastMCP)langchain-mcp-adapters: Connects LangChain to MCP serverslanggraph: Graph-based agent orchestration runtimelangchain-groq: High-speed LLM inference with Groqhttpx: Async HTTP client for weather API requestspython-dotenv: Secure environment variable loading
๐ License
This project is open-source and available under the MIT License.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.