OpenClaw + MCP 集成实战:用 Model Context Protocol 连接一切
摘要: Model Context Protocol (MCP) 是AI集成的统一标准协议,类似USB-C接口,实现工具与AI应用的无缝连接。文章通过Notion和PostgreSQL的MCP配置实战,详解MCP的架构、通信协议(JSON-RPC 2.0)及OpenClaw原生支持。MCP提供Tools(可调用函数)、Resources(可读数据)和Prompts(预定义模板)三大核心能力,支持s
OpenClaw + MCP 集成实战:用 Model Context Protocol 连接一切
🔌 MCP 就像 AI 的 USB-C 接口 —— 一个协议连接所有工具。以 Notion MCP + PostgreSQL MCP 为例,手把手演示配置、调试与生产级部署
📑 文章目录
- USB-C 类比:为什么 MCP 是 AI 集成的终局
- MCP 协议 30 秒速懂:架构、通信与生命周期
- OpenClaw 的 MCP 原生支持:零适配器集成
- MCP vs Skills:什么时候用哪个?
- 实战一:配置 Notion MCP 服务器
- 实战二:配置 PostgreSQL MCP 服务器
- Notion + PostgreSQL 联动:跨 MCP 工作流
- 调试技巧大全:从"连不上"到"调用失败"
- MCP 生态巡览:1000+ 服务器推荐
- 完整配置汇总 & 总结
1. USB-C 类比:为什么 MCP 是 AI 集成的终局
在 USB-C 出现之前,每个设备都有自己的接口——Micro-USB、Lightning、Mini-USB、各种专用插头。想给三个设备充电?你需要三根不同的线。
MCP 之前的 AI 集成也是这样:想让 Agent 连接 Google Drive?写一套自定义代码。连接 Slack?再写一套。连接数据库?再来一套。每个集成都是定制开发,互不通用。
💡 Model Context Protocol (MCP) = AI 世界的 USB-C
MCP 是由 Anthropic 于 2024 年 11 月发起的开放标准协议。它定义了 AI 应用(称为"Host")和外部工具/数据源(称为"Server")之间的统一通信接口。
就像 USB-C 让你用一根线连接任何设备,MCP 让你用一套配置连接任何工具——Google Drive、Notion、数据库、Slack、GitHub、浏览器自动化、文件系统……
一旦一个工具实现了 MCP Server 接口,所有支持 MCP 的 AI 应用(OpenClaw、Claude Desktop、Cursor、Cline、Windsurf……)都能立刻使用它。不需要为每个应用写适配器。
MCP 的三大核心能力
| 能力 | 类比 | 说明 |
|---|---|---|
| 🛠️ Tools | USB 设备上的按钮 | Server 暴露可调用的函数(如 notion.createPage、pg.query),Agent 像调用内置工具一样调用它们 |
| 📄 Resources | USB 存储设备上的文件 | Server 暴露可读取的数据(如数据库表结构、文档列表),Agent 可主动拉取为上下文 |
| 📝 Prompts | USB 设备的说明书 | Server 提供预定义的 Prompt 模板(如 “analyze this table”),Agent 可直接使用 |
2. MCP 协议 30 秒速懂:架构、通信与生命周期
2.1 三方角色
👤 Host(宿主) 🤖 Client(客户端) ⚙️ Server(服务器)
OpenClaw Gateway OpenClaw MCP Client MCP Server 进程
= 发起决策的应用 = 维护连接的中间层 = 提供工具的外部进程
|
| JSON-RPC 2.0
| (stdio / SSE / HTTP)
|
+-----------------------+-----------------------+
| | |
⚙️ Notion MCP ⚙️ PostgreSQL MCP ⚙️ Slack MCP
Server Server Server
- Host(OpenClaw Gateway):AI 应用本体。它决定何时调用哪个工具、如何处理结果。
- Client(OpenClaw 内置的 MCP Client):连接管理器。每个 MCP Server 对应一个 Client 实例,负责维护生命周期和消息路由。OpenClaw 使用
@modelcontextprotocol/sdk@1.25.3实现客户端。 - Server(外部进程):工具提供方。可以是本地 CLI(通过 stdio 通信)或远程服务(通过 SSE/HTTP 通信)。
2.2 两种传输方式
| 传输 | 协议 | 启动方式 | 适用场景 |
|---|---|---|---|
stdio ⭐ |
JSON-RPC 2.0 over stdin/stdout | OpenClaw 启动子进程 | 本地 CLI Server(最常用) |
sse |
JSON-RPC 2.0 over Server-Sent Events | Server 独立运行,Client 连接 URL | 远程 Server / Docker 容器内 |
2.3 生命周期
Agent 启动
|
v
OpenClaw 读取 openclaw.json 中的 mcpServers 配置
|
v
对每个 Server:启动子进程(stdio)或建立连接(sse)
|
v
发送 initialize 请求 → Server 返回能力列表(Tools / Resources / Prompts)
|
v
Agent 运行时:根据用户请求,自动发现并调用匹配的 MCP Tool
|
v
Agent 发送 tools/call 请求 → Server 执行 → 返回结果
|
v
Agent 会话结束 / Gateway 关闭
|
v
发送 shutdown 通知 → 子进程退出
整个过程对用户透明——你不需要知道 Agent 是调用了内置工具还是 MCP 工具。Agent 像使用内置 Skill 一样自然地发现和调用 MCP 工具。
3. OpenClaw 的 MCP 原生支持:零适配器集成
3.1 配置方式
OpenClaw 使用 @modelcontextprotocol/sdk@1.25.3 原生支持 MCP 服务器。配置非常简单——在 openclaw.json 中声明服务器名称、启动命令和参数,Agent 就可以自动发现和调用这些工具。
// ~/.openclaw/openclaw.json — MCP 基本配置结构
{
"mcpServers": {
"服务器名称": {
"command": "启动命令",
"args": ["参数1", "参数2"],
"env": {
"环境变量": "值"
}
}
}
}
就这么简单。没有 SDK 适配、没有自定义封装、没有胶水代码。
3.2 配置字段详解
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
command |
string | ✅ | MCP Server 的启动命令(如 npx、uvx、docker、二进制路径) |
args |
string[] | ✅ | 传递给命令的参数数组 |
env |
object | ❌ | 注入给 Server 进程的环境变量(API Key 等) |
transport |
“stdio” | “sse” | ❌ | 传输方式,默认 stdio |
url |
string | SSE 时必填 | SSE 模式下 Server 的 URL |
disabled |
boolean | ❌ | 设为 true 临时禁用此 Server |
timeout |
number | ❌ | 连接/调用超时(毫秒) |
3.3 环境变量注入
和 Skills 一样,MCP 配置中永远不要硬编码 API Key。使用 ${VAR} 语法引用环境变量,OpenClaw 在加载配置时会自动替换:
{
"mcpServers": {
"notion": {
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"NOTION_API_KEY": "${NOTION_API_KEY}",
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
}
}
}
}
# 在 .env 文件中设置实际值
echo 'NOTION_API_KEY=ntn_xxxxxxxxxxxxx' >> ~/.openclaw/.env
echo 'OPENAI_API_KEY=sk-xxxxxxxxxxxxx' >> ~/.openclaw/.env
3.4 Agent 如何发现 MCP 工具
当 OpenClaw 启动 MCP Server 后,Server 会返回自己暴露的工具列表。OpenClaw 将这些工具与内置工具统一注册到 Agent 的工具集中。在 Agent 看来,notion.search(MCP 工具)和 exec(内置工具)没有本质区别——它们都只是"可以调用的函数"。
# Agent 看到的工具列表(混合了内置工具和 MCP 工具):
内置工具:
exec — 执行 Shell 命令
read_file — 读取文件
write_file — 写入文件
browser — 浏览器操作
MCP 工具(来自 Notion Server):
notion.search — 搜索 Notion 内容
notion.create_page — 创建页面
notion.update_page — 更新页面
notion.list_databases — 列出数据库
notion.query_database — 查询数据库
MCP 工具(来自 PostgreSQL Server):
pg.query — 执行 SQL 查询
pg.list_tables — 列出表
pg.describe_table — 查看表结构
💡 关键洞察:Agent 不需要知道某个工具是内置的还是来自 MCP。它只看到"一堆可用工具"和每个工具的描述。当用户说"在我的 Notion 里搜索上周的会议记录",Agent 会自动匹配到
notion.search工具并调用——跟调用exec或read_file的体验完全一样。
4. MCP vs Skills:什么时候用哪个?
这是新手最困惑的问题:MCP Server 和 Skill 都能扩展 Agent 的能力,该选哪个?
🔌 MCP Server
- ✅ 通过 JSON-RPC 2.0 协议通信的外部进程
- ✅ 独立于 OpenClaw 运行
- ✅ 跨平台可移植(Claude Desktop、Cursor 等也能用)
- ✅ 任何语言实现(Python、Node、Go、Rust…)
- ✅ 社区 1,000+ 现成 Server
- ❌ 不能访问 OpenClaw 内部状态
- ❌ 进程间通信有轻微延迟
🧩 Skill
- ✅ 运行在 Agent 上下文内部的 Markdown 指令
- ✅ 可以引用 OpenClaw 内部工具和状态
- ✅ 零延迟(直接在进程内加载)
- ✅ 纯 Markdown 编写,无需编程
- ✅ 可以定义工作流和多步逻辑
- ❌ 依赖模型理解指令的准确性
选择决策树
你要连接的是外部服务(API、数据库、SaaS)?
|
+-- 是 → 社区有现成的 MCP Server 吗?
| |
| +-- 有 → 🔌 用 MCP Server(配置即用,5 分钟搞定)
| |
| +-- 没有 → 需要跨 AI 应用通用吗?
| |
| +-- 是 → 🔌 自己写 MCP Server(可移植)
| +-- 否 → 🧩 写 Skill + 调用 exec/curl
|
+-- 否 → 你要编排多步工作流?
|
+-- 是 → 🧩 用 Skill(更适合流程编排)
+-- 否 → 内置工具就够了
黄金组合:MCP + Skill 协作
MCP 和 Skill可以同时使用,这才是最强大的模式:
实际案例:每日项目状态报告
🧩 Skill "daily-project-report"
├─ 步骤 1: 调用 MCP 工具 pg.query 查询今日 JIRA Ticket
├─ 步骤 2: 调用 MCP 工具 notion.query_database 获取项目文档
├─ 步骤 3: 调用 MCP 工具 slack.list_messages 拉取今日频道消息
├─ 步骤 4: AI 综合分析,生成结构化报告
└─ 步骤 5: 调用 MCP 工具 notion.create_page 写入报告
Skill 负责编排工作流,MCP Server 负责连接外部服务。
5. 实战一:配置 Notion MCP 服务器
Notion 是知识管理神器,搭配 OpenClaw 可以实现:AI 自动写文档、查询知识库、管理任务看板。
Step 1:创建 Notion Integration & 获取 API Key
1. 访问 https://www.notion.so/my-integrations
2. 点击 "+ New integration"
3. 填写名称(如 "OpenClaw Agent")
4. 选择关联的 Workspace
5. 权限设置:
- Content Capabilities: Read content ✅, Update content ✅, Insert content ✅
- 如果不需要写入,只勾 Read(最小权限原则)
6. 点击 "Submit" → 复制 Internal Integration Secret
格式:ntn_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
7. 回到 Notion → 打开你想让 Agent 访问的页面/数据库
8. 右上角 "..." → "Connections" → 找到并添加你的 Integration
⚠️ 这一步很多人忘了!不添加 Connection,Agent 什么都访问不到。
Step 2:配置 openclaw.json
// ~/.openclaw/openclaw.json — Notion MCP 配置
{
"mcpServers": {
"notion": {
"command": "npx",
"args": [
"-y",
"@notionhq/notion-mcp-server"
],
"env": {
"NOTION_API_KEY": "${NOTION_API_KEY}",
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
}
}
}
}
# 设置环境变量
echo 'NOTION_API_KEY=ntn_xxxxxxxxxxxxx' >> ~/.openclaw/.env
# 重启 Gateway
openclaw gateway restart
# 或 Docker 环境:
# docker compose restart openclaw-gateway
⚠️ OPENAI_API_KEY 说明:Notion 官方 MCP Server 内部使用 OpenAI 的 Embedding 进行语义搜索,所以需要
OPENAI_API_KEY。如果你不使用 OpenAI,可以用NOTION_MARKDOWN_CONVERSION=true环境变量跳过 Embedding,改为纯文本模式。
Step 3:验证连接
# 方法一:查看 MCP Server 状态
openclaw mcp list
# 期望输出:
# notion: connected (5 tools, 0 resources)
# - notion.search
# - notion.create_page
# - notion.update_page
# - notion.list_databases
# - notion.query_database
# 方法二:在聊天中直接测试
# "搜索我 Notion 里关于 '项目计划' 的页面"
# Agent 应该自动调用 notion.search 并返回结果
Step 4:实际使用示例
💬 你:帮我在 Notion 的 "Meeting Notes" 数据库里创建一条新的会议记录,
标题是"2026-03-02 周会",内容包括三个议题:
1. Q1 OKR 进度回顾
2. 新功能需求讨论
3. 下周任务分配
🤖 Agent:好的,我来创建这条会议记录。
[调用 notion.list_databases]
找到数据库 "Meeting Notes"(ID: abc123...)
[调用 notion.create_page]
✅ 已在 "Meeting Notes" 数据库中创建新页面:
- 标题:2026-03-02 周会
- 包含三个议题的结构化内容
- 链接:https://notion.so/abc123...
要帮你添加更多内容或通知参会人吗?
6. 实战二:配置 PostgreSQL MCP 服务器
让 AI Agent 直接查询数据库——听起来很美好也很危险。下面我们安全地配置 PostgreSQL MCP Server。
Step 1:安装 PostgreSQL MCP Server
# 方案一:使用 npx(推荐,自动下载最新版)
# 无需手动安装,在 openclaw.json 中直接引用即可
# 方案二:全局安装
npm install -g @modelcontextprotocol/server-postgres
# 方案三:如果你偏好 Python 实现
pip install mcp-server-postgres
Step 2:创建只读数据库用户(安全第一!)
-- 🚨 永远不要给 Agent 使用有写权限的数据库用户!
-- 创建一个专用的只读用户
-- 1. 创建用户
CREATE USER openclaw_readonly WITH PASSWORD 'strong-random-password-here';
-- 2. 授予连接权限
GRANT CONNECT ON DATABASE myapp_db TO openclaw_readonly;
-- 3. 授予 Schema 使用权限
GRANT USAGE ON SCHEMA public TO openclaw_readonly;
-- 4. 授予所有表的只读权限
GRANT SELECT ON ALL TABLES IN SCHEMA public TO openclaw_readonly;
-- 5. 未来新建的表也自动授予只读
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO openclaw_readonly;
-- 6. (可选)限制特定敏感表
REVOKE SELECT ON users_passwords FROM openclaw_readonly;
REVOKE SELECT ON payment_info FROM openclaw_readonly;
🚨 安全红线:永远使用只读用户。如果 Agent 被 Prompt Injection 攻击,只读用户意味着攻击者最多只能读取数据——不能 DROP TABLE、不能 DELETE、不能 INSERT。数据泄露很糟糕,但数据删除是灾难。
Step 3:配置 openclaw.json
// ~/.openclaw/openclaw.json — PostgreSQL MCP 配置
{
"mcpServers": {
"notion": {
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"NOTION_API_KEY": "${NOTION_API_KEY}",
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
}
},
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"${POSTGRES_CONNECTION_STRING}"
],
"env": {
"POSTGRES_CONNECTION_STRING": "${POSTGRES_CONNECTION_STRING}"
}
}
}
}
# 设置连接字符串(使用只读用户!)
echo 'POSTGRES_CONNECTION_STRING=postgresql://openclaw_readonly:strong-random-password@db-host:5432/myapp_db?sslmode=require' \
>> ~/.openclaw/.env
# 重启 Gateway
openclaw gateway restart
Step 4:验证连接 & 测试
# 查看 MCP Server 状态
openclaw mcp list
# 期望:
# notion: connected (5 tools)
# postgres: connected (3 tools)
# - pg.query
# - pg.list_tables
# - pg.describe_table
💬 你:查看一下 orders 表中最近 7 天的订单数量和总金额
🤖 Agent:
[调用 pg.describe_table: orders]
了解表结构:id, user_id, amount, status, created_at...
[调用 pg.query]
SELECT
COUNT(*) as order_count,
SUM(amount) as total_amount,
DATE(created_at) as order_date
FROM orders
WHERE created_at >= NOW() - INTERVAL '7 days'
GROUP BY DATE(created_at)
ORDER BY order_date DESC;
📊 最近 7 天订单统计:
| 日期 | 订单数 | 总金额 |
|-----------|--------|----------|
| 2026-03-02 | 142 | $12,350 |
| 2026-03-01 | 168 | $15,620 |
| ... | ... | ... |
总计 1,047 笔订单,总金额 $89,230。需要更详细的分析吗?
7. Notion + PostgreSQL 联动:跨 MCP 工作流
单个 MCP Server 已经很强,但多个 MCP Server 联动才是 Agent 真正发光的地方。下面演示一个真实工作流:从数据库提取数据,自动生成 Notion 报告。
7.1 工作流描述
💬 你:从数据库查询本月的销售数据,生成一份分析报告,
发布到 Notion 的 "Monthly Reports" 数据库里。
🤖 Agent 的执行过程:
① [MCP: pg.list_tables]
发现 orders, products, customers 表
② [MCP: pg.describe_table: orders]
了解字段:id, product_id, quantity, amount, created_at...
③ [MCP: pg.query]
执行多个分析 SQL:
- 本月总销售额 & 同比增长
- Top 10 畅销产品
- 客户地域分布
- 日均订单量趋势
④ [AI 分析]
综合数据生成洞察:
- "3 月前两周销售额同比增长 23%,主要贡献来自..."
- "华东地区占比从 45% 提升到 52%..."
⑤ [MCP: notion.list_databases]
找到 "Monthly Reports" 数据库
⑥ [MCP: notion.create_page]
创建报告页面,包含:
- 数据表格
- 关键指标
- AI 生成的分析洞察
- 建议下一步行动
⑦ [回复用户]
"报告已发布到 Notion,链接:https://notion.so/xxx"
7.2 用 Skill 固化这个工作流
如果这是你每月都要做的事,写个 Skill 让它一键执行:
---
name: monthly-sales-report
description: >-
Query database for monthly sales data and publish analysis report
to Notion. Use for: sales report, monthly report, revenue analysis.
version: 1.0.0
metadata: {"openclaw":{"emoji":"📊","requires":{"env":["POSTGRES_CONNECTION_STRING","NOTION_API_KEY"]}}}
---
# Monthly Sales Report Generator
## Workflow
1. **Get current month range**: Calculate first and last day of current month.
2. **Query sales overview** using pg.query:
SELECT COUNT(*) as orders, SUM(amount) as revenue,
AVG(amount) as avg_order
FROM orders
WHERE created_at BETWEEN '{first_day}' AND '{last_day}'
3. **Query top products** using pg.query:
SELECT p.name, SUM(o.quantity) as units, SUM(o.amount) as revenue
FROM orders o JOIN products p ON o.product_id = p.id
WHERE o.created_at BETWEEN '{first_day}' AND '{last_day}'
GROUP BY p.name ORDER BY revenue DESC LIMIT 10
4. **Query daily trend** using pg.query:
SELECT DATE(created_at) as day, COUNT(*) as orders, SUM(amount) as revenue
FROM orders
WHERE created_at BETWEEN '{first_day}' AND '{last_day}'
GROUP BY DATE(created_at) ORDER BY day
5. **Generate analysis**: Based on the queried data, write 3-5 key insights
comparing to previous month trends.
6. **Publish to Notion**: Use notion.create_page to create a page in
"Monthly Reports" database with:
- Title: "Sales Report — {Month} {Year}"
- Sections: Overview, Top Products, Daily Trend, Insights
- Format all numbers with comma separators and currency symbols
7. **Report to user**: Share the Notion page link and key highlights.
## Error Handling
- If database connection fails, report error and suggest checking credentials
- If Notion API fails, save report as local Markdown file as backup
# 使用方式:
/monthly-sales-report
# 或自然语言触发:
"生成本月的销售报告并发到 Notion"
8. 调试技巧大全:从"连不上"到"调用失败"
8.1 Server 连接不上?
# 1. 确认 MCP Server 列表和状态
openclaw mcp list
# 如果显示 "disconnected" 或根本没有列出你的 Server:
# 2. 手动运行 Server 命令测试
npx -y @notionhq/notion-mcp-server
# 看有没有报错(缺依赖、权限问题等)
# 3. 检查环境变量是否正确注入
echo $NOTION_API_KEY
# 如果为空,说明 .env 没加载
# 4. 查看 Gateway 日志中的 MCP 相关信息
grep -i "mcp\|notion\|postgres" ~/.openclaw/logs/*.log | tail -50
# 5. 常见问题:npx 在容器内找不到
# Docker 环境中需要确保 Node.js 在 PATH 中
docker exec openclaw-gateway which npx
# 如果找不到,需要在 Dockerfile 中安装 Node.js
8.2 常见问题排查表
| 症状 | 可能原因 | 解决方案 |
|---|---|---|
| Server 启动后立即退出 | 缺少必需的环境变量 | 检查 env 字段是否包含 Server 要求的所有变量 |
| Server 连接但无工具 | 初始化握手失败 | 检查 Server 版本兼容性;尝试更新到最新版 |
| Notion 工具返回空结果 | 页面未添加 Integration Connection | 在每个目标页面/数据库中手动添加 Connection |
| PostgreSQL 连接超时 | 防火墙阻止 / SSL 配置错误 | 确认 sslmode 参数;检查安全组规则 |
| Agent 不调用 MCP 工具 | 工具描述与用户请求不匹配 | 在聊天中明确提及工具名;或直接用 /mcp notion.search "xxx" |
| Docker 中 stdio Server 不工作 | 容器内没有所需的运行时 | 使用 setupCommand 安装依赖或自定义镜像 |
| Server 调用返回错误 | API Key 过期 / 权限不足 | 检查提供商 Dashboard 中的 Key 状态和权限设置 |
8.3 交互式调试
# 在聊天中直接让 Agent 帮你调试:
💬 你:请列出你当前可用的所有 MCP 工具,包括每个工具的名称和描述。
如果有任何 MCP Server 连接失败的,也请告诉我。
# Agent 会列出所有已注册的 MCP 工具
# 如果某个 Server 未连接,它会明确告知
8.4 MCP Inspector 工具
社区提供了一个专门的 MCP 调试工具——MCP Inspector,可以独立测试任何 MCP Server:
# 安装 MCP Inspector
npx -y @modelcontextprotocol/inspector
# 它会启动一个 Web UI(http://localhost:5173)
# 你可以:
# 1. 连接到任何 MCP Server
# 2. 查看 Server 暴露的 Tools / Resources / Prompts
# 3. 手动调用工具并查看返回值
# 4. 查看完整的 JSON-RPC 消息交换
9. MCP 生态巡览:1000+ 服务器推荐
MCP 生态在 2025-2026 年爆发式增长。社区已有超过 1,000 个 MCP 服务器,覆盖几乎所有主流工具和服务。
精选 MCP Server 分类推荐
📼 办公 & 协作
| Server | 包名 | 功能 |
|---|---|---|
| 📝 Notion MCP | @notionhq/notion-mcp-server |
搜索、创建、更新页面和数据库 |
| 💬 Slack MCP | @anthropic/slack-mcp-server |
读消息、搜频道、发消息 |
| 📁 Google Drive MCP | @anthropic/gdrive-mcp-server |
搜索、读取、创建 Google Docs/Sheets |
| 📧 Gmail MCP | @anthropic/gmail-mcp-server |
搜索邮件、读取、撰写草稿 |
🗃️ 数据库 & 存储
| Server | 包名 | 功能 |
|---|---|---|
| 🐘 PostgreSQL MCP | @modelcontextprotocol/server-postgres |
SQL 查询、表结构浏览 |
| 🛢️ SQLite MCP | @modelcontextprotocol/server-sqlite |
轻量级本地数据库 |
| 📗 MongoDB MCP | mcp-mongo-server |
文档查询、聚合管道 |
| 🔴 Redis MCP | mcp-redis-server |
键值操作、缓存管理 |
👨💻 开发者工具
| Server | 包名 | 功能 |
|---|---|---|
| 🐙 GitHub MCP | @modelcontextprotocol/server-github |
Issue、PR、仓库管理 |
| 🐳 Docker MCP | mcp-docker-server |
容器管理、日志查看 |
| 🌐 Puppeteer MCP | @anthropic/puppeteer-mcp-server |
浏览器自动化 |
| 📦 NPM MCP | mcp-npm-server |
包搜索、版本查询 |
📊 数据 & API
| Server | 包名 | 功能 |
|---|---|---|
| 🔍 Brave Search MCP | @anthropic/brave-search-mcp-server |
Web 搜索 |
| 📈 Grafana MCP | mcp-grafana-server |
查询监控面板、告警 |
MCP Server 发现渠道
| 渠道 | 地址 | 说明 |
|---|---|---|
| MCP 官方仓库 | github.com/modelcontextprotocol/servers |
官方和审核过的 Server 合集 |
| MCP Hub | mcphub.io |
社区 MCP Server 市场 |
10. 完整配置汇总 & 总结
完整的 openclaw.json MCP 配置示例
// ~/.openclaw/openclaw.json — 完整 MCP 集成配置
{
"mcpServers": {
// ===== 办公工具 =====
"notion": {
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"NOTION_API_KEY": "${NOTION_API_KEY}",
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
}
},
"google-drive": {
"command": "npx",
"args": ["-y", "@anthropic/gdrive-mcp-server"],
"env": {
"GOOGLE_CLIENT_ID": "${GOOGLE_CLIENT_ID}",
"GOOGLE_CLIENT_SECRET": "${GOOGLE_CLIENT_SECRET}"
}
},
"slack": {
"command": "npx",
"args": ["-y", "@anthropic/slack-mcp-server"],
"env": {
"SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}"
}
},
// ===== 数据库 =====
"postgres": {
"command": "npx",
"args": [
"-y", "@modelcontextprotocol/server-postgres",
"${POSTGRES_CONNECTION_STRING}"
],
"env": {
"POSTGRES_CONNECTION_STRING": "${POSTGRES_CONNECTION_STRING}"
}
},
// ===== 开发工具 =====
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
}
},
// ===== 搜索 =====
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic/brave-search-mcp-server"],
"env": {
"BRAVE_API_KEY": "${BRAVE_API_KEY}"
}
},
// ===== 暂时禁用的 Server =====
"mongodb": {
"command": "npx",
"args": ["-y", "mcp-mongo-server"],
"env": {
"MONGO_URI": "${MONGO_URI}"
},
"disabled": true
}
},
// ===== MCP 安全策略 =====
"tools": {
"elevated": {
"mode": "ask",
"gates": [
"exec",
"write",
"mcp.*.create",
"mcp.*.update",
"mcp.*.delete"
]
}
}
}
对应的 .env 文件
# ~/.openclaw/.env
NOTION_API_KEY=ntn_xxxxxxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxxxxx
POSTGRES_CONNECTION_STRING=postgresql://openclaw_readonly:xxx@host:5432/db?sslmode=require
GITHUB_TOKEN=ghp_xxxxxxxxxxxxx
SLACK_BOT_TOKEN=xoxb-xxxxxxxxxxxxx
BRAVE_API_KEY=BSAxxxxxxxxxxxxx
GOOGLE_CLIENT_ID=xxxxxxxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxx
🎯 五个关键 Takeaway
- MCP 是 AI 的 USB-C —— 一套协议连接所有工具,配置即用,无需自定义代码
- OpenClaw 原生支持 —— 在
mcpServers中声明 Server,Agent 自动发现和调用工具,与内置工具无缝混合 - MCP + Skill 是黄金组合 —— MCP 连接外部服务,Skill 编排工作流。两者协作远大于任何一方单独使用
- 安全是底线 —— 最小权限原则:只读数据库用户、最小 API 权限、写操作需人工审批、Key 通过环境变量注入
- 生态已成熟 —— 1,000+ 现成 MCP Server 覆盖主流工具。大多数情况下你只需要配置,不需要开发
📚 参考资料
- MCP 官方文档
- OpenClaw MCP 集成文档
- SafeClaw: OpenClaw MCP 实战指南
- MCP 官方 Server 仓库
- Awesome MCP Servers
- Glama MCP Server 目录
- Notion Integration 管理
- MCP Inspector 调试工具
- Anthropic MCP 开发者文档
如果觉得有帮助,欢迎 点赞 👍 收藏 ⭐ 关注 🔔,有问题评论区见!
本文为原创内容,转载请注明出处。
更多推荐

所有评论(0)