MCP Servers
@junfanz1
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 independent
Overview
What is MCP Servers?
MCP Servers is a framework for decoupled real-time agent architectures that connect LangGraph-based AI agents to remote tools via custom MCP (Modular Command Protocol) servers. It enables modular, scalable tool execution using SSE or STDIO transports, and integrates with LangChain and LangGraph to orchestrate LLM workflows. Designed for developers building enterprise-grade AI applications, it also provides infrastructure for real-time tool execution, structured knowledge retrieval, and dynamic agentic interactions for clients like Claude and Cursor.
How to use MCP Servers?
Run tool servers (e.g., math_server.py using STDIO, weather_server.py using SSE) via mcp.run(transport="sse"). Connect agents using MultiServerMCPClient with a dictionary mapping server names to connection parameters, or use raw ClientSession for low‑level control. All interactions use Python’s async/await for non‑blocking I/O.
Key features of MCP Servers
- Decoupled architecture: LangGraph agents orchestrate, MCP servers execute tools.
- Supports both SSE and STDIO transport protocols.
- MultiServerMCPClient enables concurrent connections to multiple tool servers.
- Async I/O for scalable, real‑time tool execution.
- Dynamic tool discovery via MCP handshake and
session.list_tools(). - LangChain‑compatible tool wrappers for seamless integration.
- Self‑evolving tool registry API for runtime capability discovery.
Use cases of MCP Servers
- Real‑time multi‑server tool orchestration (math, weather, etc.).
- Enterprise LLM applications with independently scalable tool servers.
- Agent‑to‑agent communication and capability sharing.
- Structured knowledge retrieval and RAG workflows with LangGraph.
- Dynamic tool execution with user approval for AI assistants.
FAQ from MCP Servers
What tools are included in MCP Servers?
The project includes a STDIO‑based math server and an SSE‑based weather server. Additional servers can be added by defining @mcp.tool() functions.
What are the main dependencies?
LangGraph, LangChain, the MCP Python SDK (mcp), OpenAI’s langchain_openai, python-dotenv, and Python’s asyncio.
How does MCP Servers handle multiple transport types?
MultiServerMCPClient supports both STDIO (via command/args) and SSE (via url/transport) in a single client instance, binding each tool server 1:1 and routing all calls asynchronously.
What is the MCP protocol used here?
MCP stands for Modular Command Protocol. It defines a standard for modular tool servers that expose tools, resources, and prompts, allowing clients to discover and invoke them dynamically.
Is MCP Servers ready for production?
The README notes challenges including tool discovery latency, transport complexity, error handling, and the need for an orchestration layer (Docker Compose, Kubernetes) in production. Future directions include auth, observability, and parallel node execution.