Claude Code MCP
Claude Code MCP 扩展配置指南
MCP(Model Context Protocol)让 Claude Code 能够连接外部工具和数据源。本文以 Notion 为例,介绍如何配置 MCP 扩展。
什么是 MCP?
MCP 是一种标准协议,允许 AI 模型与外部工具/数据源交互。配置好后,Claude Code 可以直接读写 Notion 数据库、查询文件系统、调用外部 API 等。
安装 Notion MCP Server
sudo npm install -g @notionhq/notion-mcp-server 获取 Notion API Key
- 访问 Notion Integrations
- 创建新的 Internal Integration
- 复制生成的 API Token(格式:
ntn_xxx) - 在 Notion 中给你的数据库添加这个 Integration 访问权限
配置 Claude Code
编辑 ~/.claude.json:
{
"mcpServers": {
"notion": {
"type": "stdio",
"command": "node",
"args": [
"/usr/lib/node_modules/@notionhq/notion-mcp-server/bin/cli.mjs"
],
"env": {
"NOTION_API_KEY": "你的API Key"
}
}
}
} 验证配置
claude mcp list
# 输出应显示:notion: node /usr/lib/node_modules/... - ✓ Connected 使用示例
配置成功后,你可以直接让 Claude Code:
- "帮我查询 Notion 里标记为『进行中』的任务"
- "在 FAQ 数据库里添加一个新条目"
- "读取『项目库』数据库的所有项目信息"
我的 Notion 数据库
| 数据库 | ID |
|---|---|
| 📋 测试用例数据库 | a4aafded-df30-4d18-aeae-1f6ce282c6a4 |
| ❓ FAQ 问答数据库 | f4466ba6-167f-4d79-a529-05ae555e8d75 |
| 📁 项目库 | 85159686-3f00-48b3-9d60-63f056ce1ee5 |