@atikk-co-jp/notion-mcp-server 0.3.0 → 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 +42 -5
- package/README.md +42 -5
- package/dist/src/converters/index.d.ts +1 -1
- package/dist/src/converters/index.d.ts.map +1 -1
- package/dist/src/converters/index.js +2 -2
- package/dist/src/converters/markdown-to-blocks.d.ts.map +1 -1
- package/dist/src/converters/markdown-to-blocks.js +4 -4
- 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/create-database.d.ts.map +1 -1
- package/dist/src/tools/create-database.js +3 -1
- 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 +12 -1
- package/dist/src/tools/index.d.ts.map +1 -1
- package/dist/src/tools/index.js +24 -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
package/README.ja.md
CHANGED
|
@@ -8,13 +8,50 @@ Notion API用のMCP(Model Context Protocol)サーバー。AIアシスタン
|
|
|
8
8
|
|
|
9
9
|
## 特徴
|
|
10
10
|
|
|
11
|
-
- **ページ操作**: Notion
|
|
12
|
-
- **データベース操作**:
|
|
13
|
-
- **ブロック操作**:
|
|
11
|
+
- **ページ操作**: Notionページの作成、取得、更新、移動
|
|
12
|
+
- **データベース操作**: データベースの作成、取得、更新、フィルター/ソートを使ったクエリ
|
|
13
|
+
- **ブロック操作**: ブロックの取得、更新、削除、子要素の追加
|
|
14
14
|
- **検索**: ページとデータベースの横断検索
|
|
15
|
-
- **コメント**:
|
|
15
|
+
- **コメント**: コメントの作成・一覧取得
|
|
16
|
+
- **ユーザー**: ユーザー一覧取得、ユーザー情報取得
|
|
16
17
|
- **トークン効率化**: マークダウン/シンプル形式でトークン使用量を約96%削減
|
|
17
|
-
- **Markdown入力対応**: Markdown
|
|
18
|
+
- **Markdown入力対応**: Markdownでコンテンツを作成・追加(入力トークン80%削減)
|
|
19
|
+
|
|
20
|
+
## API対応表
|
|
21
|
+
|
|
22
|
+
| カテゴリ | Notion API | MCPツール | 形式 |
|
|
23
|
+
|---------|-----------|----------|------|
|
|
24
|
+
| **ページ** | | | |
|
|
25
|
+
| | [Create page](https://developers.notion.com/reference/post-page) | `create-page` | JSON |
|
|
26
|
+
| | | `create-page-simple` ⭐ | Markdown |
|
|
27
|
+
| | [Retrieve page](https://developers.notion.com/reference/retrieve-a-page) | `retrieve-page` | simple/json |
|
|
28
|
+
| | [Update page](https://developers.notion.com/reference/patch-page) | `update-page` | JSON |
|
|
29
|
+
| | [Retrieve page property](https://developers.notion.com/reference/retrieve-a-page-property-item) | `retrieve-page-property` | JSON |
|
|
30
|
+
| | [Move page](https://developers.notion.com/reference/post-page-move) | `move-page` | JSON |
|
|
31
|
+
| **データベース** | | | |
|
|
32
|
+
| | [Create database](https://developers.notion.com/reference/create-a-database) | `create-database` | JSON |
|
|
33
|
+
| | [Retrieve database](https://developers.notion.com/reference/retrieve-a-database) | `retrieve-database` | simple/json |
|
|
34
|
+
| | [Update database](https://developers.notion.com/reference/update-a-database) | `update-database` | JSON |
|
|
35
|
+
| | [Query database](https://developers.notion.com/reference/post-database-query) | `query-database` | simple/json |
|
|
36
|
+
| **ブロック** | | | |
|
|
37
|
+
| | [Retrieve block](https://developers.notion.com/reference/retrieve-a-block) | `retrieve-block` | markdown/json |
|
|
38
|
+
| | [Update block](https://developers.notion.com/reference/update-a-block) | `update-block` | JSON |
|
|
39
|
+
| | | `update-block-simple` ⭐ | Markdown |
|
|
40
|
+
| | [Delete block](https://developers.notion.com/reference/delete-a-block) | `delete-block` | JSON |
|
|
41
|
+
| | [Retrieve block children](https://developers.notion.com/reference/get-block-children) | `get-block-children` | markdown/json |
|
|
42
|
+
| | [Append block children](https://developers.notion.com/reference/patch-block-children) | `append-block-children` | JSON |
|
|
43
|
+
| | | `append-blocks-simple` ⭐ | Markdown |
|
|
44
|
+
| **コメント** | | | |
|
|
45
|
+
| | [Create comment](https://developers.notion.com/reference/create-a-comment) | `create-comment` | JSON |
|
|
46
|
+
| | [List comments](https://developers.notion.com/reference/retrieve-comments) | `list-comments` | JSON |
|
|
47
|
+
| **ユーザー** | | | |
|
|
48
|
+
| | [List users](https://developers.notion.com/reference/get-users) | `list-users` | JSON |
|
|
49
|
+
| | [Retrieve user](https://developers.notion.com/reference/get-user) | `retrieve-user` | JSON |
|
|
50
|
+
| | [Retrieve bot user](https://developers.notion.com/reference/get-self) | `retrieve-bot-user` | JSON |
|
|
51
|
+
| **検索** | | | |
|
|
52
|
+
| | [Search](https://developers.notion.com/reference/post-search) | `search` | JSON |
|
|
53
|
+
|
|
54
|
+
⭐ = Markdown入力対応(入力トークン約80%削減)
|
|
18
55
|
|
|
19
56
|
## インストール
|
|
20
57
|
|
package/README.md
CHANGED
|
@@ -8,13 +8,50 @@ MCP (Model Context Protocol) server for Notion API. Enables AI assistants to int
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **Page Operations**: Create, retrieve, and
|
|
12
|
-
- **Database Operations**: Create, update, and query databases with filters and sorts
|
|
13
|
-
- **Block Operations**:
|
|
11
|
+
- **Page Operations**: Create, retrieve, update, and move Notion pages
|
|
12
|
+
- **Database Operations**: Create, retrieve, update, and query databases with filters and sorts
|
|
13
|
+
- **Block Operations**: Retrieve, update, delete, and append blocks
|
|
14
14
|
- **Search**: Search across pages and databases
|
|
15
|
-
- **Comments**:
|
|
15
|
+
- **Comments**: Create and list comments
|
|
16
|
+
- **Users**: List users and retrieve user info
|
|
16
17
|
- **Token-Efficient Output**: Markdown/simple format reduces token usage by ~96%
|
|
17
|
-
- **Markdown Input**: Create and append content using Markdown (80% fewer
|
|
18
|
+
- **Markdown Input**: Create and append content using Markdown (80% fewer input tokens)
|
|
19
|
+
|
|
20
|
+
## API Coverage
|
|
21
|
+
|
|
22
|
+
| Category | Notion API | MCP Tool | Format |
|
|
23
|
+
|----------|-----------|----------|--------|
|
|
24
|
+
| **Pages** | | | |
|
|
25
|
+
| | [Create page](https://developers.notion.com/reference/post-page) | `create-page` | JSON |
|
|
26
|
+
| | | `create-page-simple` ⭐ | Markdown |
|
|
27
|
+
| | [Retrieve page](https://developers.notion.com/reference/retrieve-a-page) | `retrieve-page` | simple/json |
|
|
28
|
+
| | [Update page](https://developers.notion.com/reference/patch-page) | `update-page` | JSON |
|
|
29
|
+
| | [Retrieve page property](https://developers.notion.com/reference/retrieve-a-page-property-item) | `retrieve-page-property` | JSON |
|
|
30
|
+
| | [Move page](https://developers.notion.com/reference/post-page-move) | `move-page` | JSON |
|
|
31
|
+
| **Databases** | | | |
|
|
32
|
+
| | [Create database](https://developers.notion.com/reference/create-a-database) | `create-database` | JSON |
|
|
33
|
+
| | [Retrieve database](https://developers.notion.com/reference/retrieve-a-database) | `retrieve-database` | simple/json |
|
|
34
|
+
| | [Update database](https://developers.notion.com/reference/update-a-database) | `update-database` | JSON |
|
|
35
|
+
| | [Query database](https://developers.notion.com/reference/post-database-query) | `query-database` | simple/json |
|
|
36
|
+
| **Blocks** | | | |
|
|
37
|
+
| | [Retrieve block](https://developers.notion.com/reference/retrieve-a-block) | `retrieve-block` | markdown/json |
|
|
38
|
+
| | [Update block](https://developers.notion.com/reference/update-a-block) | `update-block` | JSON |
|
|
39
|
+
| | | `update-block-simple` ⭐ | Markdown |
|
|
40
|
+
| | [Delete block](https://developers.notion.com/reference/delete-a-block) | `delete-block` | JSON |
|
|
41
|
+
| | [Retrieve block children](https://developers.notion.com/reference/get-block-children) | `get-block-children` | markdown/json |
|
|
42
|
+
| | [Append block children](https://developers.notion.com/reference/patch-block-children) | `append-block-children` | JSON |
|
|
43
|
+
| | | `append-blocks-simple` ⭐ | Markdown |
|
|
44
|
+
| **Comments** | | | |
|
|
45
|
+
| | [Create comment](https://developers.notion.com/reference/create-a-comment) | `create-comment` | JSON |
|
|
46
|
+
| | [List comments](https://developers.notion.com/reference/retrieve-comments) | `list-comments` | JSON |
|
|
47
|
+
| **Users** | | | |
|
|
48
|
+
| | [List users](https://developers.notion.com/reference/get-users) | `list-users` | JSON |
|
|
49
|
+
| | [Retrieve user](https://developers.notion.com/reference/get-user) | `retrieve-user` | JSON |
|
|
50
|
+
| | [Retrieve bot user](https://developers.notion.com/reference/get-self) | `retrieve-bot-user` | JSON |
|
|
51
|
+
| **Search** | | | |
|
|
52
|
+
| | [Search](https://developers.notion.com/reference/post-search) | `search` | JSON |
|
|
53
|
+
|
|
54
|
+
⭐ = Markdown input supported (reduces input tokens by ~80%)
|
|
18
55
|
|
|
19
56
|
## Installation
|
|
20
57
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Notion APIから取得したデータをマークダウンやシンプルな形式に変換する機能を提供
|
|
5
5
|
*/
|
|
6
6
|
export { blocksToMarkdown, blocksToMarkdownSync, type ConvertOptions, type NotionBlock, } from './block-to-markdown.js';
|
|
7
|
+
export { markdownToBlocks, parseInlineMarkdown } from './markdown-to-blocks.js';
|
|
7
8
|
export { type NotionProperty, type PropertyValue, pagePropertiesToObject, pagePropertiesToSimple, pagesToSimple, pageToSimple, type SimplePage, type SimpleProperty, } from './page-to-markdown.js';
|
|
8
9
|
export { type RichTextItem, richTextToMarkdown, richTextToPlain, } from './rich-text-to-markdown.js';
|
|
9
|
-
export { markdownToBlocks, parseInlineMarkdown } from './markdown-to-blocks.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,KAAK,YAAY,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,4BAA4B,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/converters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE/E,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,KAAK,YAAY,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,4BAA4B,CAAA"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// ブロック変換
|
|
7
7
|
export { blocksToMarkdown, blocksToMarkdownSync, } from './block-to-markdown.js';
|
|
8
|
+
// Markdown→ブロック変換
|
|
9
|
+
export { markdownToBlocks, parseInlineMarkdown } from './markdown-to-blocks.js';
|
|
8
10
|
// ページプロパティ変換
|
|
9
11
|
export { pagePropertiesToObject, pagePropertiesToSimple, pagesToSimple, pageToSimple, } from './page-to-markdown.js';
|
|
10
12
|
// RichText変換
|
|
11
13
|
export { richTextToMarkdown, richTextToPlain, } from './rich-text-to-markdown.js';
|
|
12
|
-
// Markdown→ブロック変換
|
|
13
|
-
export { markdownToBlocks, parseInlineMarkdown } from './markdown-to-blocks.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-to-blocks.d.ts","sourceRoot":"","sources":["../../../src/converters/markdown-to-blocks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAO9D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA8HhE;AAmBD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"markdown-to-blocks.d.ts","sourceRoot":"","sources":["../../../src/converters/markdown-to-blocks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAO9D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA8HhE;AAmBD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CA8HhE"}
|
|
@@ -149,7 +149,9 @@ export function markdownToBlocks(markdown) {
|
|
|
149
149
|
const language = line.slice(3).trim() || 'plain text';
|
|
150
150
|
const codeLines = [];
|
|
151
151
|
i++;
|
|
152
|
-
while (i < lines.length &&
|
|
152
|
+
while (i < lines.length &&
|
|
153
|
+
!lines[i].startsWith('```') &&
|
|
154
|
+
codeLines.length < MAX_CODE_BLOCK_LINES) {
|
|
153
155
|
codeLines.push(lines[i]);
|
|
154
156
|
i++;
|
|
155
157
|
}
|
|
@@ -228,9 +230,7 @@ export function markdownToBlocks(markdown) {
|
|
|
228
230
|
image: {
|
|
229
231
|
type: 'external',
|
|
230
232
|
external: { url: imageMatch[2] },
|
|
231
|
-
caption: imageMatch[1]
|
|
232
|
-
? [{ type: 'text', text: { content: imageMatch[1] } }]
|
|
233
|
-
: [],
|
|
233
|
+
caption: imageMatch[1] ? [{ type: 'text', text: { content: imageMatch[1] } }] : [],
|
|
234
234
|
},
|
|
235
235
|
});
|
|
236
236
|
i++;
|
|
@@ -51,6 +51,20 @@ export declare class NotionClient {
|
|
|
51
51
|
icon?: Icon | null;
|
|
52
52
|
cover?: Cover | null;
|
|
53
53
|
}) => Promise<T>;
|
|
54
|
+
retrieveProperty: <T>(params: {
|
|
55
|
+
page_id: string;
|
|
56
|
+
property_id: string;
|
|
57
|
+
start_cursor?: string;
|
|
58
|
+
page_size?: number;
|
|
59
|
+
}) => Promise<T>;
|
|
60
|
+
move: <T>(params: {
|
|
61
|
+
page_id: string;
|
|
62
|
+
parent: {
|
|
63
|
+
page_id: string;
|
|
64
|
+
} | {
|
|
65
|
+
database_id: string;
|
|
66
|
+
};
|
|
67
|
+
}) => Promise<T>;
|
|
54
68
|
};
|
|
55
69
|
databases: {
|
|
56
70
|
create: <T>(params: {
|
|
@@ -85,6 +99,16 @@ export declare class NotionClient {
|
|
|
85
99
|
}) => Promise<T>;
|
|
86
100
|
};
|
|
87
101
|
blocks: {
|
|
102
|
+
retrieve: <T>(params: {
|
|
103
|
+
block_id: string;
|
|
104
|
+
}) => Promise<T>;
|
|
105
|
+
update: <T>(params: {
|
|
106
|
+
block_id: string;
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}) => Promise<T>;
|
|
109
|
+
delete: <T>(params: {
|
|
110
|
+
block_id: string;
|
|
111
|
+
}) => Promise<T>;
|
|
88
112
|
children: {
|
|
89
113
|
list: <T>(params: {
|
|
90
114
|
block_id: string;
|
|
@@ -103,8 +127,24 @@ export declare class NotionClient {
|
|
|
103
127
|
parent: {
|
|
104
128
|
page_id: string;
|
|
105
129
|
};
|
|
130
|
+
discussion_id?: string;
|
|
106
131
|
rich_text: RichText[];
|
|
107
132
|
}) => Promise<T>;
|
|
133
|
+
list: <T>(params: {
|
|
134
|
+
block_id?: string;
|
|
135
|
+
start_cursor?: string;
|
|
136
|
+
page_size?: number;
|
|
137
|
+
}) => Promise<T>;
|
|
138
|
+
};
|
|
139
|
+
users: {
|
|
140
|
+
list: <T>(params?: {
|
|
141
|
+
start_cursor?: string;
|
|
142
|
+
page_size?: number;
|
|
143
|
+
}) => Promise<T>;
|
|
144
|
+
retrieve: <T>(params: {
|
|
145
|
+
user_id: string;
|
|
146
|
+
}) => Promise<T>;
|
|
147
|
+
me: <T>() => Promise<T>;
|
|
108
148
|
};
|
|
109
149
|
search: <T>(params?: {
|
|
110
150
|
query?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notion-client.d.ts","sourceRoot":"","sources":["../../src/notion-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAM5D,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAC9C,KAAK,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AACtC,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AACxC,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACxD,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAClE,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAC1C,KAAK,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;A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AE,CAAA;QAC3D,IAAI,CAAC,EAAE;YAAE,SAAS,EAAE,WAAW,GAAG,YAAY,CAAC;YAAC,SAAS,EAAE,kBAAkB,CAAA;SAAE,CAAA;QAC/E,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,KAAG,OAAO,CAAC,CAAC,CAAC,CAEb;CACF;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CASjD"}
|
|
@@ -49,6 +49,16 @@ export class NotionClient {
|
|
|
49
49
|
const { page_id, ...body } = params;
|
|
50
50
|
return this.request(`/pages/${page_id}`, { method: 'PATCH', body });
|
|
51
51
|
},
|
|
52
|
+
retrieveProperty: (params) => {
|
|
53
|
+
const { page_id, property_id, ...query } = params;
|
|
54
|
+
return this.request(`/pages/${page_id}/properties/${property_id}`, {
|
|
55
|
+
query: query,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
move: (params) => {
|
|
59
|
+
const { page_id, ...body } = params;
|
|
60
|
+
return this.request(`/pages/${page_id}/move`, { method: 'POST', body });
|
|
61
|
+
},
|
|
52
62
|
};
|
|
53
63
|
// Databases
|
|
54
64
|
databases = {
|
|
@@ -69,6 +79,16 @@ export class NotionClient {
|
|
|
69
79
|
};
|
|
70
80
|
// Blocks
|
|
71
81
|
blocks = {
|
|
82
|
+
retrieve: (params) => {
|
|
83
|
+
return this.request(`/blocks/${params.block_id}`);
|
|
84
|
+
},
|
|
85
|
+
update: (params) => {
|
|
86
|
+
const { block_id, ...body } = params;
|
|
87
|
+
return this.request(`/blocks/${block_id}`, { method: 'PATCH', body });
|
|
88
|
+
},
|
|
89
|
+
delete: (params) => {
|
|
90
|
+
return this.request(`/blocks/${params.block_id}`, { method: 'DELETE' });
|
|
91
|
+
},
|
|
72
92
|
children: {
|
|
73
93
|
list: (params) => {
|
|
74
94
|
const { block_id, ...query } = params;
|
|
@@ -87,6 +107,25 @@ export class NotionClient {
|
|
|
87
107
|
create: (params) => {
|
|
88
108
|
return this.request('/comments', { method: 'POST', body: params });
|
|
89
109
|
},
|
|
110
|
+
list: (params) => {
|
|
111
|
+
return this.request('/comments', {
|
|
112
|
+
query: params,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
// Users
|
|
117
|
+
users = {
|
|
118
|
+
list: (params) => {
|
|
119
|
+
return this.request('/users', {
|
|
120
|
+
query: params,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
retrieve: (params) => {
|
|
124
|
+
return this.request(`/users/${params.user_id}`);
|
|
125
|
+
},
|
|
126
|
+
me: () => {
|
|
127
|
+
return this.request('/users/me');
|
|
128
|
+
},
|
|
90
129
|
};
|
|
91
130
|
// Search
|
|
92
131
|
search = (params) => {
|
|
@@ -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;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;
|
|
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;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAevD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAgDpF"}
|
|
@@ -4,7 +4,9 @@ import { formatResponse, handleError } from '../utils/index.js';
|
|
|
4
4
|
const inputSchema = {
|
|
5
5
|
parent_page_id: z.string().describe('Parent page ID'),
|
|
6
6
|
title: z.array(z.any()).optional().describe('Database title'),
|
|
7
|
-
properties: z
|
|
7
|
+
properties: z
|
|
8
|
+
.record(z.string(), z.any())
|
|
9
|
+
.describe('Property schema (must include one title property)'),
|
|
8
10
|
icon: z.any().optional().describe('Database icon'),
|
|
9
11
|
cover: z.any().optional().describe('Cover image'),
|
|
10
12
|
is_inline: z.boolean().optional().describe('Inline database'),
|
|
@@ -0,0 +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;AAOvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAkBjF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 delete'),
|
|
5
|
+
};
|
|
6
|
+
export function registerDeleteBlock(server, notion) {
|
|
7
|
+
server.registerTool('delete-block', {
|
|
8
|
+
description: 'Delete a block by its ID. The block will be archived (moved to trash). ' +
|
|
9
|
+
'Returns the archived block object.',
|
|
10
|
+
inputSchema,
|
|
11
|
+
}, async ({ block_id }) => {
|
|
12
|
+
try {
|
|
13
|
+
const response = await notion.blocks.delete({ block_id });
|
|
14
|
+
return formatResponse(response);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleError(error);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -6,12 +6,23 @@ import { registerCreateComment } from './create-comment.js';
|
|
|
6
6
|
import { registerCreateDatabase } from './create-database.js';
|
|
7
7
|
import { registerCreatePage } from './create-page.js';
|
|
8
8
|
import { registerCreatePageSimple } from './create-page-simple.js';
|
|
9
|
+
import { registerDeleteBlock } from './delete-block.js';
|
|
9
10
|
import { registerGetBlockChildren } from './get-block-children.js';
|
|
11
|
+
import { registerListComments } from './list-comments.js';
|
|
12
|
+
import { registerListUsers } from './list-users.js';
|
|
13
|
+
import { registerMovePage } from './move-page.js';
|
|
10
14
|
import { registerQueryDatabase } from './query-database.js';
|
|
15
|
+
import { registerRetrieveBlock } from './retrieve-block.js';
|
|
16
|
+
import { registerRetrieveBotUser } from './retrieve-bot-user.js';
|
|
17
|
+
import { registerRetrieveDatabase } from './retrieve-database.js';
|
|
11
18
|
import { registerRetrievePage } from './retrieve-page.js';
|
|
19
|
+
import { registerRetrievePageProperty } from './retrieve-page-property.js';
|
|
20
|
+
import { registerRetrieveUser } from './retrieve-user.js';
|
|
12
21
|
import { registerSearch } from './search.js';
|
|
22
|
+
import { registerUpdateBlock } from './update-block.js';
|
|
23
|
+
import { registerUpdateBlockSimple } from './update-block-simple.js';
|
|
13
24
|
import { registerUpdateDatabase } from './update-database.js';
|
|
14
25
|
import { registerUpdatePage } from './update-page.js';
|
|
15
26
|
export declare function registerAllTools(server: McpServer, notion: NotionClient): void;
|
|
16
|
-
export { registerRetrievePage, registerCreatePage, registerCreatePageSimple, registerUpdatePage, registerCreateDatabase, registerUpdateDatabase, registerQueryDatabase, registerSearch, registerGetBlockChildren, registerAppendBlockChildren, registerAppendBlocksSimple, registerCreateComment, };
|
|
27
|
+
export { registerRetrievePage, registerCreatePage, registerCreatePageSimple, registerUpdatePage, registerRetrievePageProperty, registerMovePage, registerCreateDatabase, registerUpdateDatabase, registerQueryDatabase, registerRetrieveDatabase, registerSearch, registerGetBlockChildren, registerAppendBlockChildren, registerAppendBlocksSimple, registerRetrieveBlock, registerUpdateBlock, registerUpdateBlockSimple, registerDeleteBlock, registerCreateComment, registerListComments, registerListUsers, registerRetrieveUser, registerRetrieveBotUser, };
|
|
17
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM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EACd,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,GACxB,CAAA"}
|
package/dist/src/tools/index.js
CHANGED
|
@@ -4,10 +4,21 @@ import { registerCreateComment } from './create-comment.js';
|
|
|
4
4
|
import { registerCreateDatabase } from './create-database.js';
|
|
5
5
|
import { registerCreatePage } from './create-page.js';
|
|
6
6
|
import { registerCreatePageSimple } from './create-page-simple.js';
|
|
7
|
+
import { registerDeleteBlock } from './delete-block.js';
|
|
7
8
|
import { registerGetBlockChildren } from './get-block-children.js';
|
|
9
|
+
import { registerListComments } from './list-comments.js';
|
|
10
|
+
import { registerListUsers } from './list-users.js';
|
|
11
|
+
import { registerMovePage } from './move-page.js';
|
|
8
12
|
import { registerQueryDatabase } from './query-database.js';
|
|
13
|
+
import { registerRetrieveBlock } from './retrieve-block.js';
|
|
14
|
+
import { registerRetrieveBotUser } from './retrieve-bot-user.js';
|
|
15
|
+
import { registerRetrieveDatabase } from './retrieve-database.js';
|
|
9
16
|
import { registerRetrievePage } from './retrieve-page.js';
|
|
17
|
+
import { registerRetrievePageProperty } from './retrieve-page-property.js';
|
|
18
|
+
import { registerRetrieveUser } from './retrieve-user.js';
|
|
10
19
|
import { registerSearch } from './search.js';
|
|
20
|
+
import { registerUpdateBlock } from './update-block.js';
|
|
21
|
+
import { registerUpdateBlockSimple } from './update-block-simple.js';
|
|
11
22
|
import { registerUpdateDatabase } from './update-database.js';
|
|
12
23
|
import { registerUpdatePage } from './update-page.js';
|
|
13
24
|
export function registerAllTools(server, notion) {
|
|
@@ -16,17 +27,29 @@ export function registerAllTools(server, notion) {
|
|
|
16
27
|
registerCreatePage(server, notion);
|
|
17
28
|
registerCreatePageSimple(server, notion);
|
|
18
29
|
registerUpdatePage(server, notion);
|
|
30
|
+
registerRetrievePageProperty(server, notion);
|
|
31
|
+
registerMovePage(server, notion);
|
|
19
32
|
// Database operations
|
|
20
33
|
registerCreateDatabase(server, notion);
|
|
21
34
|
registerUpdateDatabase(server, notion);
|
|
22
35
|
registerQueryDatabase(server, notion);
|
|
36
|
+
registerRetrieveDatabase(server, notion);
|
|
23
37
|
// Search
|
|
24
38
|
registerSearch(server, notion);
|
|
25
39
|
// Block operations
|
|
26
40
|
registerGetBlockChildren(server, notion);
|
|
27
41
|
registerAppendBlockChildren(server, notion);
|
|
28
42
|
registerAppendBlocksSimple(server, notion);
|
|
43
|
+
registerRetrieveBlock(server, notion);
|
|
44
|
+
registerUpdateBlock(server, notion);
|
|
45
|
+
registerUpdateBlockSimple(server, notion);
|
|
46
|
+
registerDeleteBlock(server, notion);
|
|
29
47
|
// Comment operations
|
|
30
48
|
registerCreateComment(server, notion);
|
|
49
|
+
registerListComments(server, notion);
|
|
50
|
+
// User operations
|
|
51
|
+
registerListUsers(server, notion);
|
|
52
|
+
registerRetrieveUser(server, notion);
|
|
53
|
+
registerRetrieveBotUser(server, notion);
|
|
31
54
|
}
|
|
32
|
-
export { registerRetrievePage, registerCreatePage, registerCreatePageSimple, registerUpdatePage, registerCreateDatabase, registerUpdateDatabase, registerQueryDatabase, registerSearch, registerGetBlockChildren, registerAppendBlockChildren, registerAppendBlocksSimple, registerCreateComment, };
|
|
55
|
+
export { registerRetrievePage, registerCreatePage, registerCreatePageSimple, registerUpdatePage, registerRetrievePageProperty, registerMovePage, registerCreateDatabase, registerUpdateDatabase, registerQueryDatabase, registerRetrieveDatabase, registerSearch, registerGetBlockChildren, registerAppendBlockChildren, registerAppendBlocksSimple, registerRetrieveBlock, registerUpdateBlock, registerUpdateBlockSimple, registerDeleteBlock, registerCreateComment, registerListComments, registerListUsers, registerRetrieveUser, registerRetrieveBotUser, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-comments.d.ts","sourceRoot":"","sources":["../../../src/tools/list-comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA6BvD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA6ClF"}
|
|
@@ -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
|
+
}
|