使用MCP的多工具人工智能代理
该项目演示了如何构建 工具增强型人工智能代理 使用 MCP(模型上下文协议) 和 LangChain,其中单个代理可以与多个外部工具动态交互。
______________________________________________________________________
我建造了什么
- 创建 两台MCP服务器:
- A. 数学服务器 用于算术运算 - A. 天气服务器 通过HTTP公开
- 建造了一个 客户端AI代理 即:
- 连接到多个MCP服务器 - 根据用户查询自动选择正确的工具 - 使用LLM推理和调用工具
______________________________________________________________________
查询示例
User: what's (3 + 4) * 12?
User: what's the weather in dwarka sec-3 today?## Tech Stack Used
- Python
- LangChain
- MCP (Model Context Protocol)
- FastMCP
- Groq LLM (qwen/qwen3-32b)
- AsyncIO
## Key Learnings
- How AI agents interact with external tools
- How MCP enables standardized tool communication
- Managing multiple tool servers (stdio + HTTP)
- Letting the model decide which tool to call and when