@mieubrisse/notion-mcp-server 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/.devcontainer/devcontainer.json +4 -0
- package/.dockerignore +3 -0
- package/.github/pull_request_template.md +8 -0
- package/.github/workflows/ci.yml +42 -0
- package/Dockerfile +36 -0
- package/LICENSE +7 -0
- package/README.md +412 -0
- package/docker-compose.yml +6 -0
- package/docs/images/connections.png +0 -0
- package/docs/images/integration-access.png +0 -0
- package/docs/images/integrations-capabilities.png +0 -0
- package/docs/images/integrations-creation.png +0 -0
- package/docs/images/page-access-edit.png +0 -0
- package/package.json +63 -0
- package/scripts/build-cli.js +30 -0
- package/scripts/notion-openapi.json +2238 -0
- package/scripts/start-server.ts +243 -0
- package/src/init-server.ts +50 -0
- package/src/openapi-mcp-server/README.md +3 -0
- package/src/openapi-mcp-server/auth/index.ts +2 -0
- package/src/openapi-mcp-server/auth/template.ts +24 -0
- package/src/openapi-mcp-server/auth/types.ts +26 -0
- package/src/openapi-mcp-server/client/__tests__/http-client-upload.test.ts +205 -0
- package/src/openapi-mcp-server/client/__tests__/http-client.integration.test.ts +282 -0
- package/src/openapi-mcp-server/client/__tests__/http-client.test.ts +537 -0
- package/src/openapi-mcp-server/client/http-client.ts +198 -0
- package/src/openapi-mcp-server/client/polyfill-headers.ts +42 -0
- package/src/openapi-mcp-server/index.ts +3 -0
- package/src/openapi-mcp-server/mcp/__tests__/proxy.test.ts +479 -0
- package/src/openapi-mcp-server/mcp/proxy.ts +250 -0
- package/src/openapi-mcp-server/openapi/__tests__/file-upload.test.ts +100 -0
- package/src/openapi-mcp-server/openapi/__tests__/parser-multipart.test.ts +602 -0
- package/src/openapi-mcp-server/openapi/__tests__/parser.test.ts +1448 -0
- package/src/openapi-mcp-server/openapi/file-upload.ts +40 -0
- package/src/openapi-mcp-server/openapi/parser.ts +529 -0
- package/tsconfig.json +26 -0
package/.dockerignore
ADDED
|
@@ -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/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Use Node.js LTS as the base image
|
|
4
|
+
FROM node:20-slim AS builder
|
|
5
|
+
|
|
6
|
+
# Set working directory
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
|
|
9
|
+
# Copy package.json and package-lock.json
|
|
10
|
+
COPY package*.json ./
|
|
11
|
+
|
|
12
|
+
# Install dependencies
|
|
13
|
+
RUN --mount=type=cache,target=/root/.npm npm ci --ignore-scripts --omit-dev
|
|
14
|
+
|
|
15
|
+
# Copy source code
|
|
16
|
+
COPY . .
|
|
17
|
+
|
|
18
|
+
# Build the package
|
|
19
|
+
RUN --mount=type=cache,target=/root/.npm npm run build
|
|
20
|
+
|
|
21
|
+
# Install package globally
|
|
22
|
+
RUN --mount=type=cache,target=/root/.npm npm link
|
|
23
|
+
|
|
24
|
+
# Minimal image for runtime
|
|
25
|
+
FROM node:20-slim
|
|
26
|
+
|
|
27
|
+
# Copy built package from builder stage
|
|
28
|
+
COPY scripts/notion-openapi.json /usr/local/scripts/
|
|
29
|
+
COPY --from=builder /usr/local/lib/node_modules/@notionhq/notion-mcp-server /usr/local/lib/node_modules/@notionhq/notion-mcp-server
|
|
30
|
+
COPY --from=builder /usr/local/bin/notion-mcp-server /usr/local/bin/notion-mcp-server
|
|
31
|
+
|
|
32
|
+
# Set default environment variables
|
|
33
|
+
ENV OPENAPI_MCP_HEADERS="{}"
|
|
34
|
+
|
|
35
|
+
# Set entrypoint
|
|
36
|
+
ENTRYPOINT ["notion-mcp-server"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2025 Notion Labs, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
# Notion MCP Server
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
>
|
|
5
|
+
> We’ve introduced **Notion MCP**, a remote MCP server with the following improvements:
|
|
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.
|
|
17
|
+
|
|
18
|
+

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

|
|
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
|
+
|
|
71
|
+
### Installation
|
|
72
|
+
|
|
73
|
+
#### 1. Setting up integration in Notion
|
|
74
|
+
|
|
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.
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
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_.
|
|
80
|
+
|
|
81
|
+
For example, you can create a read-only integration token by giving only "Read content" access from the "Configuration" tab:
|
|
82
|
+
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
#### 2. Connecting content to integration
|
|
86
|
+
|
|
87
|
+
Ensure relevant pages and databases are connected to your integration.
|
|
88
|
+
|
|
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
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
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".
|
|
96
|
+
|
|
97
|
+

|
|
98
|
+
|
|
99
|
+
#### 3. Adding MCP config to your client
|
|
100
|
+
|
|
101
|
+
##### Using npm
|
|
102
|
+
|
|
103
|
+
###### Cursor & Claude
|
|
104
|
+
|
|
105
|
+
Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json` (MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`)
|
|
106
|
+
|
|
107
|
+
###### Option 1: Using NOTION_TOKEN (recommended)
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"mcpServers": {
|
|
112
|
+
"notionApi": {
|
|
113
|
+
"command": "npx",
|
|
114
|
+
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
115
|
+
"env": {
|
|
116
|
+
"NOTION_TOKEN": "ntn_****"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
###### Option 2: Using OPENAPI_MCP_HEADERS (for advanced use cases)
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"notionApi": {
|
|
129
|
+
"command": "npx",
|
|
130
|
+
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
131
|
+
"env": {
|
|
132
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\" }"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
###### Zed
|
|
140
|
+
|
|
141
|
+
Add the following to your `settings.json`
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"context_servers": {
|
|
146
|
+
"some-context-server": {
|
|
147
|
+
"command": {
|
|
148
|
+
"path": "npx",
|
|
149
|
+
"args": ["-y", "@notionhq/notion-mcp-server"],
|
|
150
|
+
"env": {
|
|
151
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\" }"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"settings": {}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
##### Using Docker
|
|
161
|
+
|
|
162
|
+
There are two options for running the MCP server with Docker:
|
|
163
|
+
|
|
164
|
+
###### Option 1: Using the official Docker Hub image
|
|
165
|
+
|
|
166
|
+
Add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`
|
|
167
|
+
|
|
168
|
+
Using NOTION_TOKEN (recommended):
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"mcpServers": {
|
|
173
|
+
"notionApi": {
|
|
174
|
+
"command": "docker",
|
|
175
|
+
"args": [
|
|
176
|
+
"run",
|
|
177
|
+
"--rm",
|
|
178
|
+
"-i",
|
|
179
|
+
"-e", "NOTION_TOKEN",
|
|
180
|
+
"mcp/notion"
|
|
181
|
+
],
|
|
182
|
+
"env": {
|
|
183
|
+
"NOTION_TOKEN": "ntn_****"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Using OPENAPI_MCP_HEADERS (for advanced use cases):
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"mcpServers": {
|
|
195
|
+
"notionApi": {
|
|
196
|
+
"command": "docker",
|
|
197
|
+
"args": [
|
|
198
|
+
"run",
|
|
199
|
+
"--rm",
|
|
200
|
+
"-i",
|
|
201
|
+
"-e", "OPENAPI_MCP_HEADERS",
|
|
202
|
+
"mcp/notion"
|
|
203
|
+
],
|
|
204
|
+
"env": {
|
|
205
|
+
"OPENAPI_MCP_HEADERS": "{\"Authorization\":\"Bearer ntn_****\",\"Notion-Version\":\"2025-09-03\"}"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
This approach:
|
|
213
|
+
|
|
214
|
+
- Uses the official Docker Hub image
|
|
215
|
+
- Properly handles JSON escaping via environment variables
|
|
216
|
+
- Provides a more reliable configuration method
|
|
217
|
+
|
|
218
|
+
###### Option 2: Building the Docker image locally
|
|
219
|
+
|
|
220
|
+
You can also build and run the Docker image locally. First, build the Docker image:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
docker compose build
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Then, add the following to your `.cursor/mcp.json` or `claude_desktop_config.json`
|
|
227
|
+
|
|
228
|
+
Using NOTION_TOKEN (recommended):
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"mcpServers": {
|
|
233
|
+
"notionApi": {
|
|
234
|
+
"command": "docker",
|
|
235
|
+
"args": [
|
|
236
|
+
"run",
|
|
237
|
+
"--rm",
|
|
238
|
+
"-i",
|
|
239
|
+
"-e",
|
|
240
|
+
"NOTION_TOKEN=ntn_****",
|
|
241
|
+
"notion-mcp-server"
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Using OPENAPI_MCP_HEADERS (for advanced use cases):
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"mcpServers": {
|
|
253
|
+
"notionApi": {
|
|
254
|
+
"command": "docker",
|
|
255
|
+
"args": [
|
|
256
|
+
"run",
|
|
257
|
+
"--rm",
|
|
258
|
+
"-i",
|
|
259
|
+
"-e",
|
|
260
|
+
"OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer ntn_****\", \"Notion-Version\": \"2025-09-03\"}",
|
|
261
|
+
"notion-mcp-server"
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Don't forget to replace `ntn_****` with your integration secret. Find it from your integration configuration tab:
|
|
269
|
+
|
|
270
|
+

|
|
271
|
+
|
|
272
|
+
### Transport options
|
|
273
|
+
|
|
274
|
+
The Notion MCP Server supports two transport modes:
|
|
275
|
+
|
|
276
|
+
#### STDIO transport (default)
|
|
277
|
+
|
|
278
|
+
The default transport mode uses standard input/output for communication. This is the standard MCP transport used by most clients like Claude Desktop.
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Run with default stdio transport
|
|
282
|
+
npx @notionhq/notion-mcp-server
|
|
283
|
+
|
|
284
|
+
# Or explicitly specify stdio
|
|
285
|
+
npx @notionhq/notion-mcp-server --transport stdio
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
#### Streamable HTTP transport
|
|
289
|
+
|
|
290
|
+
For web-based applications or clients that prefer HTTP communication, you can use the Streamable HTTP transport:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Run with Streamable HTTP transport on port 3000 (default)
|
|
294
|
+
npx @notionhq/notion-mcp-server --transport http
|
|
295
|
+
|
|
296
|
+
# Run on a custom port
|
|
297
|
+
npx @notionhq/notion-mcp-server --transport http --port 8080
|
|
298
|
+
|
|
299
|
+
# Run with a custom authentication token
|
|
300
|
+
npx @notionhq/notion-mcp-server --transport http --auth-token "your-secret-token"
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
When using Streamable HTTP transport, the server will be available at `http://0.0.0.0:<port>/mcp`.
|
|
304
|
+
|
|
305
|
+
##### Authentication
|
|
306
|
+
|
|
307
|
+
The Streamable HTTP transport requires bearer token authentication for security. You have three options:
|
|
308
|
+
|
|
309
|
+
###### Option 1: Auto-generated token (recommended for development)
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
npx @notionhq/notion-mcp-server --transport http
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The server will generate a secure random token and display it in the console:
|
|
316
|
+
|
|
317
|
+
```text
|
|
318
|
+
Generated auth token: a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789ab
|
|
319
|
+
Use this token in the Authorization header: Bearer a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789ab
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
###### Option 2: Custom token via command line (recommended for production)
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
npx @notionhq/notion-mcp-server --transport http --auth-token "your-secret-token"
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
###### Option 3: Custom token via environment variable (recommended for production)
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
AUTH_TOKEN="your-secret-token" npx @notionhq/notion-mcp-server --transport http
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
The command line argument `--auth-token` takes precedence over the `AUTH_TOKEN` environment variable if both are provided.
|
|
335
|
+
|
|
336
|
+
##### Making HTTP requests
|
|
337
|
+
|
|
338
|
+
All requests to the Streamable HTTP transport must include the bearer token in the Authorization header:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# Example request
|
|
342
|
+
curl -H "Authorization: Bearer your-token-here" \
|
|
343
|
+
-H "Content-Type: application/json" \
|
|
344
|
+
-H "mcp-session-id: your-session-id" \
|
|
345
|
+
-d '{"jsonrpc": "2.0", "method": "initialize", "params": {}, "id": 1}' \
|
|
346
|
+
http://localhost:3000/mcp
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**Note:** Make sure to set either the `NOTION_TOKEN` environment variable (recommended) or the `OPENAPI_MCP_HEADERS` environment variable with your Notion integration token when using either transport mode.
|
|
350
|
+
|
|
351
|
+
### Examples
|
|
352
|
+
|
|
353
|
+
1. Using the following instruction
|
|
354
|
+
|
|
355
|
+
```text
|
|
356
|
+
Comment "Hello MCP" on page "Getting started"
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
AI will correctly plan two API calls, `v1/search` and `v1/comments`, to achieve the task
|
|
360
|
+
|
|
361
|
+
1. Similarly, the following instruction will result in a new page named "Notion MCP" added to parent page "Development"
|
|
362
|
+
|
|
363
|
+
```text
|
|
364
|
+
Add a page titled "Notion MCP" to page "Development"
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
1. You may also reference content ID directly
|
|
368
|
+
|
|
369
|
+
```text
|
|
370
|
+
Get the content of page 1a6b35e6e67f802fa7e1d27686f017f2
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Development
|
|
374
|
+
|
|
375
|
+
#### Build & test
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
npm run build
|
|
379
|
+
npm test
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
#### Execute
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
npx -y --prefix /path/to/local/notion-mcp-server @notionhq/notion-mcp-server
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Testing changes locally in Cursor:
|
|
389
|
+
|
|
390
|
+
1. Run `npm link` command from repository root to create a machine-global symlink to the `notion-mcp-server` package.
|
|
391
|
+
2. Merge the configuration snippet below into Cursor's `mcp.json` (or other MCP client you want to test with).
|
|
392
|
+
3. (Cleanup) run `npm unlink` from repository root.
|
|
393
|
+
|
|
394
|
+
```json
|
|
395
|
+
{
|
|
396
|
+
"mcpServers": {
|
|
397
|
+
"notion-local-package": {
|
|
398
|
+
"command": "notion-mcp-server",
|
|
399
|
+
"env": {
|
|
400
|
+
"NOTION_TOKEN": "ntn_..."
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
#### Publish
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
npm login
|
|
411
|
+
npm publish --access public
|
|
412
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mieubrisse/notion-mcp-server",
|
|
3
|
+
"keywords": [
|
|
4
|
+
"notion",
|
|
5
|
+
"api",
|
|
6
|
+
"mcp",
|
|
7
|
+
"server"
|
|
8
|
+
],
|
|
9
|
+
"version": "2.0.0",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -build && node scripts/build-cli.js",
|
|
14
|
+
"dev": "tsx watch scripts/start-server.ts",
|
|
15
|
+
"test": "NODE_ENV=test vitest run",
|
|
16
|
+
"test:watch": "NODE_ENV=test vitest",
|
|
17
|
+
"test:coverage": "NODE_ENV=test vitest run --coverage"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"notion-mcp-server": "bin/cli.mjs"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
24
|
+
"axios": "^1.8.4",
|
|
25
|
+
"express": "^4.21.2",
|
|
26
|
+
"form-data": "^4.0.1",
|
|
27
|
+
"mustache": "^4.2.0",
|
|
28
|
+
"node-fetch": "^3.3.2",
|
|
29
|
+
"openapi-client-axios": "^7.5.5",
|
|
30
|
+
"openapi-schema-validator": "^12.1.3",
|
|
31
|
+
"openapi-types": "^12.1.3",
|
|
32
|
+
"which": "^5.0.0",
|
|
33
|
+
"yargs": "^17.7.2",
|
|
34
|
+
"zod": "3.24.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@anthropic-ai/sdk": "^0.33.1",
|
|
38
|
+
"@types/express": "^5.0.0",
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"@types/json-schema": "^7.0.15",
|
|
41
|
+
"@types/mustache": "^4.2.5",
|
|
42
|
+
"@types/node": "^20.17.16",
|
|
43
|
+
"@types/which": "^3.0.4",
|
|
44
|
+
"@vitest/coverage-v8": "3.1.1",
|
|
45
|
+
"esbuild": "^0.25.2",
|
|
46
|
+
"multer": "1.4.5-lts.1",
|
|
47
|
+
"openai": "^4.91.1",
|
|
48
|
+
"tsx": "^4.19.3",
|
|
49
|
+
"typescript": "^5.8.2",
|
|
50
|
+
"vitest": "^3.1.1"
|
|
51
|
+
},
|
|
52
|
+
"description": "A maintained fork of the official Notion MCP server",
|
|
53
|
+
"main": "index.js",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/mieubrisse/notion-mcp-server.git"
|
|
57
|
+
},
|
|
58
|
+
"author": "@notionhq",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/mieubrisse/notion-mcp-server/issues"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://github.com/mieubrisse/notion-mcp-server#readme"
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
import { chmod } from 'fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
async function build() {
|
|
9
|
+
await esbuild.build({
|
|
10
|
+
entryPoints: [join(__dirname, 'start-server.ts')],
|
|
11
|
+
bundle: true,
|
|
12
|
+
minify: true,
|
|
13
|
+
platform: 'node',
|
|
14
|
+
target: 'node18',
|
|
15
|
+
format: 'esm',
|
|
16
|
+
outfile: 'bin/cli.mjs',
|
|
17
|
+
banner: {
|
|
18
|
+
js: "#!/usr/bin/env node\nimport { createRequire } from 'module';const require = createRequire(import.meta.url);" // see https://github.com/evanw/esbuild/pull/2067
|
|
19
|
+
},
|
|
20
|
+
external: ['util'],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Make the output file executable
|
|
24
|
+
await chmod('./bin/cli.mjs', 0o755);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
build().catch((err) => {
|
|
28
|
+
console.error(err);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|