Skip to main content
Glama

Notion MCP Server

by HariFatherKR

Notion API 服务器

参考视频

关于如何使用 Notion MCP 的视频

为了方便使用 Notion API,自定义服务器。它使用 Express.js 实现,并将 Notion API 的各种功能作为 REST API 公开。

如何安装

  1. 安装所需的软件包:
npm install express cors @notionhq/client swagger-jsdoc swagger-ui-express
  1. 运行服务器:
node server.js
  1. 服务器在http://localhost:3000运行。

如何设置

  1. 在 server.js 文件中的NOTION_TOKEN变量中设置 Notion API 令牌:
const NOTION_TOKEN = '여기에_노션_API_토큰_입력';
  1. 如果需要,您可以通过修改 PORT 变量在不同的端口上运行它。

API 功能

搜索 API

  • POST /api/search :搜索 Notion 工作区内的页面和数据库。

数据库 API

  • POST /api/databases :创建数据库
  • GET /api/databases/:id :查询数据库
  • PATCH /api/databases/:id : 更新数据库
  • POST /api/databases/:id/query :数据库查询

页面 API

  • POST /api/pages :创建页面
  • GET /api/pages/:id :查看页面信息
  • PATCH /api/pages/:id : 更新页面
  • GET /api/pages/:page_id/properties/:property_id :查看页面属性

块 API

  • GET /api/blocks/:id : 区块查询
  • GET /api/blocks/:id/children :查看区块内容
  • PATCH /api/blocks/:id : 更新区块
  • PATCH /api/blocks/:id/children : 添加块内容
  • DELETE /api/blocks/:id :删除块

用户 API

  • GET /api/users :查看用户列表
  • GET /api/users/:id :用户搜索
  • GET /api/users/me :查看自己的用户信息

评论API

  • POST /api/comments :创建评论
  • GET /api/comments?block_id=... : 查看评论

光标 MCP 集成

  1. 将以下设置添加到.cursor/mcp.json文件:
{ "mcpServers": { "customApi": { "url": "http://localhost:3000", "toolNameStrategy": "url-path-segments" } } }
  1. 您可以在服务器运行时使用 Cursor 中的 MCP 函数访问 Notion API。

使用示例

示例搜索请求

// 페이지 검색 fetch('http://localhost:3000/api/search', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ filter: { value: "page", property: "object" } }) }) .then(response => response.json()) .then(data => console.log(data));

页面创建示例

// 새 페이지 생성 fetch('http://localhost:3000/api/pages', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ parent: { page_id: "페이지_ID" }, properties: { title: { title: [ { text: { content: "새 페이지 제목" } } ] } } }) }) .then(response => response.json()) .then(data => console.log(data));

创建数据库的示例

// 데이터베이스 생성 fetch('http://localhost:3000/api/databases', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ parent: { type: "page_id", page_id: "페이지_ID" }, title: [ { text: { content: "테스트 데이터베이스" } } ], properties: { "이름": { "title": {}, "description": "제목 항목" }, "상태": { "description": "작업 상태", "select": { "options": [ { "name": "진행 중", "color": "blue" }, { "name": "완료", "color": "green" } ] } } } }) }) .then(response => response.json()) .then(data => console.log(data));

API 文档

运行服务器时,可以在以下 URL 上获取 API 文档:

-
security - not tested
F
license - not found
-
quality - not tested

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.

为 Notion 提供 REST API 接口的自定义服务器,允许通过 Cursor 的 MCP 功能轻松访问 Notion 的功能。

  1. 参考视频
    1. 如何安装
      1. 如何设置
        1. API 功能
          1. 搜索 API
          2. 数据库 API
          3. 页面 API
          4. 块 API
          5. 用户 API
          6. 评论API
        2. 光标 MCP 集成
          1. 使用示例
            1. 示例搜索请求
            2. 页面创建示例
            3. 创建数据库的示例
          2. API 文档

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              MCP Server for the Notion API, enabling Claude to interact with Notion workspaces.
              Last updated -
              18
              1,230
              699
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              Enables 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 -
              41
              17
              TypeScript
            • A
              security
              A
              license
              A
              quality
              Notion MCP Server is a MCP server implementation that enables AI assistants to interact with Notion's API.
              Last updated -
              13
              194
              91
              TypeScript
              MIT License
            • 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
              8,017
              2,292
              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/HariFatherKR/notion_mcp_server'

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