Notion API MCP
模型上下文协议 (MCP) 服务器,通过 Notion 的 API 提供高级待办事项列表管理和内容组织功能。MCP 使 AI 模型能够与外部工具和服务交互,从而实现与 Notion 强大功能的无缝集成。
MCP 概述
基于 Python 的 MCP 服务器,使 AI 模型能够与 Notion 的 API 进行交互,提供:
- 待办事项管理:使用富文本、截止日期、优先级和嵌套子任务创建、更新和跟踪任务
- 数据库操作:使用自定义属性、过滤器和视图创建和管理 Notion 数据库
- 内容组织:使用 Markdown 支持、分层列表和块操作来构建和格式化内容
- 实时集成:通过干净的异步实现与 Notion 的工作区、页面和数据库直接交互
快速入门
入门
1. 创建 Notion 集成
- 前往https://www.notion.so/my-integrations
- 点击“新集成”
- 为您的集成命名(例如,“我的 MCP 集成”)
- 选择您将使用集成的工作区
- 复制“内部集成令牌” - 这将是您的
NOTION_API_KEY
- 应以“ntn_”开头
2. 设置 Notion Access
您需要一个父页面(用于创建新数据库)或一个现有的数据库 ID:
选项 A:新数据库的父页面
- 在浏览器中打开 Notion
- 创建新页面或打开现有页面以创建数据库
- 点击右上角的•••菜单
- 选择“添加连接”并选择您的集成
- 从 URL 中复制页面 ID - 它是最后一个斜杠之后和问号之前的字符串
- 例如:在
https://notion.so/myworkspace/123456abcdef...
中,ID 为123456abcdef...
- 这将是您的
NOTION_PARENT_PAGE_ID
- 例如:在
选项 B:现有数据库
- 打开您现有的 Notion 数据库
- 确保它已连接到您的集成(••• 菜单 > 添加连接)
- 从 URL 复制数据库 ID
- 例如:在
https://notion.so/myworkspace/123456abcdef...?v=...
中,ID 为123456abcdef...
- 这将是您的
NOTION_DATABASE_ID
- 例如:在
3. 安装 MCP 服务器
- 创建虚拟环境:
- 安装依赖项:
- 配置环境:
- 使用您的 Notion 凭证编辑 .env:
4.配置Claude桌面
重要提示:虽然服务器支持 .env 文件和环境变量,但 Claude Desktop 特别要求在其配置文件中进行配置才能使用 MCP。
添加到 Claude Desktop 的配置( ~/Library/Application Support/Claude/claude_desktop_config.json
):
注意:即使您已配置 .env 文件,也必须将这些环境变量添加到 Claude Desktop 配置中,以便 Claude 使用 MCP。.env 文件主要用于本地开发和测试。
文档
- 配置详情——详细的配置选项和环境变量
- 功能- 完整的功能列表和功能
- 架构——可用工具和使用示例的概述
- API 参考- 详细的 API 端点和实现细节
- 测试覆盖率矩阵- 测试覆盖率和验证状态
- 依赖项——项目依赖项和版本信息
- 变更日志- 开发进度和更新
发展
该服务器始终使用现代 Python 异步功能:
- 使用 Pydantic 模型进行类型安全配置
- 使用 httpx 异步 HTTP 以获得更好的性能
- 清洁 MCP 集成以公开 Notion 功能
- 正确的资源清理和错误处理
调试
该服务器包括全面的日志记录:
- 用于开发的控制台输出
- 作为服务运行时的文件日志记录
- 详细错误消息
- 调试级别的请求/响应日志记录
直接运行时设置PYTHONPATH
以包含项目根目录:
未来发展
计划增强的功能:
- 性能优化
- 添加请求缓存
- 优化数据库查询
- 实现连接池
- 高级功能
- 多工作区支持
- 批量操作
- 实时更新
- 高级搜索功能
- 开发者体验
- 交互式 API 文档
- 用于常见操作的 CLI 工具
- 其他代码示例
- 性能监控
- 测试增强功能
- 性能基准
- 负载测试
- 其他边缘情况
- 扩展集成测试
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
使用 Notion 的 API 实现高级待办事项列表管理和内容组织,支持创建数据库、动态过滤和协作任务跟踪等功能。
Related Resources
Related MCP Servers
- -securityAlicense-qualityA simple Model Context Protocol (MCP) server that integrates with Notion's API to manage my personal todo list through Claude.Last updated -117PythonMIT License
- AsecurityAlicenseAqualityIntegrates Claude with Todoist for natural language task management, supporting project and section organization, task creation, updating, completion, and deletion using everyday language.Last updated -193512JavaScriptMIT License
- -securityFlicense-qualityEnables interaction with Notion through the Notion API by exposing it as tools for LLMs, allowing operations like reading, creating, updating, and deleting Notion pages seamlessly via natural language.Last updated -4117TypeScript
- -securityAlicense-qualityA Model Context Protocol server that integrates with Notion's API to manage personal todo lists, allowing users to view, add, and update tasks directly from Claude.Last updated -13PythonMIT License