用于Notion集成的模型上下文协议服务器,允许Claude和其他大型语言模型与您的Notion工作区进行交互。
克隆此仓库
安装依赖项
npm install
配置您的Notion API密钥
.env文件,并将your_notion_api_key_here替换为您实际的API密钥,或者构建服务器
npm run build
运行服务器
npm start
安装Claude for Desktop(如果尚未安装)
打开您的Claude for Desktop应用配置:
~/Library/Application Support/Claude/claude_desktop_config.json将Notion服务器添加到您的配置中:
{
"mcpServers": {
"notion": {
"command": "node",
"args": [
"/Users/shaheerahmad/Documents/notion-mcp-server/dist/index.js",
"--notion-api-key=YOUR_ACTUAL_API_KEY_HERE"
]
}
}
}
替换:
/Users/shaheerahmad/Documents/notion-mcp-server为您的项目目录的完整路径YOUR_ACTUAL_API_KEY_HERE为您实际的Notion API密钥重启Claude for Desktop
一旦连接到Claude for Desktop,您可以通过询问Claude问题来使用服务器,例如:
Claude会根据您的请求自动使用适当的工具。
搜索我的Notion工作区中的“会议记录”
获取具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion页面的内容
在Notion中创建一个标题为“周报”且内容为“本周我们完成了以下任务...”的新页面
更新具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion页面,内容为“向页面添加这些新信息”
您也可以更新标题:
更新具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion页面,标题为“新标题”,内容为“要添加的新内容”
在我的具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion页面中创建一个标题为“任务追踪器”的新数据库,属性包括:
{
"任务名称": { "title": {} },
"状态": {
"select": {
"options": [
{ "name": "未开始", "color": "red" },
{ "name": "进行中", "color": "yellow" },
{ "name": "已完成", "color": "green" }
]
}
},
"优先级": {
"select": {
"options": [
{ "name": "低", "color": "blue" },
{ "name": "中", "color": "yellow" },
{ "name": "高", "color": "red" }
]
}
},
"截止日期": { "date": {} }
}
查询具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion数据库,筛选条件为:
{
"property": "状态",
"select": {
"equals": "已完成"
}
}
您还可以添加排序:
查询具有ID 1aaada269d1b8003adceda69cf7bcd97的Notion数据库,排序条件为:
{
"property": "截止日期",
"direction": "升序"
}
更新现有数据库条目(数据库内的页面)的属性。
{
"tool_name": "update-database-entry",
"tool_params": {
"pageId": "数据库条目的page_id",
"properties": {
"状态": {
"select": {
"name": "已完成"
}
},
"优先级": {
"select": {
"name": "高"
}
},
"截止日期": {
"date": {
"start": "2023-12-31"
}
}
}
}
}
properties参数应符合Notion API对您数据库中特定属性类型的预期结构。不同的属性类型(文本、选择、日期等)需要不同的格式。
向现有的数据库添加具有自定义属性的新行。
{
"tool_name": "create-database-row",
"tool_params": {
"databaseId": "your_database_id_here",
"properties": {
"名称": {
"title": [
{
"text": {
"content": "新任务"
}
}
]
},
"状态": {
"select": {
"name": "未开始"
}
},
"优先级": {
"select": {
"name": "中"
}
},
"截止日期": {
"date": {
"start": "2023-12-15"
}
},
"备注": {
"rich_text": [
{
"text": {
"content": "这是一个通过API创建的新任务"
}
}
]
}
}
}
}
properties参数必须包括数据库所需的所有属性,并遵循每个属性类型的Notion API结构。
如果工具没有显示,请检查Claude for Desktop的日志:
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
确保您的Notion API密钥正确设置,并且您的集成已获得访问您想要交互的页面的权限。
如果日志中看到“意外的标记”错误,可能是console.log语句干扰了MCP协议。此版本的服务器已更新以避免这些问题。