Notion数据库查询与链接卡片服务

为Notion提供增强的数据库查询(支持过滤、排序和分页)和富链接卡片生成功能,弥补官方MCP的不足。

  • by Dev-Dipesh
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Dev-Dipesh/notion-query-mcp

使用说明

概念查询mcp

一个本地MCP服务器,填补了官方Notion MCP中的两个空白:

  1. 筛选/分页数据库查询 --官方的MCP无法使用过滤器或排序查询数据库
  2. 丰富的链接卡 --官方MCP不能创建带有元数据的书签块;它又回到了普通链接

设置

1.安装依赖项并构建

npm install
npm run build

2.设置您的Notion令牌

从获取您的令牌https://www.notion.so/my-integrations--创建集成并复制密钥。确保与集成共享您要访问的任何数据库或页面。

3.添加到克劳德桌面

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "notion-query": {
      "command": "node",
      "args": ["/absolute/path/to/notion-query-mcp/dist/index.js"],
      "env": {
        "NOTION_TOKEN": "ntn_xxxxx"
      }
    }
  }
}

保存后重新启动Claude Desktop。


工具: query_notion_database

使用可选的过滤器、排序和分页查询任何Notion数据库。返回扁平化的属性值(从Notion的嵌套格式中提取的纯文本)。

参数

参数 类型 必填 说明
database_id string yes 通知数据库ID(带或不带破折号)
filter object no 概念筛选器对象
sorts array no Notion对数组进行排序
page_size number no 每页结果数(默认值:100,最大值:100)
start_cursor string no 分页光标(next_cursor 根据之前的回复)

退货

{
  "results": [
    {
      "id": "page-id",
      "url": "https://notion.so/...",
      "properties": {
        "Name": "My Page",
        "Status": "In Progress",
        "Tags": ["design", "dev"]
      }
    }
  ],
  "has_more": false,
  "next_cursor": null
}

筛选器示例

单一物业:

{ "property": "Arc Space", "select": { "equals": "Development" } }

化合物:

{
  "and": [
    { "property": "Status", "status": { "equals": "Archived" } },
    { "property": "Arc Space", "select": { "equals": "Development" } }
  ]
}

按日期降序排序:

[{ "property": "Created", "direction": "descending" }]

工具: append_link_card

获取URL的Open Graph元数据,并将丰富的链接卡附加到Notion页面正文。生成一个图像块(如果OG图像可公开访问)以及一个带有标题、描述和域的标注块,所有这些都链接到原始URL。

官方的Notion MCP将书签块标记为 <unknown> (不受支持),并在创建时回退到纯段落链接。该工具通过获取元数据本身并组合本机Notion块来绕过这一点。

参数

参数 类型 必填 说明
page_id string yes 通知页面ID(带或不带破折号)
url string yes 从中获取OG元数据并链接到的URL

退货

{ "block_ids": ["block-id-1", "block-id-2"] }

写什么

[Image block — og:image, only if publicly reachable]

🔗  Title of the page          ← og:title or <title>
    Description of the page    ← og:description or <meta name="description">
    domain.com                 ← parsed from URL, linked