MCP-Server
Demostración del Protocolo de Contexto de Modelo (MCP) Multi-Servidor
Una demostración completa de la construcción e integración de múltiples servidores del Protocolo de Contexto de Modelo (MCP) con un agente LangGraph ReAct impulsado por Groq y datos en tiempo real de OpenWeatherMap.
Este proyecto muestra cómo un agente LLM puede descubrir y consumir dinámicamente herramientas a través de diferentes servidores MCP y protocolos de transporte (stdio y streamable-http) en un único flujo de trabajo unificado.
🏗️ Arquitectura
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)" --> WeatherServerComponentes
Servidor MCP de Matemáticas (
mathserver.py):Construido con FastMCP.
Se ejecuta sobre el transporte
stdio.Expone herramientas aritméticas:
add,sub,mul,div.Se lanza automáticamente como un subproceso en segundo plano por el cliente MCP.
Servidor MCP del Clima (
weatherserver.py):Construido con FastMCP ejecutándose sobre el transporte
streamable-httpenhttp://127.0.0.1:8000/mcp.Usa
httpxpara obtener datos meteorológicos en vivo de la API de OpenWeatherMap.Expone la herramienta
get_weather(devuelve temperatura, descripción del clima, sensación térmica y humedad).
Cliente Orquestador (
client.py):Se conecta a ambos servidores MCP simultáneamente usando
MultiServerMCPClientdelangchain-mcp-adapters.Ensambla las herramientas y potencia un agente LangGraph ReAct utilizando la inferencia rápida de LLM de Groq (
ChatGroq).
Related MCP server: AIE8-MCP Server
📁 Estructura del Proyecto
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🚀 Primeros Pasos
1. Requisitos Previos
Python 3.10+
Clave de API de OpenWeatherMap (nivel gratuito)
2. Instalación
Clona el repositorio e instala las dependencias:
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. Configuración del Entorno
Crea un archivo .env en el directorio raíz (o copia de .env.example):
GROQ_API_KEY=your_groq_api_key_here
OPENWEATHER_API_KEY=your_openweather_api_key_here🧪 Ejecutando la Aplicación
Paso 1: Iniciar el Servidor MCP del Clima
Dado que el servidor del clima se comunica a través de HTTP, inícialo primero en una terminal:
python weatherserver.pyEl servidor del clima comenzará a escuchar en
http://127.0.0.1:8000/mcp.
Paso 2: Ejecutar el Cliente Agente
Abre una segunda ventana de terminal (asegúrate de que tu entorno virtual esté activo) y ejecuta:
python client.pyEjemplo de Salida Esperada
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%📦 Dependencias
mcp: SDK oficial del Protocolo de Contexto de Modelo (FastMCP)langchain-mcp-adapters: Conecta LangChain a servidores MCPlanggraph: Entorno de orquestación de agentes basado en grafoslangchain-groq: Inferencia LLM de alta velocidad con Groqhttpx: Cliente HTTP asíncrono para solicitudes a la API del climapython-dotenv: Carga segura de variables de entorno
📄 Licencia
Este proyecto es de código abierto y está disponible bajo la Licencia 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.-