MCP-Server
Демонстрация Multi-Server Model Context Protocol (MCP)
Полная демонстрация создания и интеграции нескольких серверов Model Context Protocol (MCP) с агентом LangGraph ReAct на базе Groq и данными OpenWeatherMap в реальном времени.
Этот проект показывает, как LLM-агент может динамически обнаруживать и использовать инструменты на разных MCP-серверах и транспортных протоколах (stdio и streamable-http) в едином рабочем процессе.
🏗️ Архитектура
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Компоненты
Math MCP Server (
mathserver.py):Создан с помощью FastMCP.
Работает через транспорт
stdio.Предоставляет арифметические инструменты:
add,sub,mul,div.Автоматически запускается как фоновый подпроцесс MCP-клиентом.
Weather MCP Server (
weatherserver.py):Создан с помощью FastMCP, работающего через транспорт
streamable-httpпо адресуhttp://127.0.0.1:8000/mcp.Использует
httpxдля получения актуальных метеорологических данных из OpenWeatherMap API.Предоставляет инструмент
get_weather(возвращает температуру, описание погоды, ощущаемую температуру и влажность).
Клиент-оркестратор (
client.py):Подключается к обоим MCP-серверам одновременно с помощью
MultiServerMCPClientизlangchain-mcp-adapters.Собирает инструменты и управляет агентом LangGraph ReAct, используя быстрый LLM-инференс Groq (
ChatGroq).
Related MCP server: AIE8-MCP Server
📁 Структура проекта
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🚀 Начало работы
1. Предварительные требования
Python 3.10+
Ключ API OpenWeatherMap (бесплатный тариф)
2. Установка
Клонируйте репозиторий и установите зависимости:
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.txt3. Настройка окружения
Создайте файл .env в корневом каталоге (или скопируйте из .env.example):
GROQ_API_KEY=your_groq_api_key_here
OPENWEATHER_API_KEY=your_openweather_api_key_here🧪 Запуск приложения
Шаг 1: Запустите Weather MCP Server
Поскольку сервер погоды работает через HTTP, сначала запустите его в терминале:
python weatherserver.pyСервер погоды начнёт прослушивание по адресу
http://127.0.0.1:8000/mcp.
Шаг 2: Запустите клиент-агент
Откройте второе окно терминала (убедитесь, что ваше виртуальное окружение активно) и выполните:
python client.pyПример ожидаемого вывода
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%📦 Зависимости
mcp: Официальный SDK Model Context Protocol (FastMCP)langchain-mcp-adapters: Подключает LangChain к MCP-серверамlanggraph: Среда выполнения оркестрации агентов на основе графовlangchain-groq: Высокоскоростной LLM-инференс с Groqhttpx: Асинхронный HTTP-клиент для запросов к API погодыpython-dotenv: Безопасная загрузка переменных окружения
📄 Лицензия
Этот проект является открытым и доступен по лицензии MIT.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceDemonstrates custom MCP servers for math and weather operations, enabling multi-agent orchestration using LangChain, Groq, and MCP adapters for both local and remote tool integration.1
- FlicenseBqualityDmaintenanceAn MCP server that provides web search capabilities through the Tavily API and weather data retrieval tools. It demonstrates how to integrate external APIs into AI applications and build agentic workflows with LangGraph.3
- Flicense-qualityCmaintenanceA demonstration MCP server that provides math (add/multiply) and weather tools, connecting via stdio and streamable HTTP, and integrates with LangChain and LangGraph for agentic workflows.
- Flicense-qualityDmaintenanceAn MCP server that provides weather and web search tools, orchestrated by a LangGraph agent with OpenAI for natural language interaction.8
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Agent-native collaboration network: orchestrate a team of long-running agents from any MCP client.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sreeshanthkprakash-stack/MCP-Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server