Notion MCP Server 使用说明

项目简介

Notion MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器实现,它将 Notion 知识库的功能通过工具的形式暴露给 LLM 客户端。借助此服务器,LLM 可以查询 Notion 页面内容、创建数据库条目、更新页面属性等,从而实现与 Notion 的深度集成,扩展 LLM 的知识获取和操作能力。

主要功能点

  • 查询 Notion 页面和数据库:允许 LLM 检索 Notion 中页面和数据库的信息,作为上下文输入。
  • 创建、更新 Notion 内容:支持 LLM 在 Notion 中创建新的���据库条目、更新页面和数据库的属性,实现内容管理自动化。
  • 基于工具的功能调用:通过 MCP 协议的标准 'CallToolRequest' 调用预定义的 Notion 工具,例如检索 Block、添加子 Block、更新 Page 属性等。
  • 标准 MCP 服务器:遵循 MCP 协议规范,易于与任何兼容 MCP 协议的 LLM 客户端集成。

安装步骤

  1. 克隆仓库

    git clone https://github.com/arre-ankit/notion-mcp-server.git
    cd notion-mcp-server
  2. 安装依赖 确保已安装 Node.js 和 npm,然后运行:

    npm install
  3. 构建项目

    npm run build

服务器配置

为了让 MCP 客户端(例如 Claude)连接到 Notion MCP Server,您需要配置客户端的 MCP 服务器设置。以下是一个 'claude_desktop_config.json' 文件的配置示例,您需要根据实际情况进行调整:

{
  "mcpServers": {
    "notion-mcp-server": {
      "command": "node",
      "args": [
        "path/to/dist/index.js"  //  请替换为构建后 index.js 文件的实际路径
      ],
      "env": {
        "NOTION_API_TOKEN": "YOUR_NOTION_INTEGRATION_TOKEN" // 请替换为您的 Notion Integration Token
      }
    }
  }
}

配置参数说明:

  • '"notion-mcp-server"': 服务器名称,可以自定义。
  • '"command": "node"': 启动服务器的命令,这里使用 Node.js 运行。
  • '"args": ["path/to/dist/index.js"]': 命令参数,指定构建后的 'index.js' 文件路径。请务必将 '"path/to/dist/index.js"' 替换为实际的 'index.js' 文件路径,通常在项目根目录下的 'dist' 文件夹中。
  • '"env": { "NOTION_API_TOKEN": "YOUR_NOTION_INTEGRATION_TOKEN" }': 环境变量配置,'NOTION_API_TOKEN' 用于存储您的 Notion Integration Token。请将 '"YOUR_NOTION_INTEGRATION_TOKEN"' 替换为您在 Notion 官网创建的 Integration 的 Token。

获取 Notion Integration Token 步骤:

  1. 访问 https://www.notion.so/my-integrations
  2. 点击 "New integration" 创建一个新的 Integration。
  3. 命名 Integration (例如 "MCP Server")。
  4. 选择 "Read" 和 "Write" 权限,至少需要 "Pages" 的读写权限才能使用所有工具。
  5. 复制生成的 "Integration Token"。

基本使用方法

  1. 启动 MCP 服务器:MCP 客户端(如 Claude)会根据您在 'claude_desktop_config.json' 中配置的命令和参数自动启动 Notion MCP Server。

  2. 在 LLM 客户端中使用工具

    • 在支持 MCP 协议的 LLM 客户端中,您可以像调用其他工具一样使用 Notion MCP Server 提供的工具。
    • 例如,您可以指示 LLM “查询 Notion 页面 [页面链接] 的内容”,LLM 客户端会解析您的指令,识别需要调用的工具和参数,并向 Notion MCP Server 发送 'CallToolRequest'。
    • 服务器会执行相应的 Notion API 操作,并将结果返回给 LLM 客户端。

示例 Prompt:

请查询这个 Notion 页面中的内容:https://www.notion.so/your-page-link

或者

在 Notion 页面 https://www.notion.so/your-database-page 创建一个新的数据库条目,标题为 "待办事项",内容为 "学习 MCP 协议"。

注意: 您需要在 Prompt 中提供 Notion 页面或数据库的链接或 ID,以便服务器能够正确操作您的 Notion 内容。具体可使用的工具名称和参数定义请参考 'src/index.ts' 文件中 'Tool' 类型的定义。

信息

分类

生产力应用