@notionhq/notion-mcp-server 1.9.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request_template.md +8 -0
- package/.github/workflows/ci.yml +42 -0
- package/README.md +133 -57
- package/bin/cli.mjs +108 -116
- package/package.json +6 -3
- package/scripts/notion-openapi.json +1699 -1399
- package/src/openapi-mcp-server/client/__tests__/http-client-upload.test.ts +4 -4
- package/src/openapi-mcp-server/client/__tests__/http-client.integration.test.ts +125 -16
- package/src/openapi-mcp-server/client/http-client.ts +8 -1
- package/src/openapi-mcp-server/mcp/__tests__/proxy.test.ts +6 -4
- package/src/openapi-mcp-server/mcp/proxy.ts +1 -1
- package/src/openapi-mcp-server/openapi/parser.ts +7 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [20.x, 22.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: "npm"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Run build
|
|
31
|
+
run: npm run build
|
|
32
|
+
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: npm test
|
|
35
|
+
|
|
36
|
+
- name: Check for uncommitted changes
|
|
37
|
+
run: |
|
|
38
|
+
if [ -n "$(git status --porcelain)" ]; then
|
|
39
|
+
echo "Error: Uncommitted changes detected after build"
|
|
40
|
+
git status --porcelain
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
package/README.md
CHANGED
|
@@ -1,55 +1,112 @@
|
|
|
1
1
|
# Notion MCP Server
|
|
2
2
|
|
|
3
|
-
> [!NOTE]
|
|
4
|
-
>
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
>
|
|
5
5
|
> We’ve introduced **Notion MCP**, a remote MCP server with the following improvements:
|
|
6
|
-
>
|
|
7
|
-
> -
|
|
8
|
-
>
|
|
9
|
-
>
|
|
10
|
-
|
|
6
|
+
>
|
|
7
|
+
> - Easy installation via standard OAuth. No need to fiddle with JSON or API tokens anymore.
|
|
8
|
+
> - Powerful tools tailored to AI agents, including editing pages in Markdown. These tools are designed with optimized token consumption in mind.
|
|
9
|
+
>
|
|
10
|
+
> Learn more and get started at [Notion MCP documentation](https://developers.notion.com/docs/mcp).
|
|
11
|
+
>
|
|
12
|
+
> We are prioritizing, and only providing active support for, **Notion MCP** (remote). As a result:
|
|
13
|
+
>
|
|
14
|
+
> - We may sunset this local MCP server repository in the future.
|
|
15
|
+
> - Issues and pull requests here are not actively monitored.
|
|
16
|
+
> - Please do not file issues relating to the remote MCP here; instead, contact Notion support.
|
|
11
17
|
|
|
12
18
|

|
|
13
19
|
|
|
14
|
-
This project implements an [MCP server](https://spec.modelcontextprotocol.io/) for the [Notion API](https://developers.notion.com/reference/intro).
|
|
20
|
+
This project implements an [MCP server](https://spec.modelcontextprotocol.io/) for the [Notion API](https://developers.notion.com/reference/intro).
|
|
15
21
|
|
|
16
22
|

|
|
17
23
|
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ⚠️ Version 2.0.0 breaking changes
|
|
27
|
+
|
|
28
|
+
**Version 2.0.0 migrates to the Notion API 2025-09-03** which introduces data sources as the primary abstraction for databases.
|
|
29
|
+
|
|
30
|
+
### What changed
|
|
31
|
+
|
|
32
|
+
**Removed tools (4):**
|
|
33
|
+
|
|
34
|
+
- `post-database-query` - replaced by `query-data-source`
|
|
35
|
+
- `retrieve-a-database` - replaced by `retrieve-a-data-source`
|
|
36
|
+
- `update-a-database` - replaced by `update-a-data-source`
|
|
37
|
+
- `create-a-database` - replaced by `create-a-data-source`
|
|
38
|
+
|
|
39
|
+
**New tools (6):**
|
|
40
|
+
|
|
41
|
+
- `query-data-source` - Query a data source (database) with filters and sorts
|
|
42
|
+
- `retrieve-a-data-source` - Get metadata and schema for a data source
|
|
43
|
+
- `update-a-data-source` - Update data source properties
|
|
44
|
+
- `create-a-data-source` - Create a new data source
|
|
45
|
+
- `list-data-source-templates` - List available templates in a data source
|
|
46
|
+
- `move-page` - Move a page to a different parent location
|
|
47
|
+
|
|
48
|
+
**Parameter changes:**
|
|
49
|
+
|
|
50
|
+
- All database operations now use `data_source_id` instead of `database_id`
|
|
51
|
+
- Search filter values changed from `["page", "database"]` to `["page", "data_source"]`
|
|
52
|
+
- Page creation now supports both `page_id` and `database_id` parents (for data sources)
|
|
53
|
+
|
|
54
|
+
### Do I need to migrate?
|
|
55
|
+
|
|
56
|
+
**No code changes required.** MCP tools are discovered automatically when the server starts. When you upgrade to v2.0.0, AI clients will automatically see the new tool names and parameters. The old database tools are no longer available.
|
|
57
|
+
|
|
58
|
+
If you have hardcoded tool names or prompts that reference the old database tools, update them to use the new data source tools:
|
|
59
|
+
|
|
60
|
+
| Old Tool (v1.x) | New Tool (v2.0) | Parameter Change |
|
|
61
|
+
| -------------- | --------------- | ---------------- |
|
|
62
|
+
| `post-database-query` | `query-data-source` | `database_id` → `data_source_id` |
|
|
63
|
+
| `retrieve-a-database` | `retrieve-a-data-source` | `database_id` → `data_source_id` |
|
|
64
|
+
| `update-a-database` | `update-a-data-source` | `database_id` → `data_source_id` |
|
|
65
|
+
| `create-a-database` | `create-a-data-source` | No change (uses `parent.page_id`) |
|
|
66
|
+
|
|
67
|
+
**Total tools now: 21** (was 19 in v1.x)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
18
71
|
### Installation
|
|
19
72
|
|
|
20
|
-
#### 1. Setting up
|
|
73
|
+
#### 1. Setting up integration in Notion
|
|
74
|
+
|
|
21
75
|
Go to [https://www.notion.so/profile/integrations](https://www.notion.so/profile/integrations) and create a new **internal** integration or select an existing one.
|
|
22
76
|
|
|
23
77
|

|
|
24
78
|
|
|
25
|
-
While we limit the scope of Notion API's exposed (for example, you will not be able to delete databases via MCP), there is a non-zero risk to workspace data by exposing it to LLMs. Security-conscious users may want to further configure the Integration's _Capabilities_.
|
|
79
|
+
While we limit the scope of Notion API's exposed (for example, you will not be able to delete databases via MCP), there is a non-zero risk to workspace data by exposing it to LLMs. Security-conscious users may want to further configure the Integration's _Capabilities_.
|
|
26
80
|
|
|
27
81
|
For example, you can create a read-only integration token by giving only "Read content" access from the "Configuration" tab:
|
|
28
82
|
|
|
29
83
|

|
|
30
84
|
|
|
31
|
-
#### 2. Connecting content to integration
|
|
85
|
+
#### 2. Connecting content to integration
|
|
86
|
+
|
|
32
87
|
Ensure relevant pages and databases are connected to your integration.
|
|
33
88
|
|
|
34
89
|
To do this, visit the **Access** tab in your internal integration settings. Edit access and select the pages you'd like to use.
|
|
90
|
+
|
|
35
91
|

|
|
36
92
|
|
|
37
93
|

|
|
38
94
|
|
|
39
|
-
Alternatively, you can grant page access individually. You'll need to visit the target page, and click on the 3 dots, and select "Connect to integration".
|
|
95
|
+
Alternatively, you can grant page access individually. You'll need to visit the target page, and click on the 3 dots, and select "Connect to integration".
|
|
40
96
|
|
|
41
97
|

|
|
42
98
|
|
|
43
|
-
#### 3. Adding MCP config to your client
|
|
99
|
+
#### 3. Adding MCP config to your client
|
|
44
100
|
|
|
45
|
-
##### Using npm
|
|
101
|
+
##### Using npm
|
|
46
102
|
|
|
47
|
-
|
|
103
|
+
###### Cursor & Claude
|
|
48
104
|
|
|
49
105
|
Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json` (MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`)
|
|
50
106
|
|
|
51
|
-
|
|
52
|
-
|
|
107
|
+
###### Option 1: Using NOTION_TOKEN (recommended)
|
|
108
|
+
|
|
109
|
+
```json
|
|
53
110
|
{
|
|
54
111
|
"mcpServers": {
|
|
55
112
|
"notionApi": {
|
|
@@ -63,22 +120,23 @@ Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json` (Ma
|
|
|
63
120
|
}
|
|
64
121
|
```
|
|
65
122
|
|
|
66
|
-
|
|
67
|
-
|
|
123
|
+
###### Option 2: Using OPENAPI_MCP_HEADERS (for advanced use cases)
|
|
124
|
+
|
|
125
|
+
```json
|
|
68
126
|
{
|
|
69
127
|
"mcpServers": {
|
|
70
128
|
"notionApi": {
|
|
71
129
|
"command": "npx",
|
|
72
130
|
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
73
131
|
"env": {
|
|
74
|
-
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"
|
|
132
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\" }"
|
|
75
133
|
}
|
|
76
134
|
}
|
|
77
135
|
}
|
|
78
136
|
}
|
|
79
137
|
```
|
|
80
138
|
|
|
81
|
-
|
|
139
|
+
###### Zed
|
|
82
140
|
|
|
83
141
|
Add the following to your `settings.json`
|
|
84
142
|
|
|
@@ -90,7 +148,7 @@ Add the following to your `settings.json`
|
|
|
90
148
|
"path": "npx",
|
|
91
149
|
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
92
150
|
"env": {
|
|
93
|
-
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"
|
|
151
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\" }"
|
|
94
152
|
}
|
|
95
153
|
},
|
|
96
154
|
"settings": {}
|
|
@@ -99,16 +157,17 @@ Add the following to your `settings.json`
|
|
|
99
157
|
}
|
|
100
158
|
```
|
|
101
159
|
|
|
102
|
-
##### Using Docker
|
|
160
|
+
##### Using Docker
|
|
103
161
|
|
|
104
162
|
There are two options for running the MCP server with Docker:
|
|
105
163
|
|
|
106
|
-
###### Option 1: Using the official Docker Hub image
|
|
164
|
+
###### Option 1: Using the official Docker Hub image
|
|
165
|
+
|
|
166
|
+
Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`
|
|
107
167
|
|
|
108
|
-
|
|
168
|
+
Using NOTION_TOKEN (recommended):
|
|
109
169
|
|
|
110
|
-
|
|
111
|
-
```javascript
|
|
170
|
+
```json
|
|
112
171
|
{
|
|
113
172
|
"mcpServers": {
|
|
114
173
|
"notionApi": {
|
|
@@ -128,8 +187,9 @@ Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`:
|
|
|
128
187
|
}
|
|
129
188
|
```
|
|
130
189
|
|
|
131
|
-
|
|
132
|
-
|
|
190
|
+
Using OPENAPI_MCP_HEADERS (for advanced use cases):
|
|
191
|
+
|
|
192
|
+
```json
|
|
133
193
|
{
|
|
134
194
|
"mcpServers": {
|
|
135
195
|
"notionApi": {
|
|
@@ -142,7 +202,7 @@ Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`:
|
|
|
142
202
|
"mcp/notion"
|
|
143
203
|
],
|
|
144
204
|
"env": {
|
|
145
|
-
"OPENAPI_MCP_HEADERS": "{\"Authorization\":\"Bearer ntn_****\",\"Notion-Version\":\"
|
|
205
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\":\"Bearer ntn_****\",\"Notion-Version\":\"2025-09-03\"}"
|
|
146
206
|
}
|
|
147
207
|
}
|
|
148
208
|
}
|
|
@@ -150,11 +210,12 @@ Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`:
|
|
|
150
210
|
```
|
|
151
211
|
|
|
152
212
|
This approach:
|
|
213
|
+
|
|
153
214
|
- Uses the official Docker Hub image
|
|
154
215
|
- Properly handles JSON escaping via environment variables
|
|
155
216
|
- Provides a more reliable configuration method
|
|
156
217
|
|
|
157
|
-
###### Option 2: Building the Docker image locally
|
|
218
|
+
###### Option 2: Building the Docker image locally
|
|
158
219
|
|
|
159
220
|
You can also build and run the Docker image locally. First, build the Docker image:
|
|
160
221
|
|
|
@@ -162,10 +223,11 @@ You can also build and run the Docker image locally. First, build the Docker ima
|
|
|
162
223
|
docker compose build
|
|
163
224
|
```
|
|
164
225
|
|
|
165
|
-
Then, add the following to your `.cursor/mcp.json` or `claude_desktop_config.json
|
|
226
|
+
Then, add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`
|
|
227
|
+
|
|
228
|
+
Using NOTION_TOKEN (recommended):
|
|
166
229
|
|
|
167
|
-
|
|
168
|
-
```javascript
|
|
230
|
+
```json
|
|
169
231
|
{
|
|
170
232
|
"mcpServers": {
|
|
171
233
|
"notionApi": {
|
|
@@ -183,8 +245,9 @@ Then, add the following to your `.cursor/mcp.json` or `claude_desktop_config.jso
|
|
|
183
245
|
}
|
|
184
246
|
```
|
|
185
247
|
|
|
186
|
-
|
|
187
|
-
|
|
248
|
+
Using OPENAPI_MCP_HEADERS (for advanced use cases):
|
|
249
|
+
|
|
250
|
+
```json
|
|
188
251
|
{
|
|
189
252
|
"mcpServers": {
|
|
190
253
|
"notionApi": {
|
|
@@ -194,7 +257,7 @@ Then, add the following to your `.cursor/mcp.json` or `claude_desktop_config.jso
|
|
|
194
257
|
"--rm",
|
|
195
258
|
"-i",
|
|
196
259
|
"-e",
|
|
197
|
-
"OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"
|
|
260
|
+
"OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\"}",
|
|
198
261
|
"notion-mcp-server"
|
|
199
262
|
]
|
|
200
263
|
}
|
|
@@ -206,11 +269,12 @@ Don't forget to replace `ntn_****` with your integration secret. Find it from yo
|
|
|
206
269
|
|
|
207
270
|

|
|
208
271
|
|
|
209
|
-
### Transport
|
|
272
|
+
### Transport options
|
|
210
273
|
|
|
211
274
|
The Notion MCP Server supports two transport modes:
|
|
212
275
|
|
|
213
|
-
#### STDIO
|
|
276
|
+
#### STDIO transport (default)
|
|
277
|
+
|
|
214
278
|
The default transport mode uses standard input/output for communication. This is the standard MCP transport used by most clients like Claude Desktop.
|
|
215
279
|
|
|
216
280
|
```bash
|
|
@@ -221,7 +285,8 @@ npx @notionhq/notion-mcp-server
|
|
|
221
285
|
npx @notionhq/notion-mcp-server --transport stdio
|
|
222
286
|
```
|
|
223
287
|
|
|
224
|
-
#### Streamable HTTP
|
|
288
|
+
#### Streamable HTTP transport
|
|
289
|
+
|
|
225
290
|
For web-based applications or clients that prefer HTTP communication, you can use the Streamable HTTP transport:
|
|
226
291
|
|
|
227
292
|
```bash
|
|
@@ -238,31 +303,38 @@ npx @notionhq/notion-mcp-server --transport http --auth-token "your-secret-token
|
|
|
238
303
|
When using Streamable HTTP transport, the server will be available at `http://0.0.0.0:<port>/mcp`.
|
|
239
304
|
|
|
240
305
|
##### Authentication
|
|
306
|
+
|
|
241
307
|
The Streamable HTTP transport requires bearer token authentication for security. You have three options:
|
|
242
308
|
|
|
243
|
-
|
|
309
|
+
###### Option 1: Auto-generated token (recommended for development)
|
|
310
|
+
|
|
244
311
|
```bash
|
|
245
312
|
npx @notionhq/notion-mcp-server --transport http
|
|
246
313
|
```
|
|
314
|
+
|
|
247
315
|
The server will generate a secure random token and display it in the console:
|
|
248
|
-
|
|
316
|
+
|
|
317
|
+
```text
|
|
249
318
|
Generated auth token: a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789ab
|
|
250
319
|
Use this token in the Authorization header: Bearer a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789ab
|
|
251
320
|
```
|
|
252
321
|
|
|
253
|
-
|
|
322
|
+
###### Option 2: Custom token via command line (recommended for production)
|
|
323
|
+
|
|
254
324
|
```bash
|
|
255
325
|
npx @notionhq/notion-mcp-server --transport http --auth-token "your-secret-token"
|
|
256
326
|
```
|
|
257
327
|
|
|
258
|
-
|
|
328
|
+
###### Option 3: Custom token via environment variable (recommended for production)
|
|
329
|
+
|
|
259
330
|
```bash
|
|
260
331
|
AUTH_TOKEN="your-secret-token" npx @notionhq/notion-mcp-server --transport http
|
|
261
332
|
```
|
|
262
333
|
|
|
263
334
|
The command line argument `--auth-token` takes precedence over the `AUTH_TOKEN` environment variable if both are provided.
|
|
264
335
|
|
|
265
|
-
##### Making HTTP
|
|
336
|
+
##### Making HTTP requests
|
|
337
|
+
|
|
266
338
|
All requests to the Streamable HTTP transport must include the bearer token in the Authorization header:
|
|
267
339
|
|
|
268
340
|
```bash
|
|
@@ -279,38 +351,42 @@ curl -H "Authorization: Bearer your-token-here" \
|
|
|
279
351
|
### Examples
|
|
280
352
|
|
|
281
353
|
1. Using the following instruction
|
|
282
|
-
|
|
354
|
+
|
|
355
|
+
```text
|
|
283
356
|
Comment "Hello MCP" on page "Getting started"
|
|
284
357
|
```
|
|
285
358
|
|
|
286
|
-
AI will correctly plan two API calls, `v1/search` and `v1/comments`, to achieve the task
|
|
359
|
+
AI will correctly plan two API calls, `v1/search` and `v1/comments`, to achieve the task
|
|
287
360
|
|
|
288
|
-
|
|
289
|
-
|
|
361
|
+
1. Similarly, the following instruction will result in a new page named "Notion MCP" added to parent page "Development"
|
|
362
|
+
|
|
363
|
+
```text
|
|
290
364
|
Add a page titled "Notion MCP" to page "Development"
|
|
291
365
|
```
|
|
292
366
|
|
|
293
|
-
|
|
294
|
-
|
|
367
|
+
1. You may also reference content ID directly
|
|
368
|
+
|
|
369
|
+
```text
|
|
295
370
|
Get the content of page 1a6b35e6e67f802fa7e1d27686f017f2
|
|
296
371
|
```
|
|
297
372
|
|
|
298
373
|
### Development
|
|
299
374
|
|
|
300
|
-
Build
|
|
375
|
+
#### Build & test
|
|
301
376
|
|
|
302
|
-
```
|
|
377
|
+
```bash
|
|
303
378
|
npm run build
|
|
379
|
+
npm test
|
|
304
380
|
```
|
|
305
381
|
|
|
306
|
-
Execute
|
|
382
|
+
#### Execute
|
|
307
383
|
|
|
308
|
-
```
|
|
384
|
+
```bash
|
|
309
385
|
npx -y --prefix /path/to/local/notion-mcp-server @notionhq/notion-mcp-server
|
|
310
386
|
```
|
|
311
387
|
|
|
312
|
-
Publish
|
|
388
|
+
#### Publish
|
|
313
389
|
|
|
314
|
-
```
|
|
390
|
+
```bash
|
|
315
391
|
npm publish --access public
|
|
316
392
|
```
|