M
MCP Demo Langchain
作者 @ram677
Agentic AI demo showcasing custom MCP servers integrated with a LangGraph ReAct agent using LangChain and UV.
创建于 1/29/2026
更新于 26 days ago
README
Repository documentation and setup instructions
🧩 MCP Demo with LangChain, LangGraph & UV
This project demonstrates how to build custom MCP (Model Context Protocol) servers and integrate them with a LangGraph ReAct agent using LangChain MCP adapters. All dependencies are managed using the UV package manager.
🖼️ MCP Host–Server Architecture

What this shows:
- An MCP Host (Claude, Cursor, or your own app) runs MCP clients.
- Each MCP client maintains a 1:1 JSON-RPC connection with an MCP server.
- MCP servers act as adapters to:
- Private APIs
- Databases
- Public web APIs
In this project, the LangGraph agent acts as the MCP host.
🖼️ MCP Servers, Clients & Agent Interaction

Explanation:
- Each MCP server can expose multiple tools.
- MCP clients live inside the host application.
- The LangGraph ReAct agent dynamically loads MCP tools and decides when to invoke them.
- Your Python MCP client uses
load_mcp_toolsinternally via adapters.
This maps directly to:
mathserver.py→ Math toolsweather.py→ Weather tool
🖼️ Model Context Protocol (MCP) Flow
Flow explained step-by-step:
- User asks a question
- LLM reasons inside the agent
- MCP Client sends a standardized request
- MCP Server fetches or executes logic
- Data is returned back through MCP
- Agent responds with final output
📁 Project Structure
mcp-demo-langchain/
│
├── client.py # MCP client + LangGraph ReAct agent
├── mathserver.py # Math MCP server (stdio)
├── weather.py # Weather MCP server (streamable-http)
│
├── requirements.txt
├── pyproject.toml
├── uv.lock
├── README.md
├── .gitignore
├── .env
└── .venv/
⚙️ Setup Using UV
pip install uv
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
🚀 Running the Project
Start Weather MCP Server
python weather.py
Run MCP Client & Agent
python client.py
🧪 Example Outputs
Math
User: what's (3 + 5) x 12?
Output: 96
Weather
User: what is the weather in California?
Output: It's always raining in California
✨ Key Takeaways
- MCP standardizes tool communication for LLMs
- MCP servers are reusable, language-agnostic adapters
- LangGraph enables structured agent reasoning
- UV provides fast, reproducible dependency management
📄 License
For educational and demonstration purposes.
快速设置
此服务器的安装指南
安装包 (如果需要)
uvx mcp-demo-langchain
Cursor 配置 (mcp.json)
{
"mcpServers": {
"ram677-mcp-demo-langchain": {
"command": "uvx",
"args": [
"mcp-demo-langchain"
]
}
}
}