8000 chore: add agent for testing Notion MCP server · Ompragash/adk-python@821f751 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 821f751

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: add agent for testing Notion MCP server
PiperOrigin-RevId: 766325293
1 parent 94c0aca commit 821f751

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Notion MCP Agent
2+
3+
This is an agent that is using Notion MCP tool to call Notion API. And it demonstrate how to pass in the Notion API key.
4+
5+
Follow below instruction to use it:
6+
7+
* Follow the installation instruction in below page to get an API key for Notion API:
8+
https://www.npmjs.com/package/@notionhq/notion-mcp-server
9+
10+
* Set the environment variable `NOTION_API_KEY` to the API key you obtained in the previous step.
11+
12+
```bash
13+
export NOTION_API_KEY=<your_notion_api_key>
14+
```
15+
16+
* Run the agent in ADK Web UI
17+
18+
* Send below queries:
19+
* What can you do for me ?
20+
* Seach `XXXX` in my pages.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an " 8000 ;AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from . import agent
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import json
16+
import os
17+
18+
from dotenv import load_dotenv
19+
from google.adk.agents.llm_agent import LlmAgent
20+
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
21+
from google.adk.tools.mcp_tool.mcp_toolset import StdioServerParameters
22+
23+
load_dotenv()
24+
25+
NOTION_API_KEY = os.getenv("NOTION_API_KEY")
26+
NOTION_HEADERS = json.dumps({
27+
"Authorization": f"Bearer {NOTION_API_KEY}",
28+
"Notion-Version": "2022-06-28",
29+
})
30+
31+
root_agent = LlmAgent(
32+
model="gemini-2.0-flash",
33+
name="notion_agent",
34+
instruction=(
35+
"You are my workspace assistant. "
36+
"Use the provided tools to read, search, comment on, "
37+
"or create Notion pages. Ask clarifying questions when unsure."
38+
),
39+
tools=[
40+
MCPToolset(
41+
connection_params=StdioServerParameters(
42+
command="npx",
43+
args=["-y", "@notionhq/notion-mcp-server"],
44+
env={"OPENAPI_MCP_HEADERS": NOTION_HEADERS},
45+
)
46+
)
47+
],
48+
)

0 commit comments

Comments
 (0)
0