Skip to main content
Glama

Notion ReadOnly MCP 服务器

该项目为 Notion API 实现了优化的只读 MCP 服务器,专注于 AI 助手查询和检索 Notion 内容的性能和效率。

关键改进

  • 只读设计:专注于数据检索操作,确保安全访问 Notion 内容。

  • 最小化工具集:将公开的 Notion API 工具数量从 15+ 个减少到仅 6 个用于文档分析的必需工具。

  • 并行处理:通过实现异步和并行 API 请求来检索块内容,从而增强性能,显著缩短响应时间。

  • 扩展数据库访问:增加了对数据库、页面属性和评论检索操作的支持。

  • 针对 AI 助手进行了优化:大幅减少工具数量,解决了 Cursor 等 AI 助手中“太多工具会降低性能”的问题,该问题将模型限制为大约 40 种工具。

Related MCP server: notion-slim

工具比较

与标准 Notion API 集成相比,此只读实现公开的工具要少得多,从而提高了性能和与 AI 助手的兼容性:

Notion API 工具比较

精简的工具集有助于保持在建议的工具限制内,以实现最佳的 AI 助手性能,同时仍提供所有必需的功能。

安装

1.在Notion中设置集成:

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

创建 Notion Integration 代币

虽然我们限制了 Notion API 的只读操作范围,但将工作区数据暴露给 LLM 仍会带来不小的风险。注重安全的用户可能需要进一步配置集成的功能。

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

Notion Integration Token 功能显示已检查阅读内容

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

使用 npm:

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

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

使用 Docker:

将以下内容添加到您的.cursor/mcp.json或claude_desktop_config.json :

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

别忘了将ntn_****替换成你的集成密钥。你可以在集成配置选项卡中找到它。

3. 将内容与集成连接起来:

确保相关页面和数据库已连接到您的集成。

为此,请访问该页面,单击 3 个点,然后选择“连接到集成”。

将集成令牌添加到 Notion 连接

可用工具

该优化服务器仅公开必要的只读 Notion API 工具:

  • API-retrieve-a-page :获取页面信息

  • API-get-block-children :获取页面内容块(并行处理)

  • API-retrieve-a-block :获取特定区块的详细信息

  • API-retrieve-a-database :获取数据库信息

  • API-retrieve-a-comment :获取页面或区块上的评论

  • API-retrieve-a-page-property :从页面获取特定属性信息

  • API-get-one-pager :**新功能!**只需一次调用即可递归检索包含所有区块、数据库和相关内容的完整 Notion 页面

通过限制这 7 种基本工具(相比标准实施中的 15 种以上),我们确保:

  1. 在 Cursor 和 Claude 等具有工具数量限制的 AI 助手中表现更佳

  2. 选择合适的工具时减少人工智能模型的认知负荷

  3. 响应时间更快,需要考虑的 API 选项更少

  4. 通过最小化 API 表面积来增强安全性

自动内容探索

新的API-get-one-pager工具提供了一种强大的方法来探索 Notion 页面,而无需多次 API 调用:

  • 递归检索:自动遍历整个页面结构,包括嵌套块

  • 并行处理:同时获取多个块及其子块以实现最佳性能

  • 智能缓存:存储检索到的数据以最大限度地减少冗余 API 调用

  • 全面的内容:包括页面、块、数据库、评论和详细的属性信息

  • 可定制的深度:控制递归级别以在细节和性能之间取得平衡

使用单页工具

{
  "page_id": "YOUR_PAGE_ID",
  "maxDepth": 5,               // Optional: Maximum recursion depth (default: 5)
  "includeDatabases": true,    // Optional: Include linked databases (default: true)
  "includeComments": true,     // Optional: Include comments (default: true)
  "includeProperties": true    // Optional: Include detailed page properties (default: true)
}

这种自动探索功能对于需要了解 Notion 页面全部内容而无需进行数十次单独的 API 调用的 AI 助手特别有用,从而实现更快、更高效的响应。

异步处理

该服务器实现了先进的并行处理技术来处理大型 Notion 文档:

  • 多个请求被批量处理并同时处理

  • 自动为块子项处理分页

  • 结果在返回之前被有效地聚合

  • 控制台日志记录提供了对流程的可见性,而不会影响响应格式

示例

  1. 使用以下指令:

Get the content of page 1a6b35e6e67f802fa7e1d27686f017f2

人工智能将通过并行处理块内容来有效地检索页面详细信息。

  1. 使用数据库信息:

Get the structure of database 8a6b35e6e67f802fa7e1d27686f017f2

发展

建造:

pnpm build

执行:

pnpm dev

执照

麻省理工学院

AI助手性能优势

Cursor 和 Claude 等现代人工智能助手在有效处理的工具数量上存在限制:

  • 大多数模型可能不会考虑超过 40 种工具

  • 太多工具会降低整体性能和推理能力

  • 复杂的工具集增加了响应延迟和决策难度

此只读实现刻意减少了 Notion API 接口,以解决这些限制,同时保留所有基本功能。其结果是:

  • 人工智能助手的响应更快、更可靠

  • 提高与 Notion 内容交互时的准确性

  • 通过有针对性的 API 设计提高整体性能

Available Tools

8 tools
API-get-background-resultC

Retrieve the result of a background processing request

Inputs: page_id (required).

API-get-block-childrenC

Retrieve block children

Inputs: block_id (required), start_cursor, page_size.

API-get-one-pagerB

Recursively retrieve a full Notion page with all its blocks, databases, and related content

Inputs: page_id (required), maxDepth, includeDatabases, includeComments, +5 more.

API-retrieve-a-blockC

Retrieve a block

Inputs: block_id (required).

API-retrieve-a-commentC

Retrieve comments

Inputs: block_id (required), start_cursor, page_size.

API-retrieve-a-databaseC

Retrieve a database

Inputs: database_id (required).

API-retrieve-a-pageC

Retrieve a page

Inputs: page_id (required), filter_properties.

API-retrieve-a-page-propertyC

Retrieve a page property item

Inputs: page_id (required), property_id (required), page_size, start_cursor.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 8 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific Notion resources (blocks, pages, databases, comments, properties), but 'API-retrieve-a-block' and 'API-get-block-children' could cause confusion as both relate to blocks with overlapping retrieval functions. The descriptions help clarify, but the boundary isn't perfectly clear.

    Naming Consistency3/5

    The naming follows a mostly consistent 'API-[verb]-a-[noun]' pattern for seven tools, but 'API-get-background-result' and 'API-get-one-pager' deviate with different verb structures ('get' vs 'retrieve') and compound nouns. This mixed convention reduces predictability, though the names remain readable.

    Tool Count5/5

    With 8 tools, the count is well-scoped for a read-only Notion server, covering key retrieval operations without bloat. Each tool serves a clear purpose, making the set manageable and focused on the server's stated functionality.

    Completeness4/5

    For a read-only server, the tool set provides comprehensive coverage of Notion's core resources (pages, blocks, databases, comments, properties) and includes useful utilities like background result retrieval. A minor gap exists in lacking a tool for listing/searching across multiple resources, but agents can work around this with the available retrieval tools.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A token-optimized MCP server for Notion that reduces context window usage by 73% while preserving full functionality, enabling AI assistants to interact with Notion efficiently.
      29 npm
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A lightweight, read-only MCP server for Notion that enables searching, reading pages, and querying databases with token-efficient output and smart caching.
      42 npm
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Fast, read-only MCP server for Notion that reads directly from local SQLite cache, enabling instant access to Notion pages, databases, and users without API calls or rate limits.
      2
      MIT