Notion MCP 服务器是一个可与 Notion 实现无缝集成的模型上下文协议(MCP)服务器。它能让语言模型借助标准化工具,对工作区中的页面和数据库进行搜索、读取、创建和更新等操作。
git clone https://github.com/v-3/notion-server.git
cd notion-server
npm install
# 创建 .env 文件
echo "NOTION_API_KEY=你的 Notion API 密钥" > .env
# 或直接导出
export NOTION_API_KEY=你的 Notion API 密钥
npm run build
claude_desktop_config.json):{
"mcpServers": {
"notion": {
"command": "node",
"args": ["/绝对路径/to/notion-server/build/index.js"],
"env": {
"NOTION_API_KEY": "你的 Notion API 密钥"
}
}
}
}
// 搜索页面
{
query: string // 搜索查询
}
// 读取页面
{
pageId: string // 要读取的页面 ID
}
// 创建页面
{
title?: string, // 页面标题
content?: string, // 页面内容(Markdown 格式)
parentPageId: string // 父页面 ID
properties?: object // 数据库项属性
}
// 更新页面
{
pageId: string, // 要更新的页面 ID
content: string // 新的内容(Markdown 格式)
}
// 创建数据库项
{
title: string // 事项标题
content?: string // 可选内容(Markdown 格式)
properties: object // 属性,例如 { "任务状态": "未完成" }
}
// 更新数据库项
{
pageId: string // 要更新的页面 ID
properties: object // 新属性值,例如 { "任务状态": "已完成" }
}
初始化项目:
git clone https://github.com/v-3/notion-server.git && cd notion-server && npm install配置环境变量:
.env 文件并添加 NOTION_API_KEY=你的 API 密钥启动服务器:
npm start使用工具:
/api/pages 创建页面或数据库项/api/pages/{pageId} 更新现有页面或数据库项LICENSE 文件。⚠️ 重要提示
如需使用 sweir1 的版本,请直接克隆其仓库:
git clone https://github.com/sweir1/notion-server.git