MCP-MultiServer-Interoperable-Agent2Agent-LangGraph-AI-System
This project demonstrates a decoupled real-time agent architecture that connects LangGraph agents to remote tools served by custom MCP (Modular Command Protocol) servers. The architecture enables a flexible and scalable multi-agent system where each tool can be hosted independently (via SSE or STDIO), offering modularity and cloud-deployable execut
claude mcp add --transport stdio junfanz1-mcp-multiserver-interoperable-agent2agent-langgraph-ai-system python math_server.py \ --env PORT="N/A" \ --env TRANSPORT="stdio"
How to use
This MCP-based setup demonstrates a real-time, decoupled agent system where LangGraph (a ReAct-style agent framework) coordinates tool execution across remote MCP servers. Tools such as a math calculator and a weather tool are exposed as independent MCP servers, using different transports (STDIO for direct process I/O and SSE for streaming server events). A LangGraph agent can concurrently invoke these tools via a MultiServerMCPClient, receiving asynchronous results that feed back into the agent’s reasoning loop. Users can extend this pattern by adding more tool servers and binding them 1:1 to the agent, enabling scalable, language-agnostic tool integration with real-time responsiveness. The included multiserver_client.py demonstrates how to register multiple tool endpoints (e.g., math and weather) and invoke them in parallel, while stdio_client.py shows a low-level STDIO-based workflow for a single server.
How to install
Prerequisites:
- Python 3.8+ (or a compatible Python environment)
- Git
- Optional: virtual environment tool (venv/conda)
-
Clone the repository: git clone https://github.com/your-org/junfanz1-mcp-multiserver-interoperable-agent2agent-langgraph-ai-system.git cd junfanz1-mcp-multiserver-interoperable-agent2agent-langgraph-ai-system
-
Set up a Python environment: python -m venv venv source venv/bin/activate # on Unix/macOS .\venv\Scripts\activate # on Windows
-
Install dependencies (example; adapt if a requirements file exists): pip install -r requirements.txt
-
Start the tool servers (in separate terminals or as background processes):
STDIO-based math server
python servers/math_server.py
SSE-based weather server (if it uses a separate process/port, ensure it is running and accessible)
python servers/weather_server.py
-
Run the client that talks to multiple servers:
From project root
python client/multiserver_client.py
Notes:
- If you modify transports or add new servers, update the mcp_config accordingly.
- Ensure network access and proper ports/firewall settings for SSE-based servers.
Additional notes
Tips and caveats:
- Transport handling: Some servers use STDIO (direct process I/O) while others use SSE (streaming over HTTP). Ensure the corresponding client side configuration matches the server transport.
- Handshake and tool discovery: The ClientSession and tool-loading utilities rely on MCP handshake conventions. If you add new tools, ensure they are discoverable by the client and expose the expected tool signatures.
- Async orchestration: All tool calls are designed to be non-blocking. For best performance, run multiple tool invocations concurrently and handle partial results gracefully.
- Environment management: Use virtual environments to isolate dependencies. Pin package versions to avoid breaking changes across updates.
- Deployment: In production, consider containerizing each tool server (e.g., Docker) and orchestrating them with Docker Compose or Kubernetes for resilience and scalability.
Related MCP Servers
falcon
Connect AI agents to CrowdStrike Falcon for automated security analysis and threat hunting
ai-learning
AI Learning: A comprehensive repository for Artificial Intelligence and Machine Learning resources, primarily using Jupyter Notebooks and Python. Explore tutorials, projects, and guides covering foundational to advanced concepts in AI, ML, DL and Gen/Agentic Ai.
Helios
An AI IDE secure coding MCP service
alris
Alris is an AI automation tool that transforms natural language commands into task execution.
AI-web mode
一个基于 MCP (Model Context Protocol) 的智能对话助手Web应用,支持实时聊天、工具调用和对话历史管理。
mcp-raganything
API/MCP wrapper for RagAnything