数学计算服务集成

该项目展示了三种不同的MCP服务器集成方法,包括独立数学计算服务、基于LangGraph的代理工作流和Claude代理的直接集成,适用于需要数学计算功能的开发场景。

  • by suranimayur
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 suranimayur/MCP-LangGraph-Integration---Complete-End-to-End-Demo-Guide

使用说明

MCP语言图集成应用

使用OpenRouter的Minimax模型,全面演示了模型上下文协议(MCP)与LangGraph和Claude Agent实现的集成。

🏗️ 架构概述

本项目演示了集成MCP服务器的三种不同方法:

  1. MCP服务器:独立的数学计算服务
  2. LangGraph应用程序:基于代理的工作流与MCP集成
  3. 克劳德代理人:直接集成MCP工具进行计算

📁 项目结构

mcp-langgraph-app/
├── mcp-server/                    # MCP Math Calculator Server
│   ├── src/
│   │   ├── math_calculator.py     # Core math functions
│   │   └── __init__.py
│   ├── requirements.txt
│   └── main.py                    # Server entry point
├── langgraph-app/                # LangGraph Implementation
│   ├── src/
│   │   ├── agent.py              # Graph-based agent
│   │   ├── config.py             # Configuration
│   │   └── __init__.py
│   ├── requirements.txt
│   └── main.py
├── claude-agent-app/             # Claude Agent Implementation
│   ├── src/
│   │   ├── agent.py              # Agent with MCP tools
│   │   ├── config.py             # Configuration
│   │   └── __init__.py
│   ├── requirements.txt
│   └── main.py
├── shared/                       # Shared utilities
│   ├── config.py                 # OpenRouter config
│   └── utils.py                  # Common utilities
├── docker/                       # Containerization
│   ├── Dockerfile.mcp-server
│   ├── Dockerfile.langgraph
│   ├── Dockerfile.claude-agent
│   └── docker-compose.yml
├── docs/                         # Documentation
│   ├── README.md
│   ├── API.md
│   └── DEPLOYMENT.md
├── examples/                     # Usage examples
│   ├── basic_calculations.py
│   └── advanced_calculations.py
├── tests/                        # Test suites
│   ├── test_mcp_server.py
│   ├── test_langgraph.py
│   └── test_claude_agent.py
└── scripts/                      # Setup scripts
    ├── setup.sh
    └── demo.sh

🚀 快速开始

  1. 设置环境

    ./scripts/setup.sh
    
  2. 运行MCP服务器

    cd mcp-server && python main.py
    
  3. 测试语言应用程序

    cd langgraph-app && python main.py
    
  4. 测试克劳德代理

    cd claude-agent-app && python main.py
    

🔧 配置

  • OpenRouter模型: minimax/minimax-m2:free
  • MCP服务器:端口8080(默认)
  • 基本URL: http://localhost:8080

📚 文档

🧪 例子

# Basic calculation
result = mcp_client.call_tool("add", {"a": 10, "b": 20})

# Advanced calculation
result = mcp_client.call_tool("calculate_expression", {"expression": "sin(45) + log(100)"})```