Skip to main content
Glama

Notion ReadOnly MCP Server

by Taewoong1378

Notion ReadOnly MCP 服务器

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

关键改进

  • 只读设计:专注于数据检索操作,确保安全访问 Notion 内容。
  • 最小化工具集:将公开的 Notion API 工具数量从 15+ 个减少到仅 6 个用于文档分析的必需工具。
  • 并行处理:通过实现异步和并行 API 请求来检索块内容,从而增强性能,显著缩短响应时间。
  • 扩展数据库访问:增加了对数据库、页面属性和评论检索操作的支持。
  • 针对 AI 助手进行了优化:大幅减少工具数量,解决了 Cursor 等 AI 助手中“太多工具会降低性能”的问题,该问题将模型限制为大约 40 种工具。

工具比较

与标准 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.jsonclaude_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.jsonclaude_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 设计提高整体性能
Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

针对 AI 助手优化的只读服务器,可高效查询和检索 Notion 内容,具有并行处理功能和 7 个基本只读操作的最小化工具集。

  1. 关键改进
    1. 工具比较
      1. 安装
        1. 1.在Notion中设置集成:
        2. 将 MCP 配置添加到您的客户端:
        3. 将内容与集成连接起来:
      2. 可用工具
        1. 自动内容探索
          1. 使用单页工具
        2. 异步处理
          1. 示例
            1. 发展
              1. 执照
                1. AI助手性能优势

                  Related MCP Servers

                  • A
                    security
                    A
                    license
                    A
                    quality
                    Allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.
                    Last updated -
                    1
                    580
                    Python
                    MIT License
                    • Linux
                    • Apple
                  • A
                    security
                    A
                    license
                    A
                    quality
                    This server enables AI systems to integrate with Tavily's search and data extraction tools, providing real-time web information access and domain-specific searches.
                    Last updated -
                    2
                    9,397
                    468
                    JavaScript
                    MIT License
                    • Apple
                    • Linux
                  • -
                    security
                    F
                    license
                    -
                    quality
                    Enables AI assistants to interact with Metabase, providing access to dashboards, questions, databases, and tools for executing queries and viewing data through natural language.
                    Last updated -
                    JavaScript
                    • Apple
                  • A
                    security
                    A
                    license
                    A
                    quality
                    An MCP server that enables AI assistants to interact with the Notion API, allowing them to search, read, comment on, and create content in Notion workspaces through natural language commands.
                    Last updated -
                    19
                    7,075
                    2,226
                    TypeScript
                    MIT License
                    • Apple

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/Taewoong1378/notion-readonly-mcp-server'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server