@atikk-co-jp/notion-mcp-server 0.8.1 → 0.9.1
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/README.ja.md +41 -38
- package/README.md +40 -38
- package/dist/src/converters/__tests__/page-to-markdown.test.js +103 -0
- package/dist/src/converters/page-to-markdown.d.ts +6 -3
- package/dist/src/converters/page-to-markdown.d.ts.map +1 -1
- package/dist/src/converters/page-to-markdown.js +12 -5
- package/dist/src/notion-client.d.ts +1 -2
- package/dist/src/notion-client.d.ts.map +1 -1
- package/dist/src/schemas/descriptions/fields.d.ts +3 -0
- package/dist/src/schemas/descriptions/fields.d.ts.map +1 -1
- package/dist/src/schemas/descriptions/fields.js +3 -0
- package/dist/src/tools/append-block-children.d.ts.map +1 -1
- package/dist/src/tools/append-block-children.js +6 -3
- package/dist/src/tools/append-blocks-simple.d.ts.map +1 -1
- package/dist/src/tools/append-blocks-simple.js +7 -3
- package/dist/src/tools/archive-database.d.ts.map +1 -1
- package/dist/src/tools/archive-database.js +6 -3
- package/dist/src/tools/archive-page.d.ts.map +1 -1
- package/dist/src/tools/archive-page.js +6 -3
- package/dist/src/tools/create-comment-simple.d.ts.map +1 -1
- package/dist/src/tools/create-comment-simple.js +6 -3
- package/dist/src/tools/create-comment.d.ts.map +1 -1
- package/dist/src/tools/create-comment.js +6 -3
- package/dist/src/tools/create-database.d.ts.map +1 -1
- package/dist/src/tools/create-database.js +8 -3
- package/dist/src/tools/create-page-simple.d.ts.map +1 -1
- package/dist/src/tools/create-page-simple.js +6 -2
- package/dist/src/tools/create-page.d.ts.map +1 -1
- package/dist/src/tools/create-page.js +7 -3
- package/dist/src/tools/delete-block.d.ts.map +1 -1
- package/dist/src/tools/delete-block.js +6 -3
- package/dist/src/tools/move-page.d.ts.map +1 -1
- package/dist/src/tools/move-page.js +7 -3
- package/dist/src/tools/query-data-source.d.ts.map +1 -1
- package/dist/src/tools/query-data-source.js +6 -3
- package/dist/src/tools/retrieve-data-source.js +5 -5
- package/dist/src/tools/retrieve-database.js +1 -1
- package/dist/src/tools/search.d.ts +1 -1
- package/dist/src/tools/search.d.ts.map +1 -1
- package/dist/src/tools/search.js +34 -2
- package/dist/src/tools/update-block-simple.d.ts.map +1 -1
- package/dist/src/tools/update-block-simple.js +5 -2
- package/dist/src/tools/update-block.d.ts.map +1 -1
- package/dist/src/tools/update-block.js +7 -3
- package/dist/src/tools/update-data-source.d.ts.map +1 -1
- package/dist/src/tools/update-data-source.js +6 -3
- package/dist/src/tools/update-database.d.ts.map +1 -1
- package/dist/src/tools/update-database.js +8 -3
- package/dist/src/tools/update-page.d.ts.map +1 -1
- package/dist/src/tools/update-page.js +8 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { parseInlineMarkdown } from '../converters/index.js';
|
|
3
3
|
import { F } from '../schemas/descriptions/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { formatSimpleResponse, handleError } from '../utils/index.js';
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
page_id: z.string().optional().describe(F.page_id),
|
|
7
7
|
block_id: z.string().optional().describe(F.block_id),
|
|
@@ -10,7 +10,7 @@ const inputSchema = {
|
|
|
10
10
|
};
|
|
11
11
|
export function registerCreateCommentSimple(server, notion) {
|
|
12
12
|
server.registerTool('create-comment-simple', {
|
|
13
|
-
description: 'Add a comment using Markdown. Simpler than create-comment.',
|
|
13
|
+
description: 'Add a comment using Markdown. Simpler than create-comment. Returns comment ID.',
|
|
14
14
|
inputSchema,
|
|
15
15
|
}, async ({ page_id, block_id, discussion_id, content }) => {
|
|
16
16
|
try {
|
|
@@ -42,7 +42,10 @@ export function registerCreateCommentSimple(server, notion) {
|
|
|
42
42
|
params.parent = { block_id };
|
|
43
43
|
}
|
|
44
44
|
const response = await notion.comments.create(params);
|
|
45
|
-
|
|
45
|
+
// Return minimal response (id only)
|
|
46
|
+
return formatSimpleResponse({
|
|
47
|
+
id: response.id,
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
catch (error) {
|
|
48
51
|
return handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-comment.d.ts","sourceRoot":"","sources":["../../../src/tools/create-comment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAYvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"create-comment.d.ts","sourceRoot":"","sources":["../../../src/tools/create-comment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAYvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2DnF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
page_id: z.string().optional().describe(F.page_id),
|
|
@@ -13,7 +13,7 @@ export function registerCreateComment(server, notion) {
|
|
|
13
13
|
description: 'Add a comment to a Notion page. Creates a new discussion or adds to an existing one. ' +
|
|
14
14
|
'Comments support rich text formatting (bold, italic, links, etc.). ' +
|
|
15
15
|
'Use discussion_id to reply to an existing comment thread. ' +
|
|
16
|
-
'Returns the created comment
|
|
16
|
+
'Returns the created comment ID.',
|
|
17
17
|
inputSchema,
|
|
18
18
|
}, async ({ page_id, block_id, discussion_id, rich_text }) => {
|
|
19
19
|
try {
|
|
@@ -44,7 +44,10 @@ export function registerCreateComment(server, notion) {
|
|
|
44
44
|
params.parent = { block_id };
|
|
45
45
|
}
|
|
46
46
|
const response = await notion.comments.create(params);
|
|
47
|
-
|
|
47
|
+
// Return minimal response (id only)
|
|
48
|
+
return formatSimpleResponse({
|
|
49
|
+
id: response.id,
|
|
50
|
+
});
|
|
48
51
|
}
|
|
49
52
|
catch (error) {
|
|
50
53
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-database.d.ts","sourceRoot":"","sources":["../../../src/tools/create-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAevD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"create-database.d.ts","sourceRoot":"","sources":["../../../src/tools/create-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAevD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAqCpF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
// Uses z.any() for title/icon/cover to reduce context size (~2,300 tokens saved)
|
|
6
6
|
const inputSchema = {
|
|
@@ -15,7 +15,8 @@ export function registerCreateDatabase(server, notion) {
|
|
|
15
15
|
server.registerTool('create-database', {
|
|
16
16
|
description: 'Create a new database as a subpage of an existing Notion page. ' +
|
|
17
17
|
'Requires a parent_page_id and properties object defining the database schema. ' +
|
|
18
|
-
'Each database must have exactly one title property.
|
|
18
|
+
'Each database must have exactly one title property. ' +
|
|
19
|
+
'Returns database ID and URL. (API version 2025-09-03)',
|
|
19
20
|
inputSchema,
|
|
20
21
|
}, async ({ parent_page_id, title, properties, icon, cover, is_inline }) => {
|
|
21
22
|
try {
|
|
@@ -29,7 +30,11 @@ export function registerCreateDatabase(server, notion) {
|
|
|
29
30
|
...(is_inline !== undefined && { is_inline }),
|
|
30
31
|
};
|
|
31
32
|
const response = await notion.databases.create(params);
|
|
32
|
-
|
|
33
|
+
// Return minimal response (id + url only)
|
|
34
|
+
return formatSimpleResponse({
|
|
35
|
+
id: response.id,
|
|
36
|
+
url: 'url' in response ? response.url : undefined,
|
|
37
|
+
});
|
|
33
38
|
}
|
|
34
39
|
catch (error) {
|
|
35
40
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-page-simple.d.ts","sourceRoot":"","sources":["../../../src/tools/create-page-simple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAIxE,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAiBzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"create-page-simple.d.ts","sourceRoot":"","sources":["../../../src/tools/create-page-simple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAIxE,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAiBzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA0EtF"}
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { markdownToBlocks } from '../converters/index.js';
|
|
3
3
|
import { isFullDataSource } from '../notion-client.js';
|
|
4
4
|
import { F } from '../schemas/descriptions/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
6
6
|
// Minimal schema for MCP
|
|
7
7
|
const inputSchema = {
|
|
8
8
|
data_source_id: z.string().describe(F.data_source_id),
|
|
@@ -56,7 +56,11 @@ export function registerCreatePageSimple(server, notion) {
|
|
|
56
56
|
...(children && { children }),
|
|
57
57
|
...(icon && { icon: { type: 'emoji', emoji: icon } }),
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
// Return minimal response (id + url only)
|
|
60
|
+
return formatSimpleResponse({
|
|
61
|
+
id: response.id,
|
|
62
|
+
url: 'url' in response ? response.url : undefined,
|
|
63
|
+
});
|
|
60
64
|
}
|
|
61
65
|
catch (error) {
|
|
62
66
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-page.d.ts","sourceRoot":"","sources":["../../../src/tools/create-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAoBvD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"create-page.d.ts","sourceRoot":"","sources":["../../../src/tools/create-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAoBvD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAkDhF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
data_source_id: z.string().describe(F.data_source_id),
|
|
@@ -13,7 +13,7 @@ export function registerCreatePage(server, notion) {
|
|
|
13
13
|
server.registerTool('create-page', {
|
|
14
14
|
description: 'Create a new page in a Notion data source. Requires a data_source_id and properties object. ' +
|
|
15
15
|
'Optionally include initial content blocks, icon, and cover image. ' +
|
|
16
|
-
'Returns the created page
|
|
16
|
+
'Returns the created page ID and URL. (API version 2025-09-03)',
|
|
17
17
|
inputSchema,
|
|
18
18
|
}, async ({ data_source_id, properties, children, icon, cover }) => {
|
|
19
19
|
try {
|
|
@@ -31,7 +31,11 @@ export function registerCreatePage(server, notion) {
|
|
|
31
31
|
params.cover = cover;
|
|
32
32
|
}
|
|
33
33
|
const response = await notion.pages.create(params);
|
|
34
|
-
|
|
34
|
+
// Return minimal response (id + url only)
|
|
35
|
+
return formatSimpleResponse({
|
|
36
|
+
id: response.id,
|
|
37
|
+
url: 'url' in response ? response.url : undefined,
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
catch (error) {
|
|
37
41
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-block.d.ts","sourceRoot":"","sources":["../../../src/tools/delete-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAQvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"delete-block.d.ts","sourceRoot":"","sources":["../../../src/tools/delete-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAQvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAsBjF"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleError } from '../utils/index.js';
|
|
4
4
|
const inputSchema = {
|
|
5
5
|
block_id: z.string().describe(F.block_id),
|
|
6
6
|
};
|
|
7
7
|
export function registerDeleteBlock(server, notion) {
|
|
8
8
|
server.registerTool('delete-block', {
|
|
9
9
|
description: 'Delete a block by its ID. The block will be archived (moved to trash). ' +
|
|
10
|
-
'Returns
|
|
10
|
+
'Returns deleted block ID.',
|
|
11
11
|
inputSchema,
|
|
12
12
|
}, async ({ block_id }) => {
|
|
13
13
|
try {
|
|
14
14
|
const response = await notion.blocks.delete({ block_id });
|
|
15
|
-
|
|
15
|
+
// Return minimal response (id only)
|
|
16
|
+
return formatSimpleResponse({
|
|
17
|
+
id: response.id,
|
|
18
|
+
});
|
|
16
19
|
}
|
|
17
20
|
catch (error) {
|
|
18
21
|
return handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-page.d.ts","sourceRoot":"","sources":["../../../src/tools/move-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAcvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"move-page.d.ts","sourceRoot":"","sources":["../../../src/tools/move-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAcvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2C9E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleError } from '../utils/index.js';
|
|
4
4
|
const inputSchema = {
|
|
5
5
|
page_id: z.string().describe(F.page_id),
|
|
6
6
|
parent: z
|
|
@@ -14,7 +14,7 @@ export function registerMovePage(server, notion) {
|
|
|
14
14
|
server.registerTool('move-page', {
|
|
15
15
|
description: 'Move a page to a new parent (page or data source). ' +
|
|
16
16
|
'Provide either page_id or data_source_id as the new parent. ' +
|
|
17
|
-
'(API version 2025-09-03)',
|
|
17
|
+
'Returns page ID and URL. (API version 2025-09-03)',
|
|
18
18
|
inputSchema,
|
|
19
19
|
}, async ({ page_id, parent }) => {
|
|
20
20
|
try {
|
|
@@ -36,7 +36,11 @@ export function registerMovePage(server, notion) {
|
|
|
36
36
|
page_id,
|
|
37
37
|
parent: parentParam,
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
// Return minimal response (id + url only)
|
|
40
|
+
return formatSimpleResponse({
|
|
41
|
+
id: response.id,
|
|
42
|
+
url: 'url' in response ? response.url : undefined,
|
|
43
|
+
});
|
|
40
44
|
}
|
|
41
45
|
catch (error) {
|
|
42
46
|
return handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-data-source.d.ts","sourceRoot":"","sources":["../../../src/tools/query-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"query-data-source.d.ts","sourceRoot":"","sources":["../../../src/tools/query-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAoBnE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAwCrF"}
|
|
@@ -11,15 +11,17 @@ const inputSchema = {
|
|
|
11
11
|
sorts: z.array(z.any()).optional().describe(F.sorts),
|
|
12
12
|
start_cursor: z.string().optional().describe(F.start_cursor),
|
|
13
13
|
page_size: z.number().optional().describe(F.page_size),
|
|
14
|
-
format: z.enum(['json', 'simple']).optional().describe(F.format),
|
|
14
|
+
format: z.enum(['json', 'simple']).optional().default('simple').describe(F.format),
|
|
15
|
+
fields: z.array(z.string()).optional().describe(F.fields),
|
|
15
16
|
};
|
|
16
17
|
export function registerQueryDataSource(server, notion) {
|
|
17
18
|
server.registerTool('query-data-source', {
|
|
18
19
|
description: 'Query a Notion data source with optional filters and sorts. Returns paginated results. ' +
|
|
19
20
|
"Use format='simple' (default) for human-readable output with reduced token usage. " +
|
|
21
|
+
'Use fields parameter to limit which properties are returned (simple format only). ' +
|
|
20
22
|
'(API version 2025-09-03)',
|
|
21
23
|
inputSchema,
|
|
22
|
-
}, async ({ data_source_id, filter, sorts, start_cursor, page_size, format }) => {
|
|
24
|
+
}, async ({ data_source_id, filter, sorts, start_cursor, page_size, format, fields }) => {
|
|
23
25
|
try {
|
|
24
26
|
const response = await notion.dataSources.query({
|
|
25
27
|
data_source_id,
|
|
@@ -31,9 +33,10 @@ export function registerQueryDataSource(server, notion) {
|
|
|
31
33
|
if (format === 'simple') {
|
|
32
34
|
// Filter to full pages and cast for pagesToSimple converter
|
|
33
35
|
const fullPages = response.results.filter(isFullPage);
|
|
34
|
-
const simplePages = pagesToSimple(fullPages);
|
|
36
|
+
const simplePages = pagesToSimple(fullPages, fields);
|
|
35
37
|
return formatSimplePaginatedResponse(simplePages, response.has_more, response.next_cursor);
|
|
36
38
|
}
|
|
39
|
+
// JSON format: full Notion API response
|
|
37
40
|
return formatPaginatedResponse(response.results, response.has_more, response.next_cursor);
|
|
38
41
|
}
|
|
39
42
|
catch (error) {
|
|
@@ -4,7 +4,7 @@ import { F } from '../schemas/descriptions/index.js';
|
|
|
4
4
|
import { formatResponse, formatSimpleResponse, handleError } from '../utils/index.js';
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
data_source_id: z.string().describe(F.data_source_id),
|
|
7
|
-
format: z.enum(['json', 'simple']).optional().describe(F.format),
|
|
7
|
+
format: z.enum(['json', 'simple']).optional().default('simple').describe(F.format),
|
|
8
8
|
};
|
|
9
9
|
export function registerRetrieveDataSource(server, notion) {
|
|
10
10
|
server.registerTool('retrieve-data-source', {
|
|
@@ -29,19 +29,19 @@ export function registerRetrieveDataSource(server, notion) {
|
|
|
29
29
|
id: prop.id,
|
|
30
30
|
type: prop.type,
|
|
31
31
|
};
|
|
32
|
-
// Include options for select/multi_select/status
|
|
32
|
+
// Include options for select/multi_select/status (names only for simple format)
|
|
33
33
|
const propAny = prop;
|
|
34
34
|
if (prop.type === 'select' && propAny.select) {
|
|
35
35
|
const selectProp = propAny.select;
|
|
36
|
-
simpleProp.options = selectProp.options;
|
|
36
|
+
simpleProp.options = selectProp.options?.map((o) => o.name);
|
|
37
37
|
}
|
|
38
38
|
else if (prop.type === 'multi_select' && propAny.multi_select) {
|
|
39
39
|
const multiSelectProp = propAny.multi_select;
|
|
40
|
-
simpleProp.options = multiSelectProp.options;
|
|
40
|
+
simpleProp.options = multiSelectProp.options?.map((o) => o.name);
|
|
41
41
|
}
|
|
42
42
|
else if (prop.type === 'status' && propAny.status) {
|
|
43
43
|
const statusProp = propAny.status;
|
|
44
|
-
simpleProp.options = statusProp.options;
|
|
44
|
+
simpleProp.options = statusProp.options?.map((o) => o.name);
|
|
45
45
|
}
|
|
46
46
|
simpleProperties[name] = simpleProp;
|
|
47
47
|
}
|
|
@@ -4,7 +4,7 @@ import { F } from '../schemas/descriptions/index.js';
|
|
|
4
4
|
import { formatResponse, formatSimpleResponse, handleError } from '../utils/index.js';
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
database_id: z.string().describe(F.database_id),
|
|
7
|
-
format: z.enum(['json', 'simple']).optional().describe(F.format),
|
|
7
|
+
format: z.enum(['json', 'simple']).optional().default('simple').describe(F.format),
|
|
8
8
|
};
|
|
9
9
|
export function registerRetrieveDatabase(server, notion) {
|
|
10
10
|
server.registerTool('retrieve-database', {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type NotionClient } from '../notion-client.js';
|
|
3
3
|
export declare function registerSearch(server: McpServer, notion: NotionClient): void;
|
|
4
4
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,EAAc,KAAK,YAAY,EAA2B,MAAM,qBAAqB,CAAA;AAmC5F,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAyF5E"}
|
package/dist/src/tools/search.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { pagesToSimple } from '../converters/index.js';
|
|
3
|
+
import { isFullPage } from '../notion-client.js';
|
|
2
4
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import { formatPaginatedResponse, handleErrorWithContext } from '../utils/index.js';
|
|
5
|
+
import { formatPaginatedResponse, formatSimplePaginatedResponse, handleErrorWithContext, } from '../utils/index.js';
|
|
4
6
|
const inputSchema = {
|
|
5
7
|
query: z.string().optional().describe(F.query),
|
|
6
8
|
filter: z
|
|
@@ -19,16 +21,20 @@ const inputSchema = {
|
|
|
19
21
|
.describe(F.sort),
|
|
20
22
|
start_cursor: z.string().optional().describe(F.start_cursor),
|
|
21
23
|
page_size: z.number().min(1).max(100).optional().describe(F.page_size),
|
|
24
|
+
format: z.enum(['json', 'simple']).optional().default('simple').describe(F.format),
|
|
25
|
+
fields: z.array(z.string()).optional().describe(F.fields),
|
|
22
26
|
};
|
|
23
27
|
export function registerSearch(server, notion) {
|
|
24
28
|
server.registerTool('search', {
|
|
25
29
|
description: 'Search across all pages and data sources in the workspace by title and content. ' +
|
|
26
30
|
'Filter results by type (page or data_source) and sort by last edited time. ' +
|
|
27
31
|
'Returns paginated results. ' +
|
|
32
|
+
"Use format='simple' (default) for human-readable output with reduced token usage. " +
|
|
33
|
+
'Use fields parameter to limit which properties are returned (simple format only). ' +
|
|
28
34
|
'For querying a specific data source with filters, use query-data-source instead. ' +
|
|
29
35
|
'(API version 2025-09-03)',
|
|
30
36
|
inputSchema,
|
|
31
|
-
}, async ({ query, filter, sort, start_cursor, page_size }) => {
|
|
37
|
+
}, async ({ query, filter, sort, start_cursor, page_size, format, fields }) => {
|
|
32
38
|
try {
|
|
33
39
|
const params = {};
|
|
34
40
|
if (query) {
|
|
@@ -47,6 +53,32 @@ export function registerSearch(server, notion) {
|
|
|
47
53
|
params.page_size = page_size;
|
|
48
54
|
}
|
|
49
55
|
const response = await notion.search(params);
|
|
56
|
+
if (format === 'simple') {
|
|
57
|
+
// Convert results to simple format
|
|
58
|
+
const simpleResults = response.results.map((result) => {
|
|
59
|
+
if (result.object === 'page' && isFullPage(result)) {
|
|
60
|
+
// Use pagesToSimple for pages
|
|
61
|
+
const [simplePage] = pagesToSimple([result], fields);
|
|
62
|
+
return { object: 'page', ...simplePage };
|
|
63
|
+
}
|
|
64
|
+
if (result.object === 'data_source') {
|
|
65
|
+
// Simple format for data sources
|
|
66
|
+
const ds = result;
|
|
67
|
+
return {
|
|
68
|
+
object: 'data_source',
|
|
69
|
+
id: ds.id,
|
|
70
|
+
title: ds.title?.map((t) => t.plain_text).join('') ?? '',
|
|
71
|
+
url: ds.url ?? '',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Fallback for partial objects
|
|
75
|
+
return {
|
|
76
|
+
object: result.object,
|
|
77
|
+
id: result.id,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
return formatSimplePaginatedResponse(simpleResults, response.has_more, response.next_cursor);
|
|
81
|
+
}
|
|
50
82
|
return formatPaginatedResponse(response.results, response.has_more, response.next_cursor);
|
|
51
83
|
}
|
|
52
84
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-block-simple.d.ts","sourceRoot":"","sources":["../../../src/tools/update-block-simple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAyBpE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-block-simple.d.ts","sourceRoot":"","sources":["../../../src/tools/update-block-simple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAyBpE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAqEvF"}
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { parseInlineMarkdown } from '../converters/index.js';
|
|
3
3
|
import { isFullBlock } from '../notion-client.js';
|
|
4
4
|
import { F } from '../schemas/descriptions/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { formatSimpleResponse, handleError } from '../utils/index.js';
|
|
6
6
|
const inputSchema = {
|
|
7
7
|
block_id: z.string().describe(F.block_id),
|
|
8
8
|
content: z.string().describe(F.content),
|
|
@@ -69,7 +69,10 @@ export function registerUpdateBlockSimple(server, notion) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
const response = await notion.blocks.update(params);
|
|
72
|
-
|
|
72
|
+
// Return minimal response (id only)
|
|
73
|
+
return formatSimpleResponse({
|
|
74
|
+
id: response.id,
|
|
75
|
+
});
|
|
73
76
|
}
|
|
74
77
|
catch (error) {
|
|
75
78
|
return handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-block.d.ts","sourceRoot":"","sources":["../../../src/tools/update-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAUvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-block.d.ts","sourceRoot":"","sources":["../../../src/tools/update-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAUvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAmCjF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
const inputSchema = {
|
|
5
5
|
block_id: z.string().describe(F.block_id),
|
|
6
6
|
block: z.record(z.string(), z.any()).describe(F.block),
|
|
@@ -10,7 +10,8 @@ export function registerUpdateBlock(server, notion) {
|
|
|
10
10
|
server.registerTool('update-block', {
|
|
11
11
|
description: 'Update a block by its ID. Provide the block type and its properties. ' +
|
|
12
12
|
'Example: { "paragraph": { "rich_text": [{ "text": { "content": "Updated text" } }] } }. ' +
|
|
13
|
-
'Set archived to true to move the block to trash.'
|
|
13
|
+
'Set archived to true to move the block to trash. ' +
|
|
14
|
+
'Returns updated block ID.',
|
|
14
15
|
inputSchema,
|
|
15
16
|
}, async ({ block_id, block, archived }) => {
|
|
16
17
|
try {
|
|
@@ -22,7 +23,10 @@ export function registerUpdateBlock(server, notion) {
|
|
|
22
23
|
params.archived = archived;
|
|
23
24
|
}
|
|
24
25
|
const response = await notion.blocks.update(params);
|
|
25
|
-
|
|
26
|
+
// Return minimal response (id only)
|
|
27
|
+
return formatSimpleResponse({
|
|
28
|
+
id: response.id,
|
|
29
|
+
});
|
|
26
30
|
}
|
|
27
31
|
catch (error) {
|
|
28
32
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-data-source.d.ts","sourceRoot":"","sources":["../../../src/tools/update-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAcvD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-data-source.d.ts","sourceRoot":"","sources":["../../../src/tools/update-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAcvD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAmCtF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
data_source_id: z.string().describe(F.data_source_id),
|
|
@@ -10,7 +10,7 @@ export function registerUpdateDataSource(server, notion) {
|
|
|
10
10
|
server.registerTool('update-data-source', {
|
|
11
11
|
description: 'Update a data source schema (properties/columns). ' +
|
|
12
12
|
'Use this to add, update, or delete properties. Set a property to null to delete it. ' +
|
|
13
|
-
'(API version 2025-09-03)',
|
|
13
|
+
'Returns data source ID. (API version 2025-09-03)',
|
|
14
14
|
inputSchema,
|
|
15
15
|
}, async ({ data_source_id, properties }) => {
|
|
16
16
|
try {
|
|
@@ -19,7 +19,10 @@ export function registerUpdateDataSource(server, notion) {
|
|
|
19
19
|
params.properties = properties;
|
|
20
20
|
}
|
|
21
21
|
const response = await notion.dataSources.update(params);
|
|
22
|
-
|
|
22
|
+
// Return minimal response (id only)
|
|
23
|
+
return formatSimpleResponse({
|
|
24
|
+
id: response.id,
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
27
|
catch (error) {
|
|
25
28
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-database.d.ts","sourceRoot":"","sources":["../../../src/tools/update-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAkBvD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-database.d.ts","sourceRoot":"","sources":["../../../src/tools/update-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAkBvD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAsCpF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
// Note: Properties (schema) updates should use update-data-source in API 2025-09-03
|
|
6
6
|
// Uses z.any() for title/description/icon/cover to reduce context size (~3,700 tokens saved)
|
|
@@ -17,7 +17,8 @@ const inputSchema = {
|
|
|
17
17
|
export function registerUpdateDatabase(server, notion) {
|
|
18
18
|
server.registerTool('update-database', {
|
|
19
19
|
description: 'Update a Notion database container. Can modify title, description, icon, cover, inline status, archive status, and lock status. ' +
|
|
20
|
-
'For schema (properties/columns) updates, use update-data-source instead.
|
|
20
|
+
'For schema (properties/columns) updates, use update-data-source instead. ' +
|
|
21
|
+
'Returns database ID and URL. (API version 2025-09-03)',
|
|
21
22
|
inputSchema,
|
|
22
23
|
}, async ({ database_id, title, description, icon, cover, is_inline, archived, is_locked }) => {
|
|
23
24
|
try {
|
|
@@ -33,7 +34,11 @@ export function registerUpdateDatabase(server, notion) {
|
|
|
33
34
|
...(is_locked !== undefined && { is_locked }),
|
|
34
35
|
};
|
|
35
36
|
const response = await notion.databases.update(params);
|
|
36
|
-
|
|
37
|
+
// Return minimal response (id + url only)
|
|
38
|
+
return formatSimpleResponse({
|
|
39
|
+
id: response.id,
|
|
40
|
+
url: 'url' in response ? response.url : undefined,
|
|
41
|
+
});
|
|
37
42
|
}
|
|
38
43
|
catch (error) {
|
|
39
44
|
return handleErrorWithContext(error, notion, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-page.d.ts","sourceRoot":"","sources":["../../../src/tools/update-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAoBvD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update-page.d.ts","sourceRoot":"","sources":["../../../src/tools/update-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAoBvD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA4DhF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F } from '../schemas/descriptions/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatSimpleResponse, handleErrorWithContext } from '../utils/index.js';
|
|
4
4
|
// Minimal schema for MCP (full validation by Notion API)
|
|
5
5
|
const inputSchema = {
|
|
6
6
|
page_id: z.string().describe(F.page_id),
|
|
@@ -16,7 +16,8 @@ export function registerUpdatePage(server, notion) {
|
|
|
16
16
|
'Partial updates are supported - only provide the fields you want to change. ' +
|
|
17
17
|
'Set icon or cover to null to remove them. ' +
|
|
18
18
|
'Set archived to true to move the page to trash. ' +
|
|
19
|
-
'Set is_locked to true to lock the page in the UI.'
|
|
19
|
+
'Set is_locked to true to lock the page in the UI. ' +
|
|
20
|
+
'Returns updated page ID and URL.',
|
|
20
21
|
inputSchema,
|
|
21
22
|
}, async ({ page_id, properties, archived, icon, cover, is_locked }) => {
|
|
22
23
|
try {
|
|
@@ -37,7 +38,11 @@ export function registerUpdatePage(server, notion) {
|
|
|
37
38
|
params.is_locked = is_locked;
|
|
38
39
|
}
|
|
39
40
|
const response = await notion.pages.update(params);
|
|
40
|
-
|
|
41
|
+
// Return minimal response (id + url only)
|
|
42
|
+
return formatSimpleResponse({
|
|
43
|
+
id: response.id,
|
|
44
|
+
url: 'url' in response ? response.url : undefined,
|
|
45
|
+
});
|
|
41
46
|
}
|
|
42
47
|
catch (error) {
|
|
43
48
|
// Note: update-page uses page_id, not data_source_id,
|