Notion集成服务器

一个提供与Notion无缝集成的MCP服务器,允许AI助手如Claude读写Notion页面、管理数据库等。

  • by razibra
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 razibra/notion-mcp-server

使用说明

MCP服务器概念

一个模型上下文协议(MCP)服务器,提供与Notion的无缝集成,允许像Claude这样的AI助手读写Notion页面、管理数据库等。

特性

  • 📄 页面管理:创建、读取、更新和删除Notion页面
  • 📊 数据库操作:查询和操作Notion数据库
  • 🔍 搜索:在您的Notion工作区中搜索
  • ✏️ 富文本支持:处理格式化文本、标题、列表等
  • 🔗 区块管理:添加和修改各种块类型
  • 🏷️ 属性支持:适用于所有Notion属性类型

安装

先决条件

快速开始

  1. 克隆存储库:
git clone https://github.com/yourusername/notion-mcp-server.git
cd notion-mcp-server
  1. 安装依赖项:
npm install
  1. 设置环境变量:
cp .env.example .env
# Edit .env and add your Notion API key
  1. 构建项目:
npm run build
  1. 测试服务器:
npm test

配置

环境变量

创建一个 .env 文件包含以下内容:

# Required
NOTION_API_KEY=your_notion_integration_token

# Optional
NOTION_API_VERSION=2022-06-28
LOG_LEVEL=info

Claude桌面配置

添加到您的Claude桌面配置(%APPDATA%\Claude\claude_desktop_config.json 在Windows上):

{
  "mcpServers": {
    "notion": {
      "command": "node",
      "args": ["path/to/notion-mcp-server/dist/index.js"],
      "env": {
        "NOTION_API_KEY": "your_notion_integration_token"
      }
    }
  }
}

可用工具

页面操作

  • notion_create_page -创建新的Notion页面
  • notion_get_page -检索页面内容和属性
  • notion_update_page -更新页面属性或内容
  • notion_delete_page -删除页面(移至垃圾箱)

数据库操作

  • notion_query_database -使用筛选器和排序查询数据库
  • notion_create_database_item -向数据库添加新项目
  • notion_update_database_item -更新数据库项属性

区块操作

  • notion_append_blocks -向页面添加块
  • notion_get_blocks -获取页面或块的子块
  • notion_update_block -更新现有块内容

搜索

  • notion_search -在工作区中搜索页面和数据库

使用示例

创建页面

Use notion_create_page to create a new page titled "Meeting Notes" in the workspace

查询数据库

Use notion_query_database to find all tasks with status "In Progress" from database [database_id]

搜索工作区

Use notion_search to find all pages containing "quarterly report"

发展

项目结构

notion-mcp-server/
├── src/
│   ├── index.ts           # Main MCP server
│   ├── notion-client.ts   # Notion API client wrapper
│   ├── tools/            # Individual tool implementations
│   │   ├── pages.ts
│   │   ├── databases.ts
│   │   ├── blocks.ts
│   │   └── search.ts
│   └── types/            # TypeScript types
├── test/                 # Test files
├── docs/                 # Documentation
└── examples/            # Usage examples

在发展中奔跑

npm run dev

代码的风格

该项目使用ESLint和Prettier。提交前运行:

npm run lint
npm run format

概念设置

  1. 首选 notion.so/my集成
  2. 点击“新建集成”
  3. 为其命名并选择功能
  4. 复制集成令牌
  5. 通过集成共享您的Notion页面/数据库

安全

  • 永远不要提交您的Notion API密钥
  • 对敏感数据使用环境变量
  • 将集成权限限制在所需范围内
  • 定期旋转API键

贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

致谢

  • 专为配合使用而设计 克劳德 以及模型上下文协议
  • 使用官方 API通知

支持