Back to MCP directory
publicPublicdnsLocal runtime

makenotion_notion-mcp-server

该项目实现了一个Notion API的MCP服务器,允许通过MCP协议与Notion进行交互,支持搜索、评论、添加页面等操作。

article

README

🚀 Notion MCP 服务器

本项目实现了一个 MCP 服务器 对接 Notion 接口,为相关应用提供支持。

notion-mcp-sm

🚀 快速开始

本项目可助力您实现与 Notion 接口的对接,通过 MCP 服务器进行相关操作。

mcp-demo

📦 安装指南

1. 在 Notion 中设置集成

访问 https://www.notion.so/profile/integrations 创建一个新的 内部 集成,或选择一个现有的集成。

创建 Notion 集成令牌

尽管我们限制了 Notion 接口暴露的范围(例如,您无法通过 MCP 删除数据库),但将数据暴露给 LLM 存在非零风险。注重安全的用户可能希望进一步配置集成的 功能

例如,您可以创建一个只读集成令牌,仅授予“读取内容”访问权限(从“配置”选项卡):

Notion 集成令牌功能显示“读取内容”已选中

2. 将 MCP 配置添加到客户端

使用 npm

将以下内容添加到您的 .cursor/mcp.jsonclaude_desktop_config.json(MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "notionApi": {
      "command": "npx",
      "args": ["-y", "@notionhq/notion-mcp-server"],
      "env": {
        "OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2022-06-28\" }"
      }
    }
  }
}

使用 Docker

您也可以使用 Docker 运行 MCP 服务器。首先构建 Docker 镜像:

docker-compose build

然后将以下内容添加到您的 .cursor/mcp.jsonclaude_desktop_config.json

{
  "mcpServers": {
    "notionApi": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2022-06-28\"}",
        "notion-mcp-server-notion-mcp-server"
      ]
    }
  }
}

别忘了用您的集成秘密令牌替换 ntn_****。从集成配置选项卡中找到:

设置 Notion 集成

3. 连接到数据库

Notion 中 创建一个免费帐户并创建一些数据库。

💻 使用示例

基础用法

命令行使用示例

echo "{
  \"messages\": [
    {
      \"role\": \"user\",
      \"content\": \"告诉我有关人工智能的内容。\"
    }
  ],
  \"model\": \"gpt-3.5-turbo\",
  \"temperature\": 0.7
}" | curl -X POST http://localhost:1234/v1/chat/completions

Python 使用示例

import requests

url = "http://localhost:1234/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
}
data = {
    "messages": [
        {"role": "user", "content": "告诉我有关人工智能的内容。"}
    ],
    "model": "gpt-3.5-turbo",
    "temperature": 0.7
}

response = requests.post(url, json=data)
print(response.json())

🔧 技术细节

开发

安装依赖项

npm install

运行测试

npm test

构建项目

npm run build

运行服务器

npm start

⚠️ 注意事项

⚠️ 重要提示

确保您的 Notion 集成令牌具有适当的权限。

💡 使用建议

测试时使用较小的温度值以获得更确定的结果。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client