Notion服务
启用语言模型通过标准化的工具与 Notion 工作区交互,以进行搜索、阅读、创建和更新页面及数据库。
服务介绍
Notion MCP 服务器
一个模型上下文协议(MCP)服务器,提供与 Notion 的无缝集成。该服务器通过标准化的工具使语言模型能够搜索、阅读、创建和更新您的 Notion 工作区中的页面和数据库。
🌟 主要功能
页面操作
- 🔍 搜索您的 Notion 工作区
- 📝 使用丰富的 Markdown 内容创建新页面
- 📖 以整洁的格式读取页面内容
- 🔄 更新现有页面
- 💬 添加和检索评论
- 🧱 块级操作(更新、删除)
增强的 Markdown 支持
- 多级标题 (H1-H3)
- 支持语言的代码块
- 具有复选框状态的交互式待办事项
- 支持多行的引用块
- 水平分隔线
- 带有说明的图片
- 嵌套的项目符号列表
数据库操作
- 创建和管理数据库
- 添加和更新数据库条目
- 使用过滤器和排序进行查询
- 支持多种属性类型:
- 标题、富文本、数字
- 单选、多选
- 日期、复选框
- 等等!
🚀 开始使用
前提条件
- Node.js (v16 或更高版本)
- Notion API 密钥
- MCP 兼容客户端(例如 Claude Desktop)
安装
- 克隆仓库:
git clone https://github.com/v-3/notion-server.git
cd notion-server
- 安装依赖项:
npm install
- 设置您的环境:
# Create .env file
echo "NOTION_API_KEY=your_notion_api_key_here" > .env
# Or export directly
export NOTION_API_KEY=your_notion_api_key_here
- 构建服务器:
npm run build
🔧 配置
Claude Desktop 设置
- 更新您的 Claude Desktop 配置 (
claude_desktop_config.json):
{
"mcpServers": {
"notion": {
"command": "node",
"args": ["/absolute/path/to/notion-server/build/index.js"],
"env": {
"NOTION_API_KEY": "your_notion_api_key_here"
}
}
}
}
- 重启 Claude Desktop 以应用更改
🛠️ 可用工具
页面操作
// Search pages
{
query: string // Search query
}
// Read page
{
pageId: string // ID of the page to read
}
// Create page
{
title?: string, // Page title
content?: string, // Page content in markdown
parentPageId: string // Parent page ID
properties?: object // For database items
}
// Update page
{
pageId: string, // Page ID to update
content: string, // New content
type?: string // Content type
}
数据库操作
// Create database
{
parentPageId: string,
title: string,
properties: object
}
// Query database
{
databaseId: string,
filter?: object,
sort?: object
}
🔐 设置 Notion 访问权限
创建集成
- 访问 Notion 集成
- 点击“新建集成”
- 配置权限:
- 内容:读取、更新、插入
- 评论:读取、创建
- 用户信息:读取
连接页面
- 打开您的 Notion 页面
- 点击“...”菜单 → “连接”
- 添加您的集成
- 如有必要,请对其他页面重复此步骤
📝 使用示例
创建页面
const result = await notion.create_page({
parentPageId: "page_id",
title: "My Page",
content: "# Welcome\nThis is a test page."
});
查询数据库
const result = await notion.query_database({
databaseId: "db_id",
filter: {
property: "Status",
select: {
equals: "In Progress"
}
}
});
🤝 贡献
欢迎贡献!请:
- 分叉仓库
- 创建功能分支
- 提交 Pull Request
📜 许可证
该项目根据 MIT 许可证许可 - 详情请参阅 LICENSE 文件。
🙏 致谢
该项目得到了 sweir1/notion-server 的显著改进,他们进行了以下更新:
- 增强了具有更多块类型的 Markdown 支持
- 全面的数据库操作
- 改进了错误处理和调试
- 更好的数据库条目属性处理
- 更干净的页面输出格式
要使用 sweir1 的版本,您可以克隆他们的仓库:
git clone https://github.com/sweir1/notion-server.git