Notion MCP
Access Notion via MCP (Model Context Protocol) with managed authentication.
Quick Start
CODEBLOCK0
Base URL
CODEBLOCK1
Replace {tool-name} with the MCP tool name (e.g., notion-search). The gateway proxies requests to mcp.notion.com and automatically injects your credentials.
Request Headers
MCP requests use the Mcp-Session-Id header for session management. If not specified, the gateway initializes a new session and returns the session ID in the Mcp-Session-Id response header. You can include this session ID in subsequent requests to reuse the same session.
Authentication
All requests require the Maton API key:
CODEBLOCK2
Environment Variable: Set your API key as MATON_API_KEY:
CODEBLOCK3
Getting Your API Key
- 1. Sign in or create an account at maton.ai
- Go to maton.ai/settings
- Copy your API key
Connection Management
Manage your Notion MCP connections at https://ctrl.maton.ai.
List Connections
CODEBLOCK4
Create Connection
CODEBLOCK5
Get Connection
CODEBLOCK6
Response:
CODEBLOCK7
Open the returned url in a browser to complete OAuth authorization.
Delete Connection
CODEBLOCK8
Specifying Connection
If you have multiple Notion connections (eg. OAuth2, MCP), you must specify which MCP connection to use with the Maton-Connection header:
CODEBLOCK9
IMPORTANT: If omitted, the gateway uses the default (oldest) active connection, which may fail if it's not an MCP connection.
MCP Reference
All MCP tools use POST method:
| Tool | Description | Schema |
|---|
| INLINECODE10 | Search workspace and connected services | schema |
| INLINECODE11 |
Retrieve content from pages/databases |
schema |
|
notion-create-pages | Create pages with properties and content |
schema |
|
notion-update-page | Update page properties and content |
schema |
|
notion-move-pages | Relocate pages to new parent |
schema |
|
notion-duplicate-page | Copy pages within workspace |
schema |
|
notion-create-database | Create databases with schema |
schema |
|
notion-update-data-source | Modify data source attributes |
schema |
|
notion-create-comment | Add comments to pages/blocks |
schema |
|
notion-get-comments | Retrieve page comments |
schema |
|
notion-get-teams | List workspace teams |
schema |
|
notion-get-users | List workspace users |
schema |
Search
Search for pages and databases:
CODEBLOCK10
Response:
CODEBLOCK11
Search for users:
CODEBLOCK12
With date filter:
CODEBLOCK13
Fetch Content
Fetch page by URL:
CODEBLOCK14
Response:
CODEBLOCK15
Fetch by UUID:
CODEBLOCK16
Fetch data source (collection):
CODEBLOCK17
Include discussions:
CODEBLOCK18
Create Pages
Create a simple page:
CODEBLOCK19
Response:
CODEBLOCK20
Create page under parent:
CODEBLOCK21
Create page in data source (database):
CODEBLOCK22
Update Page
Update properties:
CODEBLOCK23
Response:
CODEBLOCK24
Replace entire content:
CODEBLOCK25
Replace content range:
CODEBLOCK26
Insert content after:
CODEBLOCK27
Move Pages
Move to page:
CODEBLOCK28
Response:
CODEBLOCK29
Move to workspace:
CODEBLOCK30
Move to database:
CODEBLOCK31
Duplicate Page
CODEBLOCK32
Response:
CODEBLOCK33
Create Database
Create with SQL DDL schema:
CODEBLOCK34
Response:
CODEBLOCK35
Update Data Source
CODEBLOCK36
Response:
CODEBLOCK37
Get Comments
CODEBLOCK38
Response:
CODEBLOCK39
Create Comment
CODEBLOCK40
Response:
CODEBLOCK41
List Teams
CODEBLOCK42
Response:
CODEBLOCK43
List Users
CODEBLOCK44
Response:
CODEBLOCK45
Code Examples
JavaScript
CODEBLOCK46
Python
CODEBLOCK47
Property Types Reference
When creating or updating pages in databases:
| Property Type | Format |
|---|
| Title | INLINECODE22 |
| Text |
"Text Property": "Some text" |
| Number |
"Number Property": 42 |
| Checkbox |
"Checkbox Property": "__YES__" or
"__NO__" |
| Select |
"Select Property": "Option Name" |
| Multi-select |
"Multi Property": "Option1, Option2" |
| Date (start) |
"date:Date Property:start": "2024-12-25" |
| Date (end) |
"date:Date Property:end": "2024-12-31" |
| Date (is datetime) |
"date:Date Property:is_datetime": 1 |
| Place (name) |
"place:Location:name": "Office HQ" |
| Place (coordinates) |
"place:Location:latitude": 37.7749 |
Special naming: Properties named "id" or "url" must be prefixed with userDefined: (e.g., "userDefined:URL").
Error Handling
| Status | Meaning |
|---|
| 400 | Missing MCP connection or invalid tool name |
| 401 |
Invalid or missing Maton API key |
| 429 | Rate limited (10 req/sec per account) |
Troubleshooting: API Key Issues
- 1. Check that the
MATON_API_KEY environment variable is set:
CODEBLOCK48
- 2. Verify the API key is valid by listing connections:
CODEBLOCK49
Troubleshooting: Invalid App Name
- 1. Ensure your URL path starts with
notion. For example:
- - Correct: INLINECODE38
- Incorrect: INLINECODE39
Notes
- - All IDs are UUIDs (with or without hyphens)
- MCP tool responses wrap content in
{"content": [{"type": "text", "text": "..."}], "isError": false} format - The
text field contains JSON-stringified data that should be parsed - Use
notion-fetch to get page/database structure before creating or updating pages - For databases, fetch first to get the data source ID (
collection://... URL)
Resources
Notion MCP
通过托管身份验证,使用 MCP(模型上下文协议)访问 Notion。
快速开始
bash
python <
import urllib.request, os, json
data = json.dumps({query: 会议笔记, query_type: internal}).encode()
req = urllib.request.Request(https://gateway.maton.ai/notion/notion-search, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
基础 URL
https://gateway.maton.ai/notion/{工具名称}
将 {工具名称} 替换为 MCP 工具名称(例如 notion-search)。网关将请求代理到 mcp.notion.com,并自动注入您的凭据。
请求头
MCP 请求使用 Mcp-Session-Id 头进行会话管理。如果未指定,网关会初始化一个新会话,并在 Mcp-Session-Id 响应头中返回会话 ID。您可以在后续请求中包含此会话 ID 以复用同一会话。
身份验证
所有请求都需要 Maton API 密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的 API 密钥设置为 MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
获取您的 API 密钥
- 1. 在 maton.ai 登录或创建账户
- 前往 maton.ai/settings
- 复制您的 API 密钥
连接管理
在 https://ctrl.maton.ai 管理您的 Notion MCP 连接。
列出连接
bash
python <
import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=notion&method=MCP&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
创建连接
bash
python <
import urllib.request, os, json
data = json.dumps({app: notion, method: MCP}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
获取连接
bash
python <
import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: PENDING,
creation_time: 2025-12-08T07:20:53.488460Z,
url: https://connect.maton.ai/?session_token=...,
app: notion,
method: MCP,
metadata: {}
}
}
在浏览器中打开返回的 url 以完成 OAuth 授权。
删除连接
bash
python <
import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
指定连接
如果您有多个 Notion 连接(例如 OAuth2、MCP),必须使用 Maton-Connection 头指定要使用的 MCP 连接:
bash
python <
import urllib.request, os, json
data = json.dumps({query: 会议笔记, query_type: internal}).encode()
req = urllib.request.Request(https://gateway.maton.ai/notion/notion-search, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
重要提示:如果省略此头,网关将使用默认(最旧)的活动连接,如果该连接不是 MCP 连接,则可能失败。
MCP 参考
所有 MCP 工具均使用 POST 方法:
| 工具 | 描述 | 模式 |
|---|
| notion-search | 搜索工作区和已连接的服务 | schema |
| notion-fetch |
检索页面/数据库的内容 |
schema |
| notion-create-pages | 创建带有属性和内容的页面 |
schema |
| notion-update-page | 更新页面属性和内容 |
schema |
| notion-move-pages | 将页面移动到新的父级 |
schema |
| notion-duplicate-page | 在工作区内复制页面 |
schema |
| notion-create-database | 创建带有模式的数据库 |
schema |
| notion-update-data-source | 修改数据源属性 |
schema |
| notion-create-comment | 向页面/块添加评论 |
schema |
| notion-get-comments | 检索页面评论 |
schema |
| notion-get-teams | 列出工作区团队 |
schema |
| notion-get-users | 列出工作区用户 |
schema |
搜索
搜索页面和数据库:
bash
POST /notion/notion-search
Content-Type: application/json
{
query: 会议笔记,
query_type: internal
}
响应:
json
{
content: [
{
type: text,
text: {\results\:[{\id\:\30702dc5-9a3b-8106-b51b-ed6d1bfeeed4\,\title\:\会议总结报告\,\url\:\https://www.notion.so/30702dc59a3b8106b51bed6d1bfeeed4\,\type\:\page\,\highlight\:\会议材料\,\timestamp\:\2026-02-15T00:07:00.000Z\}],\type\:\workspace_search\}
}
],
isError: false
}
搜索用户:
bash
POST /notion/notion-search
Content-Type: application/json
{
query: john@example.com,
query_type: user
}
带日期筛选:
bash
POST /notion/notion-search
Content-Type: application/json
{
query: 季度报告,
query_type: internal,
filters: {
createddaterange: {
start_date: 2024-01-01,
end_date: 2025-01-01
}
}
}
获取内容
通过 URL 获取页面:
bash
POST /notion/notion-fetch
Content-Type: application/json
{
id: https://notion.so/workspace/Page-a1b2c3d4e5f67890
}
响应:
json
{
content: [
{
type: text,
text: {\metadata\:{\type\:\page\},\title\:\项目概览\,\url\:\https://www.notion.so/30702dc59a3b8106