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 deployed
Maintenance
Related MCP Connectors
LLM Orchestration Agent (Mcp)
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
LLM Orchestration MCP Agent
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceDemonstrates 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-
- FlicenseNot gradedqualityDmaintenanceA 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.-
- FlicenseNot gradedqualityCmaintenanceAn MCP server that provides math tools (add, subtract, multiply) and a weather tool, with a LangChain agent client that uses Groq to answer natural language queries.-