本项目实现了一个 MCP 服务器 对接 Notion 接口,为相关应用提供支持。
本项目可助力您实现与 Notion 接口的对接,通过 MCP 服务器进行相关操作。
访问 https://www.notion.so/profile/integrations 创建一个新的 内部 集成,或选择一个现有的集成。
尽管我们限制了 Notion 接口暴露的范围(例如,您无法通过 MCP 删除数据库),但将数据暴露给 LLM 存在非零风险。注重安全的用户可能希望进一步配置集成的 功能。
例如,您可以创建一个只读集成令牌,仅授予“读取内容”访问权限(从“配置”选项卡):
将以下内容添加到您的 .cursor/mcp.json
或 claude_desktop_config.json
(MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
)
{
"mcpServers": {
"notionApi": {
"command": "npx",
"args": ["-y", "@notionhq/notion-mcp-server"],
"env": {
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2022-06-28\" }"
}
}
}
}
您也可以使用 Docker 运行 MCP 服务器。首先构建 Docker 镜像:
docker-compose build
然后将以下内容添加到您的 .cursor/mcp.json
或 claude_desktop_config.json
:
{
"mcpServers": {
"notionApi": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2022-06-28\"}",
"notion-mcp-server-notion-mcp-server"
]
}
}
}
别忘了用您的集成秘密令牌替换 ntn_****
。从集成配置选项卡中找到:
在 Notion 中 创建一个免费帐户并创建一些数据库。
echo "{
\"messages\": [
{
\"role\": \"user\",
\"content\": \"告诉我有关人工智能的内容。\"
}
],
\"model\": \"gpt-3.5-turbo\",
\"temperature\": 0.7
}" | curl -X POST http://localhost:1234/v1/chat/completions
import requests
url = "http://localhost:1234/v1/chat/completions"
headers = {
"Content-Type": "application/json",
}
data = {
"messages": [
{"role": "user", "content": "告诉我有关人工智能的内容。"}
],
"model": "gpt-3.5-turbo",
"temperature": 0.7
}
response = requests.post(url, json=data)
print(response.json())
npm install
npm test
npm run build
npm start
⚠️ 重要提示
确保您的 Notion 集成令牌具有适当的权限。
💡 使用建议
测试时使用较小的温度值以获得更确定的结果。