Notion MCP 服务器是一个用于与 Notion 进行交互的工具,它提供了丰富的功能,如页面管理、数据库交互等,方便用户对 Notion 数据进行操作。
运行以下命令安装所需的依赖项:
pip install python-dotenv requests
使用 Git 克隆此仓库:
git clone https://github.com/your-username/notion-mcp.git
cd notion-mcp
创建一个名为 config.env
的新文件,并添加以下内容:
NOTION_TOKEN=你的Notion令牌
PORT=指定的端口(默认为5000)
运行主脚本以启动 MCP 服务器:
python3 mcp_server.py
⚠️ 重要提示
- 确保你拥有有效的 Notion 令牌。
- 配置文件中的 PORT 可以根据需要进行调整。
- 确保服务器运行时网络连接正常。
- 定期检查依赖库的更新,以保持最佳性能和安全性。
- 确保你拥有正确的权限来执行这些操作。
- 遵守 Notion 的 API 使用政策和限制。
- 定期检查和更新依赖库以保持安全性和兼容性。
页面管理
数据库交互
用户操作
评论处理
批量操作
高级查询
事件监听
日志记录
POST /api/create_page
Content-Type: application/json
{
"parent": {
"database_id": "09d4db7b-xxxx-xxxx-xxxx-c86ab25ef5cf"
},
"properties": {
"Name": {
"title": [
{
"text": {
"content": "新页面标题"
}
}
]
}
},
"children": []
}
PUT /api/update_page?id=14f5d08c-xxxx-xxxx-xxxx-d9e6b534a7cd
Content-Type: application/json
{
"properties": {
"Name": {
"title": [
{
"text": {
"content": "更新后的页面标题"
}
}
]
}
},
"children": []
}
DELETE /api/delete_page?id=14f5d08c-xxxx-xxxx-xxxx-d9e6b534a7cd
POST /api/query_database?database_id=09d4db7b-xxxx-xxxx-xxxx-c86ab25ef5cf
Content-Type: application/json
{
"filter": {
"property": "Status",
"value": {
"status": {
"equals": "完成"
}
}
},
"sorts": [
{
"property": "创建时间",
"direction": "descending"
}
],
"start_cursor": "",
"page_size": 10
}
POST /api/create_database_item?database_id=09d4db7b-xxxx-xxxx-xxxx-c86ab25ef5cf
Content-Type: application/json
{
"properties": {
"Name": {
"title": [
{
"text": {
"content": "新数据库项"
}
}
]
},
"Status": {
"select": {
"name": "完成"
}
}
},
"children": []
}
GET /api/get_user_info
POST /api/create_comment
Content-Type: application/json
{
"parent": {
"page_id": "14f5d08c-xxxx-xxxx-xxxx-d9e6b534a7cd"
},
"properties": {},
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"rich_text": [
{
"type": "text",
"text": {
"content": "这是一个新评论。"
}
}
]
}
}
]
}
GET /api/get_comments?page_id=14f5d08c-xxxx-xxxx-xxxx-d9e6b534a7cd
由于原文档未明确高级用法相关代码示例,此处暂不提供。
本项目遵循 MIT 协议。请查阅 LICENSE
文件获取详细信息。
感谢使用我们的 MCP 服务器!如有任何问题,请随时联系支持团队。