使用说明

项目简介

本项目 'Notion_MCP_advanced' 是一个基于 Model Context Protocol (MCP) 的服务器实现,它充当 Claude 等大型语言模型 (LLM) 与 Notion 之间的桥梁。通过这个服务器,您可以让 Claude 理解和操作您在 Notion 中维护的个人待办事项列表,实现通过自然语言指令管理 Notion 任务的功能。

主要功能点

  • 添加待办事项: 通过自然语言指令,让 Claude 将新的任务添加到您的 Notion 待办事项数据库中,可以包含任务名称、描述和相关链接。
  • 查看待办事项: 询问 Claude 查看所有待办事项,服务器会将您的 Notion 任务列表以结构化的形式返回给 Claude。
  • 完成待办事项: 通过指定任务ID,让 Claude 将 Notion 中已完成的任务标记为完成状态。
  • 集成 Notion: 利用 Notion API,安全地连接和操作您指定的 Notion 数据库。

安装步骤

  1. 克隆仓库: 首先,将 GitHub 仓库克隆到本地:

    git clone https://github.com/Ruijian-Zha/Notion_MCP_advanced.git
    cd Notion_MCP_advanced
  2. 配置 Python 环境: 建议使用虚拟环境管理项目依赖:

    python -m venv .venv
    source .venv/bin/activate  # Linux/macOS
    .venv\Scripts\activate  # Windows
    uv pip install -e .
  3. 创建 Notion 集成:

  4. 分享数据库:

    • 打开您的 Notion 待办事项数据库。
    • 点击右上角的 "..." 菜单,选择 "添加连接"。
    • 搜索并选择您刚刚创建的集成,授予集成访问您数据库的权限。
  5. 配置环境变量:

    • 在项目根目录下创建 '.env' 文件。
    • 编辑 '.env' 文件,填入您的 Notion API 密钥和数据库 ID:
      NOTION_API_KEY=YOUR_NOTION_API_KEY
      NOTION_DATABASE_ID=YOUR_NOTION_DATABASE_ID

      'NOTION_DATABASE_ID' 是您的 Notion 数据库的 ID。在 Notion 数据库页面的 URL 中可以找到,例如 'https://www.notion.so/{database_id}?v=...'。

服务器配置 (Claude Desktop)

如果您使用 Claude Desktop,可以通过以下 JSON 配置来启动和连接 Notion MCP 服务器。将以下配置添加到 Claude Desktop 的配置文件 'claude_desktop_config.json' 中的 'mcpServers' 部分:

{
  "mcpServers": {
    "notion-todo": {
      "name": "notion-todo",  // MCP 服务器的名称,可以自定义
      "command": "/path/to/your/.venv/bin/python", // Python 解释器路径,请替换为您的虚拟环境中的 Python 路径
      "args": ["-m", "notion_mcp"], // 启动服务器的参数,固定为 ["-m", "notion_mcp"]
      "cwd": "/path/to/Notion_MCP_advanced" // 项目根目录的路径,请替换为您的 Notion_MCP_advanced 仓库的本地路径
    }
  }
}

请注意:

  • '/path/to/your/.venv/bin/python' 和 '/path/to/Notion_MCP_advanced' 需要替换为您的实际路径。您可以在激活虚拟环境后,在终端输入 'which python' (macOS/Linux) 或 'where python' (Windows) 来查找 Python 解释器路径。
  • 'claude_desktop_config.json' 的位置通常在用户配置目录下,具体位置请参考 Claude Desktop 的文档。

基本使用方法

配置完成后,启动 Claude Desktop。Claude 启动时会自动启动 Notion MCP 服务器。您可以通过以下自然语言指令与 Claude 交互,管理您的 Notion 待办事项:

  • 查看所有待办事项: 在 Claude 中输入类似 "Show all my todos" 或 "我的待办事项有哪些?" 的指令。
  • 添加新的待办事项: 例如 "Add a todo: 买菜" 或 "添加一个待办事项:整理项目文档,链接是 https://example.com/project"。
  • 完成待办事项: 例如 "Mark todo [任务ID] as complete"。您需要先通过查看待办事项获取任务 ID,然后使用 ID 完成任务,例如 "Mark todo xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx as complete"。

示例指令:

  • "Show all my todos"
  • "Add a todo: 完成年度报告"
  • "Add a todo: 学习MCP协议, with link: https://example.com/mcp-docs"
  • "Mark todo xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx as complete"

信息

分类

生产力应用