@atikk-co-jp/notion-mcp-server 0.2.3 → 0.4.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/README.ja.md +105 -4
- package/README.md +105 -4
- package/dist/src/converters/__tests__/markdown-to-blocks.test.d.ts +2 -0
- package/dist/src/converters/__tests__/markdown-to-blocks.test.d.ts.map +1 -0
- package/dist/src/converters/__tests__/markdown-to-blocks.test.js +245 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/index.d.ts.map +1 -1
- package/dist/src/converters/index.js +2 -0
- package/dist/src/converters/markdown-to-blocks.d.ts +21 -0
- package/dist/src/converters/markdown-to-blocks.d.ts.map +1 -0
- package/dist/src/converters/markdown-to-blocks.js +244 -0
- package/dist/src/notion-client.d.ts +40 -0
- package/dist/src/notion-client.d.ts.map +1 -1
- package/dist/src/notion-client.js +39 -0
- package/dist/src/tools/append-blocks-simple.d.ts +4 -0
- package/dist/src/tools/append-blocks-simple.d.ts.map +1 -0
- package/dist/src/tools/append-blocks-simple.js +36 -0
- package/dist/src/tools/create-database.d.ts.map +1 -1
- package/dist/src/tools/create-database.js +3 -1
- package/dist/src/tools/create-page-simple.d.ts +4 -0
- package/dist/src/tools/create-page-simple.d.ts.map +1 -0
- package/dist/src/tools/create-page-simple.js +54 -0
- package/dist/src/tools/delete-block.d.ts +4 -0
- package/dist/src/tools/delete-block.d.ts.map +1 -0
- package/dist/src/tools/delete-block.js +20 -0
- package/dist/src/tools/index.d.ts +14 -1
- package/dist/src/tools/index.d.ts.map +1 -1
- package/dist/src/tools/index.js +28 -1
- package/dist/src/tools/list-comments.d.ts +4 -0
- package/dist/src/tools/list-comments.d.ts.map +1 -0
- package/dist/src/tools/list-comments.js +50 -0
- package/dist/src/tools/list-users.d.ts +4 -0
- package/dist/src/tools/list-users.d.ts.map +1 -0
- package/dist/src/tools/list-users.js +31 -0
- package/dist/src/tools/move-page.d.ts +4 -0
- package/dist/src/tools/move-page.d.ts.map +1 -0
- package/dist/src/tools/move-page.js +43 -0
- package/dist/src/tools/query-database.d.ts.map +1 -1
- package/dist/src/tools/retrieve-block.d.ts +4 -0
- package/dist/src/tools/retrieve-block.d.ts.map +1 -0
- package/dist/src/tools/retrieve-block.js +32 -0
- package/dist/src/tools/retrieve-bot-user.d.ts +4 -0
- package/dist/src/tools/retrieve-bot-user.d.ts.map +1 -0
- package/dist/src/tools/retrieve-bot-user.js +16 -0
- package/dist/src/tools/retrieve-database.d.ts +4 -0
- package/dist/src/tools/retrieve-database.d.ts.map +1 -0
- package/dist/src/tools/retrieve-database.js +58 -0
- package/dist/src/tools/retrieve-page-property.d.ts +4 -0
- package/dist/src/tools/retrieve-page-property.d.ts.map +1 -0
- package/dist/src/tools/retrieve-page-property.js +33 -0
- package/dist/src/tools/retrieve-user.d.ts +4 -0
- package/dist/src/tools/retrieve-user.d.ts.map +1 -0
- package/dist/src/tools/retrieve-user.js +19 -0
- package/dist/src/tools/update-block-simple.d.ts +4 -0
- package/dist/src/tools/update-block-simple.d.ts.map +1 -0
- package/dist/src/tools/update-block-simple.js +68 -0
- package/dist/src/tools/update-block.d.ts +4 -0
- package/dist/src/tools/update-block.d.ts.map +1 -0
- package/dist/src/tools/update-block.js +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatPaginatedResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
block_id: z.string().optional().describe('Block ID to get comments from'),
|
|
5
|
+
page_id: z
|
|
6
|
+
.string()
|
|
7
|
+
.optional()
|
|
8
|
+
.describe('Page ID to get comments from (use either block_id or page_id)'),
|
|
9
|
+
start_cursor: z.string().optional().describe('Pagination cursor'),
|
|
10
|
+
page_size: z.number().optional().describe('Number of results (1-100)'),
|
|
11
|
+
};
|
|
12
|
+
export function registerListComments(server, notion) {
|
|
13
|
+
server.registerTool('list-comments', {
|
|
14
|
+
description: 'List comments on a page or block. Either block_id or page_id must be provided. ' +
|
|
15
|
+
'Returns a paginated list of comments with their content and metadata.',
|
|
16
|
+
inputSchema,
|
|
17
|
+
}, async ({ block_id, page_id, start_cursor, page_size }) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!block_id && !page_id) {
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: 'Error: Either block_id or page_id must be provided.',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
isError: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Notion API only accepts block_id (page_id works as block_id since pages are blocks)
|
|
31
|
+
const response = await notion.comments.list({
|
|
32
|
+
block_id: block_id || page_id,
|
|
33
|
+
start_cursor,
|
|
34
|
+
page_size,
|
|
35
|
+
});
|
|
36
|
+
// Format comments with essential info
|
|
37
|
+
const comments = response.results.map((comment) => ({
|
|
38
|
+
id: comment.id,
|
|
39
|
+
discussion_id: comment.discussion_id,
|
|
40
|
+
text: comment.rich_text.map((t) => t.plain_text).join(''),
|
|
41
|
+
created_time: comment.created_time,
|
|
42
|
+
created_by: comment.created_by.id,
|
|
43
|
+
}));
|
|
44
|
+
return formatPaginatedResponse(comments, response.has_more, response.next_cursor);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return handleError(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-users.d.ts","sourceRoot":"","sources":["../../../src/tools/list-users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAuBvD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA8B/E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatPaginatedResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
start_cursor: z.string().optional().describe('Pagination cursor'),
|
|
5
|
+
page_size: z.number().optional().describe('Number of results (1-100)'),
|
|
6
|
+
};
|
|
7
|
+
export function registerListUsers(server, notion) {
|
|
8
|
+
server.registerTool('list-users', {
|
|
9
|
+
description: 'List all users in the workspace. Returns paginated list of users with their IDs, names, and types (person or bot).',
|
|
10
|
+
inputSchema,
|
|
11
|
+
}, async ({ start_cursor, page_size }) => {
|
|
12
|
+
try {
|
|
13
|
+
const response = await notion.users.list({
|
|
14
|
+
start_cursor,
|
|
15
|
+
page_size,
|
|
16
|
+
});
|
|
17
|
+
// Format users with essential info
|
|
18
|
+
const users = response.results.map((user) => ({
|
|
19
|
+
id: user.id,
|
|
20
|
+
type: user.type,
|
|
21
|
+
name: user.name,
|
|
22
|
+
avatar_url: user.avatar_url,
|
|
23
|
+
email: user.person?.email,
|
|
24
|
+
}));
|
|
25
|
+
return formatPaginatedResponse(users, response.has_more, response.next_cursor);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return handleError(error);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +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;AAavD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAsC9E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
page_id: z.string().describe('Page ID to move'),
|
|
5
|
+
parent: z
|
|
6
|
+
.object({
|
|
7
|
+
page_id: z.string().optional().describe('Target parent page ID'),
|
|
8
|
+
database_id: z.string().optional().describe('Target database ID'),
|
|
9
|
+
})
|
|
10
|
+
.describe('New parent (provide either page_id or database_id)'),
|
|
11
|
+
};
|
|
12
|
+
export function registerMovePage(server, notion) {
|
|
13
|
+
server.registerTool('move-page', {
|
|
14
|
+
description: 'Move a page to a new parent (page or database). ' +
|
|
15
|
+
'Provide either page_id or database_id as the new parent.',
|
|
16
|
+
inputSchema,
|
|
17
|
+
}, async ({ page_id, parent }) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!parent.page_id && !parent.database_id) {
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: 'Error: Parent must have either page_id or database_id.',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
isError: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const parentParam = parent.page_id
|
|
31
|
+
? { page_id: parent.page_id }
|
|
32
|
+
: { database_id: parent.database_id };
|
|
33
|
+
const response = await notion.pages.move({
|
|
34
|
+
page_id,
|
|
35
|
+
parent: parentParam,
|
|
36
|
+
});
|
|
37
|
+
return formatResponse(response);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return handleError(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-database.d.ts","sourceRoot":"","sources":["../../../src/tools/query-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA8BvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"query-database.d.ts","sourceRoot":"","sources":["../../../src/tools/query-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA8BvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAoDnF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NotionClient } from '../notion-client.js';
|
|
3
|
+
export declare function registerRetrieveBlock(server: McpServer, notion: NotionClient): void;
|
|
4
|
+
//# sourceMappingURL=retrieve-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-block.d.ts","sourceRoot":"","sources":["../../../src/tools/retrieve-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAWvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2BnF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { blocksToMarkdownSync } from '../converters/index.js';
|
|
3
|
+
import { formatMarkdownResponse, formatResponse, handleError } from '../utils/index.js';
|
|
4
|
+
const inputSchema = {
|
|
5
|
+
block_id: z.string().describe('Block ID to retrieve'),
|
|
6
|
+
format: z
|
|
7
|
+
.enum(['markdown', 'json'])
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Output format: 'markdown' (default) or 'json'"),
|
|
10
|
+
};
|
|
11
|
+
export function registerRetrieveBlock(server, notion) {
|
|
12
|
+
server.registerTool('retrieve-block', {
|
|
13
|
+
description: 'Retrieve a single block by its ID. Returns block content and metadata. ' +
|
|
14
|
+
"Use format='markdown' (default) for human-readable output, 'json' for full Notion API response.",
|
|
15
|
+
inputSchema,
|
|
16
|
+
}, async ({ block_id, format = 'markdown' }) => {
|
|
17
|
+
try {
|
|
18
|
+
const response = await notion.blocks.retrieve({
|
|
19
|
+
block_id,
|
|
20
|
+
});
|
|
21
|
+
if (format === 'json') {
|
|
22
|
+
return formatResponse(response);
|
|
23
|
+
}
|
|
24
|
+
// Convert to markdown
|
|
25
|
+
const markdown = blocksToMarkdownSync([response]);
|
|
26
|
+
return formatMarkdownResponse(markdown, false, null);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return handleError(error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NotionClient } from '../notion-client.js';
|
|
3
|
+
export declare function registerRetrieveBotUser(server: McpServer, notion: NotionClient): void;
|
|
4
|
+
//# sourceMappingURL=retrieve-bot-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-bot-user.d.ts","sourceRoot":"","sources":["../../../src/tools/retrieve-bot-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGvD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAkBrF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { formatResponse, handleError } from '../utils/index.js';
|
|
2
|
+
export function registerRetrieveBotUser(server, notion) {
|
|
3
|
+
server.registerTool('retrieve-bot-user', {
|
|
4
|
+
description: 'Retrieve information about the current bot user (the integration). ' +
|
|
5
|
+
'Returns the bot ID, name, avatar, and owner information.',
|
|
6
|
+
inputSchema: {},
|
|
7
|
+
}, async () => {
|
|
8
|
+
try {
|
|
9
|
+
const response = await notion.users.me();
|
|
10
|
+
return formatResponse(response);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return handleError(error);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NotionClient } from '../notion-client.js';
|
|
3
|
+
export declare function registerRetrieveDatabase(server: McpServer, notion: NotionClient): void;
|
|
4
|
+
//# sourceMappingURL=retrieve-database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-database.d.ts","sourceRoot":"","sources":["../../../src/tools/retrieve-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA8BvD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2DtF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatResponse, formatSimpleResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
database_id: z.string().describe('Database ID'),
|
|
5
|
+
format: z
|
|
6
|
+
.enum(['json', 'simple'])
|
|
7
|
+
.optional()
|
|
8
|
+
.describe("Output format: 'simple' (default) or 'json'"),
|
|
9
|
+
};
|
|
10
|
+
export function registerRetrieveDatabase(server, notion) {
|
|
11
|
+
server.registerTool('retrieve-database', {
|
|
12
|
+
description: 'Retrieve a database schema by its ID. Returns database properties (columns) and their types. ' +
|
|
13
|
+
"Use format='simple' (default) for reduced token usage, 'json' for full Notion API response.",
|
|
14
|
+
inputSchema,
|
|
15
|
+
}, async ({ database_id, format = 'simple' }) => {
|
|
16
|
+
try {
|
|
17
|
+
const response = await notion.databases.retrieve({ database_id });
|
|
18
|
+
if (format === 'json') {
|
|
19
|
+
return formatResponse(response);
|
|
20
|
+
}
|
|
21
|
+
// Simple format: extract essential info
|
|
22
|
+
const simpleProperties = {};
|
|
23
|
+
for (const [name, prop] of Object.entries(response.properties)) {
|
|
24
|
+
const simpleProp = {
|
|
25
|
+
id: prop.id,
|
|
26
|
+
type: prop.type,
|
|
27
|
+
};
|
|
28
|
+
// Include options for select/multi_select/status
|
|
29
|
+
if (prop.type === 'select' && prop.select) {
|
|
30
|
+
const selectProp = prop.select;
|
|
31
|
+
simpleProp.options = selectProp.options;
|
|
32
|
+
}
|
|
33
|
+
else if (prop.type === 'multi_select' && prop.multi_select) {
|
|
34
|
+
const multiSelectProp = prop.multi_select;
|
|
35
|
+
simpleProp.options = multiSelectProp.options;
|
|
36
|
+
}
|
|
37
|
+
else if (prop.type === 'status' && prop.status) {
|
|
38
|
+
const statusProp = prop.status;
|
|
39
|
+
simpleProp.options = statusProp.options;
|
|
40
|
+
}
|
|
41
|
+
simpleProperties[name] = simpleProp;
|
|
42
|
+
}
|
|
43
|
+
const simpleResponse = {
|
|
44
|
+
id: response.id,
|
|
45
|
+
title: response.title.map((t) => t.plain_text).join(''),
|
|
46
|
+
description: response.description.map((t) => t.plain_text).join(''),
|
|
47
|
+
url: response.url,
|
|
48
|
+
properties: simpleProperties,
|
|
49
|
+
is_inline: response.is_inline,
|
|
50
|
+
archived: response.archived,
|
|
51
|
+
};
|
|
52
|
+
return formatSimpleResponse(simpleResponse);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return handleError(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NotionClient } from '../notion-client.js';
|
|
3
|
+
export declare function registerRetrievePageProperty(server: McpServer, notion: NotionClient): void;
|
|
4
|
+
//# sourceMappingURL=retrieve-page-property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-page-property.d.ts","sourceRoot":"","sources":["../../../src/tools/retrieve-page-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAmBvD,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAkC1F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatPaginatedResponse, formatResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
page_id: z.string().describe('Page ID'),
|
|
5
|
+
property_id: z.string().describe('Property ID (from page properties)'),
|
|
6
|
+
start_cursor: z.string().optional().describe('Pagination cursor'),
|
|
7
|
+
page_size: z.number().optional().describe('Number of results (1-100)'),
|
|
8
|
+
};
|
|
9
|
+
export function registerRetrievePageProperty(server, notion) {
|
|
10
|
+
server.registerTool('retrieve-page-property', {
|
|
11
|
+
description: 'Retrieve a specific property value from a page. Supports pagination for properties with many values (e.g., rollup, relation). ' +
|
|
12
|
+
'Use the property_id from the page properties object.',
|
|
13
|
+
inputSchema,
|
|
14
|
+
}, async ({ page_id, property_id, start_cursor, page_size }) => {
|
|
15
|
+
try {
|
|
16
|
+
const response = await notion.pages.retrieveProperty({
|
|
17
|
+
page_id,
|
|
18
|
+
property_id,
|
|
19
|
+
start_cursor,
|
|
20
|
+
page_size,
|
|
21
|
+
});
|
|
22
|
+
// If it's a paginated list response
|
|
23
|
+
if (response.object === 'list' && response.results) {
|
|
24
|
+
return formatPaginatedResponse(response.results, response.has_more ?? false, response.next_cursor ?? null);
|
|
25
|
+
}
|
|
26
|
+
// Single property item
|
|
27
|
+
return formatResponse(response);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return handleError(error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-user.d.ts","sourceRoot":"","sources":["../../../src/tools/retrieve-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAOvD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAiBlF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
user_id: z.string().describe('User ID'),
|
|
5
|
+
};
|
|
6
|
+
export function registerRetrieveUser(server, notion) {
|
|
7
|
+
server.registerTool('retrieve-user', {
|
|
8
|
+
description: 'Retrieve a user by their ID. Returns user information including name, avatar, and type (person or bot).',
|
|
9
|
+
inputSchema,
|
|
10
|
+
}, async ({ user_id }) => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await notion.users.retrieve({ user_id });
|
|
13
|
+
return formatResponse(response);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return handleError(error);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NotionClient } from '../notion-client.js';
|
|
3
|
+
export declare function registerUpdateBlockSimple(server: McpServer, notion: NotionClient): void;
|
|
4
|
+
//# sourceMappingURL=update-block-simple.d.ts.map
|
|
@@ -0,0 +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,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAwBvD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2DvF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseInlineMarkdown } from '../converters/index.js';
|
|
3
|
+
import { formatResponse, handleError } from '../utils/index.js';
|
|
4
|
+
const inputSchema = {
|
|
5
|
+
block_id: z.string().describe('Block ID to update'),
|
|
6
|
+
content: z.string().describe('New content in Markdown format'),
|
|
7
|
+
};
|
|
8
|
+
// Supported block types for simple update
|
|
9
|
+
const SUPPORTED_TYPES = [
|
|
10
|
+
'paragraph',
|
|
11
|
+
'heading_1',
|
|
12
|
+
'heading_2',
|
|
13
|
+
'heading_3',
|
|
14
|
+
'bulleted_list_item',
|
|
15
|
+
'numbered_list_item',
|
|
16
|
+
'to_do',
|
|
17
|
+
'quote',
|
|
18
|
+
'callout',
|
|
19
|
+
'toggle',
|
|
20
|
+
];
|
|
21
|
+
export function registerUpdateBlockSimple(server, notion) {
|
|
22
|
+
server.registerTool('update-block-simple', {
|
|
23
|
+
description: 'Update a text block using Markdown. Simpler than update-block: just provide markdown text. ' +
|
|
24
|
+
'Supports inline formatting: **bold**, *italic*, ~~strikethrough~~, `code`, [links](url). ' +
|
|
25
|
+
'Only works with text-based blocks: paragraph, headings, lists, to_do, quote, callout, toggle.',
|
|
26
|
+
inputSchema,
|
|
27
|
+
}, async ({ block_id, content }) => {
|
|
28
|
+
try {
|
|
29
|
+
// First, retrieve the block to get its type
|
|
30
|
+
const existingBlock = await notion.blocks.retrieve({ block_id });
|
|
31
|
+
const blockType = existingBlock.type;
|
|
32
|
+
if (!SUPPORTED_TYPES.includes(blockType)) {
|
|
33
|
+
return {
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'text',
|
|
37
|
+
text: `Error: Block type "${blockType}" is not supported for simple update. Supported types: ${SUPPORTED_TYPES.join(', ')}`,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
isError: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Parse markdown to rich_text
|
|
44
|
+
const richText = parseInlineMarkdown(content);
|
|
45
|
+
// Build the update params based on block type
|
|
46
|
+
const params = {
|
|
47
|
+
block_id,
|
|
48
|
+
};
|
|
49
|
+
if (blockType === 'to_do') {
|
|
50
|
+
// Preserve the checked state for to_do blocks
|
|
51
|
+
params[blockType] = {
|
|
52
|
+
rich_text: richText,
|
|
53
|
+
checked: existingBlock.to_do?.checked ?? false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
params[blockType] = {
|
|
58
|
+
rich_text: richText,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const response = await notion.blocks.update(params);
|
|
62
|
+
return formatResponse(response);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return handleError(error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +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;AASvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA4BjF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { formatResponse, handleError } from '../utils/index.js';
|
|
3
|
+
const inputSchema = {
|
|
4
|
+
block_id: z.string().describe('Block ID to update'),
|
|
5
|
+
block: z.record(z.string(), z.any()).describe('Block data with type-specific properties'),
|
|
6
|
+
archived: z.boolean().optional().describe('Set to true to archive the block'),
|
|
7
|
+
};
|
|
8
|
+
export function registerUpdateBlock(server, notion) {
|
|
9
|
+
server.registerTool('update-block', {
|
|
10
|
+
description: 'Update a block by its ID. Provide the block type and its properties. ' +
|
|
11
|
+
'Example: { "paragraph": { "rich_text": [{ "text": { "content": "Updated text" } }] } }. ' +
|
|
12
|
+
'Set archived to true to move the block to trash.',
|
|
13
|
+
inputSchema,
|
|
14
|
+
}, async ({ block_id, block, archived }) => {
|
|
15
|
+
try {
|
|
16
|
+
const params = {
|
|
17
|
+
block_id,
|
|
18
|
+
...block,
|
|
19
|
+
};
|
|
20
|
+
if (archived !== undefined) {
|
|
21
|
+
params.archived = archived;
|
|
22
|
+
}
|
|
23
|
+
const response = await notion.blocks.update(params);
|
|
24
|
+
return formatResponse(response);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return handleError(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|