Skip to main content
Glama

Notion API 服务器

参考视频

关于如何使用 Notion MCP 的视频

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

Related MCP server: SystemPrompt MCP Notion Server

如何安装

  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

Latest Blog Posts

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