Notion MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Allows searching across a Notion workspace, retrieving/creating/updating pages, creating/querying/updating databases, and managing database entries with custom properties.

Not MCP 服务器

用于 Notion 集成的模型上下文协议服务器,允许 Claude 和其他 LLM 与您的 Notion 工作区进行交互。

特征

  • 搜索 Notion :搜索整个 Notion 工作区
  • 获取页面:从特定 Notion 页面检索内容
  • 创建页面:在 Notion 工作区中创建新页面
  • 更新页面:使用新内容或标题更新现有页面
  • 创建数据库:使用自定义属性创建新数据库
  • 查询数据库:使用过滤器和排序查询数据库
  • 更新数据库条目:更新数据库条目的属性
  • 创建数据库行:使用自定义属性向现有数据库添加新行

设置

  1. 克隆此存储库
  2. 安装依赖项
    npm install
  3. 配置你的 Notion API 密钥
    • Notion 开发者门户中创建集成
    • 复制您的 API 密钥
    • 您可以:
      • 编辑.env文件并将your_notion_api_key_here替换为你的实际 API 密钥,或者
      • 直接在 Claude for Desktop 配置中传递它(推荐,见下文)
  4. 构建服务器
    npm run build
  5. 运行服务器
    npm start

使用 Claude for Desktop 进行设置

  1. 安装 Claude for Desktop(如果尚未安装)
  2. 打开您的 Claude for Desktop App 配置:
    • 在 macOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 如果文件不存在,则创建该文件
  3. 将 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 密钥
  4. 重启 Claude 桌面版

使用服务器

一旦连接到 Claude for Desktop,您可以通过向 Claude 询问以下问题来使用服务器:

  • “在我的 Notion 工作区中搜索会议记录”
  • “获取我的项目规划页面内容”(您需要页面 ID)
  • “在 Notion 中创建一个包含任务列表的新页面”
  • “更新我的 Notion 页面(ID 为 1aaada269d1b8003adceda69cf7bcd97),内容为‘这是要添加到页面的一些新内容。’”
  • “在我的 Notion 页面中创建一个新的数据库,ID 为 1aaada269d1b8003adceda69cf7bcd97”
  • “查询 ID 为 1aaada269d1b8003adceda69cf7bcd97 的 Notion 数据库,查找状态为‘已完成’的项目”

Claude 将根据您的请求自动使用适当的工具。

工具使用示例

搜索概念

Search for "meeting notes" in my Notion workspace

获取页面内容

Get the content of my Notion page with ID 1aaada269d1b8003adceda69cf7bcd97

创建新页面

Create a new page in Notion with title "Weekly Report" and content "This week we accomplished the following tasks..."

更新现有页面

Update my Notion page with ID 1aaada269d1b8003adceda69cf7bcd97 with content "Adding this new information to the page."

您还可以更新标题:

Update my Notion page with ID 1aaada269d1b8003adceda69cf7bcd97 with title "New Title" and content "New content to add."

创建新数据库

Create a new database in my Notion page with ID 1aaada269d1b8003adceda69cf7bcd97 with title "Task Tracker" and properties { "Task Name": { "title": {} }, "Status": { "select": { "options": [ { "name": "Not Started", "color": "red" }, { "name": "In Progress", "color": "yellow" }, { "name": "Completed", "color": "green" } ] } }, "Priority": { "select": { "options": [ { "name": "Low", "color": "blue" }, { "name": "Medium", "color": "yellow" }, { "name": "High", "color": "red" } ] } }, "Due Date": { "date": {} } }

查询数据库

Query my Notion database with ID 1aaada269d1b8003adceda69cf7bcd97 with filter { "property": "Status", "select": { "equals": "Completed" } }

您还可以添加排序:

Query my Notion database with ID 1aaada269d1b8003adceda69cf7bcd97 with sort { "property": "Due Date", "direction": "ascending" }

更新数据库条目

更新现有数据库条目(数据库内的页面)的属性。

{ "tool_name": "update-database-entry", "tool_params": { "pageId": "page_id_of_database_entry", "properties": { "Status": { "select": { "name": "Completed" } }, "Priority": { "select": { "name": "High" } }, "Due Date": { "date": { "start": "2023-12-31" } } } } }

properties参数应与 Notion API 针对数据库中特定属性类型所期望的结构相匹配。不同的属性类型(文本、选择、日期等)需要不同的格式。

创建数据库行

使用自定义属性向现有数据库添加新行。

{ "tool_name": "create-database-row", "tool_params": { "databaseId": "your_database_id_here", "properties": { "Name": { "title": [ { "text": { "content": "New Task" } } ] }, "Status": { "select": { "name": "Not Started" } }, "Priority": { "select": { "name": "Medium" } }, "Due Date": { "date": { "start": "2023-12-15" } }, "Notes": { "rich_text": [ { "text": { "content": "This is a new task created via the API" } } ] } } } }

properties参数必须包含数据库的所有必需属性,并遵循每种属性类型的 Notion API 结构。

故障排除

  • 如果工具没有显示,请检查 Claude for Desktop 日志:
    tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
  • 确保您的 Notion API 密钥已正确设置,并且您的集成已被授予访问您想要交互的页面的权限。
  • 如果您在日志中看到“意外令牌”错误,则可能是 console.log 语句干扰了 MCP 协议。此版本的服务器已更新,以避免出现此类问题。

未来的改进

  • 添加数据库查询功能
  • 实施更好的内容格式
  • 添加对更多块类型的支持
-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器使 Claude 和其他 LLM 能够与 Notion 工作区交互,提供搜索、检索、创建和更新页面以及管理数据库等功能。

  1. Features
    1. Setup
      1. Setting up with Claude for Desktop
        1. Using the Server
          1. Tool Usage Examples
        2. Troubleshooting
          1. Future Improvements
            ID: 1456h4f2lq