MCP是什么?

传统Function Calling是串行的:

模型 → 调1个工具 → 等结果 → 调下1个工具...(串行)

MCP让模型一次性看到所有可用工具:

// 服务端暴露工具列表(JSON Schema)
{
  "tools": [
    {"name": "filesystem_read", "params": {"path": "string"}},
    {"name": "database_query", "params": {"sql": "string"}},
    {"name": "github_pr", "params": {"title": "string", "body": "string"}}
  ]
}
// 客户端:Claude Code、Cline、Continue.dev均支持MCP

MonkeyCode集成MCP配置

// ~/.monkeycode/mcp_servers.json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/workspace"],
      "env": {}
    },
    "database": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {"DATABASE_URL": "postgresql://user:pwd@localhost:5432/db"}
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {"GITHUB_TOKEN": "ghp_your_token"}
    }
  }
}
# 在MonkeyCode中使用
from monkeycode import MonkeyCode

mc = MonkeyCode(
    model="minimax/m3",
    mcp_config="~/.monkeycode/mcp_servers.json"
)

# 列出所有可用工具
print(mc.list_tools())
# 输出: [filesystem/read_file, database/query, github/create_pr, ...]

Agent实战:一条指令完成复杂任务

场景:修复Bug → 提交PR → 部署上线

# 一条指令,M3自动完成:
# 1. 读取CI失败日志
# 2. 分析代码找Bug
# 3. 自动修复
# 4. 写测试验证
# 5. 提交GitHub PR
# 6. 合并后自动部署

result = mc.execute(
    task="修复CI失败的测试,并在GitHub上创建PR然后部署到staging环境",
    context={
        "ci_log_url": "https://github.com/org/repo/actions/runs/12345",
        "deployment_target": "staging"
    },
    mode="thinking"
)

print(result.chain)
# [
#   {"step": 1, "tool": "filesystem/read_file", "input": "logs/ci.log", "output": "Test failed at test_auth.py:23"},
#   {"step": 2, "tool": "analyze", "input": "...", "output": "Fix: add token refresh logic"},
#   {"step": 3, "tool": "filesystem/write_file", "input": "auth.py patch", "output": "OK"},
#   {"step": 4, "tool": "execute", "input": "pytest", "output": "3 tests passed"},
#   {"step": 5, "tool": "github/create_pr", "input": "...", "output": "PR #234 created"},
#   {"step": 6, "tool": "deploy", "input": "...", "output": "Deployed to staging ✅"}
# ]

为什么M3适合做Agent?

特性 重要性 M3表现
Tool调用准确性 ⭐⭐⭐⭐⭐ ✅ 在Claw-Eval获最高分
长任务保持专注 ⭐⭐⭐⭐ ✅ 1M上下文,中间结果不丢失
多轮推理 ⭐⭐⭐⭐⭐ ✅ thinking模式支持
执行效率 ⭐⭐⭐⭐ ✅ MSA架构,推理快

常用MCP工具组合

场景 MCP Server 用途
代码开发 filesystem 读写项目文件
数据库 postgres/mysql 查询/执行SQL
Git操作 github 创建PR、合并MR
浏览器 puppeteer Web自动化测试
API测试 http RESTful接口测试
Docker docker 容器编排部署
// 添加更多MCP服务器
{
  "mcpServers": {
    "docker": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-docker"]
    },
    "http": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-http"]
    }
  }
}

M3的Tool Calling vs GPT/Claude

指标 M3 GPT-5.5 Claude 3.5
Claw-Eval得分 最高分 82% 79%
Tool选择准确率 94% 91% 93%
参数填充正确率 89% 85% 87%
多Tool调用顺序 ⚠️
Tool执行失败恢复 ⚠️ ⚠️
Logo

这里是“一人公司”的成长家园。我们提供从产品曝光、技术变现到法律财税的全栈内容,并连接云服务、办公空间等稀缺资源,助你专注创造,无忧运营。

更多推荐