Notion¶
Notion MCP 服务器将你的 ADK 智能体连接到 Notion,允许它在工作区中搜索、创建和管理页面、数据库等。这使你的智能体能够使用自然语言查询、创建和组织你的 Notion 工作区中的内容。
使用案例¶
-
搜索你的工作区:根据内容查找项目页面、会议记录或文档。
-
创建新内容:生成会议记录、项目计划或任务的新页面。
-
管理任务和数据库:更新任务状态、向数据库添加项目或更改属性。
-
组织你的工作区:移动页面、复制模板或向文档添加评论。
先决条件¶
- 通过访问你个人资料中的Notion 集成获取 Notion 集成令牌。有关更多详细信息,请参阅授权文档。
- 确保相关页面和数据库可以通过你的集成进行访问。访问Notion 集成 设置中的访问选项卡,然后通过选择要使用的页面来授予访问权限。
与智能体一起使用¶
from google.adk.agents import Agent
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
from mcp import StdioServerParameters
NOTION_TOKEN = "YOUR_NOTION_TOKEN"
root_agent = Agent(
model="gemini-2.5-pro",
name="notion_agent",
instruction="帮助用户从 Notion 获取信息",
tools=[
MCPToolset(
connection_params=StdioConnectionParams(
server_params = StdioServerParameters(
command="npx",
args=[
"-y",
"@notionhq/notion-mcp-server",
],
env={
"NOTION_TOKEN": NOTION_TOKEN,
}
),
timeout=30,
),
)
],
)
可用工具¶
| 工具 |
描述 |
|---|---|
notion-search |
在你的 Notion 工作区和连接的工具(如 Slack、Google Drive 和 Jira)中进行搜索。如果 AI 功能不可用,则回退到基本工作区搜索。 |
notion-fetch |
通过其 URL 从 Notion 页面或数据库检索内容 |
notion-create-pages |
创建具有指定属性和内容的一个或多个 Notion 页面。 |
notion-update-page |
更新 Notion 页面的属性或内容。 |
notion-move-pages |
将一个或多个 Notion 页面或数据库移动到新的父级。 |
notion-duplicate-page |
在你的工作区中复制 Notion 页面。此操作是异步完成的。 |
notion-create-database |
创建具有指定属性的新 Notion 数据库、初始数据源和初始视图。 |
notion-update-database |
更新 Notion 数据源的属性、名称、描述或其他属性。 |
notion-create-comment |
向页面添加评论 |
notion-get-comments |
列出特定页面上的所有评论,包括主题讨论。 |
notion-get-teams |
检索当前工作区中的团队(团队空间)列表。 |
notion-get-users |
列出工作区中的所有用户及其详细信息。 |
notion-get-user |
按 ID 检索你的用户信息 |
notion-get-self |
检索有关你自己的机器人用户和你连接到的 Notion 工作区的信息。 |