不用手动一个个配置——MCP Tool Discovery 让 Agent 自动发现 MCP 服务器上有哪些工具可以用。
MCP Tool Discovery 是 Model Context Protocol 中的工具发现机制。当 Agent 连接到 MCP 服务器时,它会自动获取该服务器提供的所有可用工具列表,包括工具名称、参数定义和功能描述。
| 类型 | 说明 | 示例 |
|---|---|---|
| Resources | 数据源,Agent 可读取 | 数据库表、文件内容 |
| Tools | 函数,Agent 可调用 | create_issue、send_message |
| Prompts | 预定义提示模板 | code_review、summarize |
// openclaw.json 中的 MCP 服务器配置
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_xxxx"
}
},
"postgres": {
"command": "npx",
"args": ["@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://..."
}
}
}
}
OpenClaw Gateway
│
▼
┌───────────────┐
│ MCP Client │
│ (内置) │
└───────┬───────┘
│
▼ JSON-RPC 2.0
┌───────────────┐
│ MCP Server │
│ (GitHub等) │
└───────┬───────┘
│
▼
┌───────────────┐
│ tools/list │
│ → 返回工具列表│
│ → 工具schema │
└───────────────┘
│
▼
┌───────────────┐
│ Agent 可用 │
│ 工具自动注册 │
└───────────────┘
| 特性 | MCP | Skills | Function Calling |
|---|---|---|---|
| 标准化 | ✅ 统一协议 | ❌ 私有格式 | ❌ 各LLM不同 |
| 跨Agent共享 | ✅ 支持 | ⚠️ 需适配 | ❌ 不支持 |
| 工具发现 | ✅ 自动 | ⚠️ 手动 | ❌ 手动 |
| 适用场景 | 标准化集成 | Agent特定能力 | 简单函数调用 |