@node2flow/notion-mcp 1.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/dist/worker.js ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Cloudflare Worker entry — Stateless Streamable HTTP MCP
3
+ *
4
+ * Each request creates a new transport + server (CF Workers can't share memory between isolates).
5
+ */
6
+ import { WebStandardStreamableHTTPServerTransport, } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
7
+ import { createServer } from './server.js';
8
+ import { TOOLS } from './tools.js';
9
+ function corsHeaders() {
10
+ return {
11
+ 'Access-Control-Allow-Origin': '*',
12
+ 'Access-Control-Allow-Methods': 'GET, POST, DELETE, OPTIONS',
13
+ 'Access-Control-Allow-Headers': 'Content-Type, mcp-session-id, Accept, mcp-protocol-version',
14
+ 'Access-Control-Expose-Headers': 'mcp-session-id',
15
+ };
16
+ }
17
+ function addCors(response) {
18
+ const headers = new Headers(response.headers);
19
+ for (const [key, value] of Object.entries(corsHeaders())) {
20
+ headers.set(key, value);
21
+ }
22
+ return new Response(response.body, {
23
+ status: response.status,
24
+ statusText: response.statusText,
25
+ headers,
26
+ });
27
+ }
28
+ export default {
29
+ async fetch(request) {
30
+ const url = new URL(request.url);
31
+ // CORS preflight
32
+ if (request.method === 'OPTIONS') {
33
+ return new Response(null, { status: 204, headers: corsHeaders() });
34
+ }
35
+ // Health check
36
+ if (url.pathname === '/' && request.method === 'GET') {
37
+ return addCors(Response.json({
38
+ name: 'notion-mcp',
39
+ version: '1.0.0',
40
+ status: 'ok',
41
+ tools: TOOLS.length,
42
+ transport: 'streamable-http',
43
+ endpoints: { mcp: '/mcp' },
44
+ }));
45
+ }
46
+ // Only /mcp endpoint
47
+ if (url.pathname !== '/mcp') {
48
+ return addCors(new Response('Not Found', { status: 404 }));
49
+ }
50
+ if (request.method !== 'POST') {
51
+ return addCors(Response.json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed. Use POST.' }, id: null }, { status: 405 }));
52
+ }
53
+ const apiKey = url.searchParams.get('NOTION_API_KEY') || '';
54
+ const config = apiKey ? { apiKey } : undefined;
55
+ try {
56
+ const transport = new WebStandardStreamableHTTPServerTransport({
57
+ sessionIdGenerator: undefined,
58
+ enableJsonResponse: true,
59
+ });
60
+ const server = createServer(config);
61
+ await server.connect(transport);
62
+ const response = await transport.handleRequest(request);
63
+ return addCors(response);
64
+ }
65
+ catch (error) {
66
+ return addCors(Response.json({ jsonrpc: '2.0', error: { code: -32603, message: error.message || 'Internal server error' }, id: null }, { status: 500 }));
67
+ }
68
+ },
69
+ };
70
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wCAAwC,GACzC,MAAM,+DAA+D,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,SAAS,WAAW;IAClB,OAAO;QACL,6BAA6B,EAAE,GAAG;QAClC,8BAA8B,EAAE,4BAA4B;QAC5D,8BAA8B,EAAE,4DAA4D;QAC5F,+BAA+B,EAAE,gBAAgB;KAClD,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,QAAkB;IACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;QACjC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAA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C;QACL,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/C,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,wCAAwC,CAAC;gBAC7D,kBAAkB,EAAE,SAAS;gBAC7B,kBAAkB,EAAE,IAAI;aACzB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACpC,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAEhC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAC1B,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,uBAAuB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EACxG,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@node2flow/notion-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Notion API — manage pages, blocks, databases, data sources, comments, and users",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "notion-mcp": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "LICENSE",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "start": "node dist/index.js",
18
+ "dev": "tsx src/index.ts",
19
+ "deploy": "wrangler deploy",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "notion",
25
+ "api",
26
+ "model-context-protocol",
27
+ "ai",
28
+ "claude",
29
+ "node2flow"
30
+ ],
31
+ "author": "Node2Flow",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/node2flow-th/notion-mcp-community"
36
+ },
37
+ "engines": {
38
+ "node": ">=18"
39
+ },
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.26.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.0.0",
45
+ "tsx": "^4.19.0",
46
+ "typescript": "^5.7.0",
47
+ "wrangler": "^4.0.0"
48
+ }
49
+ }