@mcp-monorepo/notion-query 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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { createMcpServer } from '@mcp-monorepo/shared';
3
+ import { registerNotionQueryTool } from './tools/notion-query.js';
4
+ createMcpServer({
5
+ name: 'notion-query',
6
+ importMetaPath: import.meta.filename,
7
+ title: 'Notion Query MCP Server',
8
+ tools: [registerNotionQueryTool],
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,eAAe,CAAC;IACd,IAAI,EAAE,cAAc;IACpB,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ;IACpC,KAAK,EAAE,yBAAyB;IAChC,KAAK,EAAE,CAAC,uBAAuB,CAAC;CACjC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare const registerNotionQueryTool: (server: McpServer) => void;
3
+ //# sourceMappingURL=notion-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-query.d.ts","sourceRoot":"","sources":["../../src/tools/notion-query.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,eAAO,MAAM,uBAAuB,GAAI,QAAQ,SAAS,SAuFrD,CAAA"}
@@ -0,0 +1,83 @@
1
+ import { registerTool } from '@mcp-monorepo/shared';
2
+ import { z } from 'zod';
3
+ export const registerNotionQueryTool = (server) => registerTool(server, {
4
+ name: 'notion-query',
5
+ title: 'Query a Notion Data Source',
6
+ description: `Gets a list of pages from a data source, identified by its URL (e.g., "collection://<uuid>"). Supports filtering and sorting. The response is paginated; use 'start_cursor' for subsequent requests if 'next_cursor' is returned. Filters operate on properties and can be simple or compound (using "and"/"or"). Sorts operate on properties or timestamps. For performance, use 'filter_properties' to retrieve only necessary page properties. Refer to Notion API documentation for the exact filter and sort object structures.`,
7
+ inputSchema: {
8
+ data_source_url: z
9
+ .string()
10
+ .describe('The URL of the data source to query, e.g., "collection://f336d0bc-b841-465b-8045-024475c079dd".'),
11
+ filter: z
12
+ .any()
13
+ .optional()
14
+ .describe('A JSON filter object to apply. Example: {"property": "Done", "checkbox": {"equals": true}} or {"and": [...]}.'),
15
+ sorts: z
16
+ .array(z.any())
17
+ .optional()
18
+ .describe('An array of JSON sort objects. Example: [{"property": "Name", "direction": "ascending"}].'),
19
+ start_cursor: z.string().optional().describe('If provided, starts the query at the specified cursor.'),
20
+ page_size: z.number().optional().describe('The number of items to return (max 100).'),
21
+ filter_properties: z
22
+ .array(z.string())
23
+ .optional()
24
+ .describe('An array of property IDs or names to return. If not provided, all properties are returned.'),
25
+ },
26
+ outputSchema: {
27
+ results: z.array(z.any()).describe('An array of page objects matching the query.'),
28
+ next_cursor: z
29
+ .string()
30
+ .nullable()
31
+ .describe('The cursor for the next page of results, or null if there are no more results.'),
32
+ has_more: z.boolean().describe('Whether there are more results available.'),
33
+ },
34
+ isReadOnly: true,
35
+ async fetcher(args) {
36
+ const { data_source_url, filter, sorts, start_cursor, page_size, filter_properties } = args;
37
+ if (!data_source_url?.startsWith('collection://')) {
38
+ throw new Error('Invalid data_source_url format. Must start with "collection://".');
39
+ }
40
+ const dataSourceId = data_source_url.substring('collection://'.length);
41
+ const NOTION_API_KEY = process.env.NOTION_API_KEY;
42
+ if (!NOTION_API_KEY) {
43
+ throw new Error('NOTION_API_KEY environment variable is not set.');
44
+ }
45
+ const apiUrl = new URL(`https://api.notion.com/v1/data_sources/${dataSourceId}/query`);
46
+ if (filter_properties && filter_properties.length > 0) {
47
+ filter_properties.forEach((prop) => {
48
+ apiUrl.searchParams.append('filter_properties', prop);
49
+ });
50
+ }
51
+ const body = {};
52
+ if (filter)
53
+ body.filter = filter;
54
+ if (sorts)
55
+ body.sorts = sorts;
56
+ if (start_cursor)
57
+ body.start_cursor = start_cursor;
58
+ if (page_size)
59
+ body.page_size = page_size;
60
+ const response = await fetch(apiUrl.toString(), {
61
+ method: 'POST',
62
+ headers: {
63
+ Authorization: `Bearer ${NOTION_API_KEY}`,
64
+ 'Notion-Version': '2025-09-03',
65
+ 'Content-Type': 'application/json',
66
+ },
67
+ body: Object.keys(body).length > 0 ? JSON.stringify(body) : undefined,
68
+ });
69
+ if (!response.ok) {
70
+ const errorText = await response.text();
71
+ throw new Error(`Notion API request failed with status ${response.status}: ${errorText}`);
72
+ }
73
+ return (await response.json());
74
+ },
75
+ formatter(data) {
76
+ return {
77
+ results: data.results,
78
+ next_cursor: data.next_cursor,
79
+ has_more: data.has_more,
80
+ };
81
+ },
82
+ });
83
+ //# sourceMappingURL=notion-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion-query.js","sourceRoot":"","sources":["../../src/tools/notion-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAiB,EAAE,EAAE,CAC3D,YAAY,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,4BAA4B;IACnC,WAAW,EAAE,sgBAAsgB;IACnhB,WAAW,EAAE;QACX,eAAe,EAAE,CAAC;aACf,MAAM,EAAE;aACR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AAQ,CAAC,IAAI,EAAE,CAAA;YACvC,MAAM,IAAI,KAAK,CAAC,yCAAyC,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CAAA;QAC3F,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA0E,CAAA;IACzG,CAAC;IACD,SAAS,CAAC,IAAI;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@mcp-monorepo/notion-query",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "MCP server for querying Notion data sources.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "mcp-npm-server": "./dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc -b",
19
+ "dev": "tsc --watch",
20
+ "start": "node dist/index.js",
21
+ "test": "vitest run --passWithNoTests",
22
+ "test:watch": "vitest",
23
+ "test:coverage": "vitest run --coverage",
24
+ "typecheck": "tsc --noEmit",
25
+ "clean": "rimraf dist tsconfig.tsbuildinfo"
26
+ },
27
+ "dependencies": {
28
+ "@modelcontextprotocol/sdk": "^1.0.0",
29
+ "zod": "^3.25.76",
30
+ "@mcp-monorepo/shared": "*"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.14.1",
34
+ "typescript": "^5.8.3",
35
+ "vitest": "^3.2.4",
36
+ "rimraf": "^6.0.1"
37
+ }
38
+ }