mcp-server-notion 是一个 MCP 服务器,借助 Notion API 可在 Notion 数据库中搜索文章,并获取文章内容。它以 Notion 作为内容源,让您能通过编程方式便捷地获取所需文章信息。
您需要在环境变量中配置 Notion API 令牌,示例如下:
NOTION_API_TOKEN=your_notion_integration_token
notion_search该工具可用于在 Notion 数据库中搜索文章,支持传入搜索关键词和结果最大数量。示例代码如下:
# 假设这里有调用 notion_search 的代码
# 例如:
# result = notion_search(query="example_query", limit=10)
# 这里只是示例,实际代码需根据具体实现编写
notion_get_article此工具用于获取指定文章 ID 的文章内容,并可指定输出格式。示例代码如下:
# 假设这里有调用 notion_get_article 的代码
# 例如:
# article_content = notion_get_article(article_id="example_id", format="json")
# 这里只是示例,实际代码需根据具体实现编写
您可以根据实际需求组合使用这两个工具,例如先搜索文章,再获取搜索结果中某篇文章的详细内容。示例代码如下:
# 先搜索文章
search_result = notion_search(query="advanced_query", limit=5)
# 假设搜索结果中的第一篇文章是我们想要的
first_article_id = search_result[0]['id']
# 获取该文章的详细内容
article_content = notion_get_article(article_id=first_article_id, format="markdown")
notion_search| 参数 | 详情 |
|---|---|
query |
搜索关键词,用于指定搜索的内容 |
limit |
结果的最大数量,限制搜索结果的条数 |
notion_get_article| 参数 | 详情 |
|---|---|
article_id |
要获取的文章 ID,用于指定具体的文章 |
format |
输出格式,支持 json、markdown、text 三种格式 |