notion-mcp-server 1.0.1 → 2.4.2

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.
Files changed (99) hide show
  1. package/README.md +383 -192
  2. package/build/config/index.js +3 -1
  3. package/build/dispatch/concurrency.js +15 -0
  4. package/build/dispatch/idempotency.js +38 -0
  5. package/build/dispatch/index.js +175 -0
  6. package/build/dispatch/rate-limit.js +56 -0
  7. package/build/dispatch/retry.js +97 -0
  8. package/build/index.js +1 -1
  9. package/build/markdown/parse.js +265 -0
  10. package/build/operations/blocks.js +331 -0
  11. package/build/operations/comments.js +191 -0
  12. package/build/operations/data-sources.js +85 -0
  13. package/build/operations/databases.js +345 -0
  14. package/build/operations/files.js +239 -0
  15. package/build/operations/index.js +19 -0
  16. package/build/operations/pages.js +486 -0
  17. package/build/operations/registry.js +16 -0
  18. package/build/operations/users.js +101 -0
  19. package/build/prompts/index.js +105 -0
  20. package/build/schema/blocks.js +19 -138
  21. package/build/schema/database.js +27 -111
  22. package/build/schema/emit.js +68 -0
  23. package/build/schema/file.js +1 -1
  24. package/build/schema/filter-dsl.js +333 -0
  25. package/build/schema/icon.js +1 -1
  26. package/build/schema/page-properties.js +17 -3
  27. package/build/schema/page.js +12 -125
  28. package/build/schema/refs.js +16 -0
  29. package/build/schema/rich-text.js +1 -1
  30. package/build/server/index.js +16 -3
  31. package/build/services/auth.js +19 -0
  32. package/build/services/notion.js +14 -17
  33. package/build/tools/index.js +119 -21
  34. package/build/utils/error.js +125 -86
  35. package/build/utils/handler.js +11 -0
  36. package/build/utils/learning-error.js +40 -0
  37. package/build/utils/notion-types.js +16 -0
  38. package/build/utils/paginate.js +35 -0
  39. package/build/utils/schema-slice.js +156 -0
  40. package/build/utils/slim.js +269 -0
  41. package/package.json +13 -7
  42. package/build/resources/imageList.js +0 -62
  43. package/build/resources/index.js +0 -1
  44. package/build/resources/predictionList.js +0 -43
  45. package/build/resources/svgList.js +0 -69
  46. package/build/schema/comments.js +0 -60
  47. package/build/schema/notion.js +0 -57
  48. package/build/schema/richText.js +0 -757
  49. package/build/schema/tools.js +0 -17
  50. package/build/schema/users.js +0 -39
  51. package/build/services/loggs.js +0 -13
  52. package/build/services/replicate.js +0 -23
  53. package/build/tools/appendBlockChildren.js +0 -25
  54. package/build/tools/batchAppendBlockChildren.js +0 -33
  55. package/build/tools/batchDeleteBlocks.js +0 -32
  56. package/build/tools/batchMixedOperations.js +0 -58
  57. package/build/tools/batchUpdateBlocks.js +0 -33
  58. package/build/tools/blocks.js +0 -34
  59. package/build/tools/comments.js +0 -81
  60. package/build/tools/createDatabase.js +0 -18
  61. package/build/tools/createPage.js +0 -18
  62. package/build/tools/createPrediction.js +0 -28
  63. package/build/tools/database.js +0 -16
  64. package/build/tools/deleteBlock.js +0 -24
  65. package/build/tools/formatRichText.js +0 -83
  66. package/build/tools/generateImage.js +0 -48
  67. package/build/tools/generateImageVariants.js +0 -105
  68. package/build/tools/generateMultipleImages.js +0 -60
  69. package/build/tools/generateSVG.js +0 -43
  70. package/build/tools/getPrediction.js +0 -22
  71. package/build/tools/pages.js +0 -22
  72. package/build/tools/predictionList.js +0 -30
  73. package/build/tools/queryDatabase.js +0 -22
  74. package/build/tools/retrieveBlock.js +0 -24
  75. package/build/tools/retrieveBlockChildren.js +0 -32
  76. package/build/tools/searchPage.js +0 -24
  77. package/build/tools/updateBlock.js +0 -25
  78. package/build/tools/updateDatabase.js +0 -18
  79. package/build/tools/updatePage.js +0 -40
  80. package/build/tools/updatePageProperties.js +0 -21
  81. package/build/tools/users.js +0 -75
  82. package/build/types/blocks.js +0 -12
  83. package/build/types/comments.js +0 -7
  84. package/build/types/database.js +0 -6
  85. package/build/types/notion.js +0 -1
  86. package/build/types/page.js +0 -8
  87. package/build/types/richText.js +0 -1
  88. package/build/types/tools.js +0 -1
  89. package/build/types/users.js +0 -6
  90. package/build/utils/blob.js +0 -5
  91. package/build/utils/image.js +0 -34
  92. package/build/utils/index.js +0 -1
  93. package/build/utils/richText.js +0 -174
  94. package/build/validation/blocks.js +0 -568
  95. package/build/validation/notion.js +0 -51
  96. package/build/validation/page.js +0 -262
  97. package/build/validation/richText.js +0 -744
  98. package/build/validation/tools.js +0 -16
  99. /package/build/{types/index.js → operations/types.js} +0 -0
@@ -1,60 +0,0 @@
1
- import { z } from "zod";
2
- import { RICH_TEXT_ITEM_REQUEST_SCHEMA } from "./rich-text.js";
3
- import { preprocessJson } from "./preprocess.js";
4
- // Schema for getting comments
5
- export const GET_COMMENTS_SCHEMA = {
6
- block_id: z
7
- .string()
8
- .describe("The ID of the block or page to get comments from"),
9
- start_cursor: z
10
- .string()
11
- .optional()
12
- .describe("The cursor to start from for pagination"),
13
- page_size: z
14
- .number()
15
- .optional()
16
- .describe("Number of comments to return per page"),
17
- };
18
- // Schema for adding a comment to a page
19
- export const ADD_PAGE_COMMENT_SCHEMA = {
20
- parent: z.object({
21
- page_id: z.string().describe("The ID of the page to add the comment to"),
22
- }),
23
- rich_text: z
24
- .array(RICH_TEXT_ITEM_REQUEST_SCHEMA)
25
- .describe("Rich text content for the comment"),
26
- };
27
- // Schema for adding a comment to a discussion
28
- export const ADD_DISCUSSION_COMMENT_SCHEMA = {
29
- discussion_id: z
30
- .string()
31
- .describe("The ID of the discussion to add the comment to"),
32
- rich_text: z
33
- .array(RICH_TEXT_ITEM_REQUEST_SCHEMA)
34
- .describe("Rich text content for the comment"),
35
- };
36
- // Combined schema for all comment operations
37
- export const COMMENTS_OPERATION_SCHEMA = {
38
- payload: z
39
- .preprocess(preprocessJson, z.discriminatedUnion("action", [
40
- z.object({
41
- action: z
42
- .literal("get_comments")
43
- .describe("Use this action to get comments from a block or page."),
44
- params: z.object(GET_COMMENTS_SCHEMA),
45
- }),
46
- z.object({
47
- action: z
48
- .literal("add_page_comment")
49
- .describe("Use this action to add a comment to a page."),
50
- params: z.object(ADD_PAGE_COMMENT_SCHEMA),
51
- }),
52
- z.object({
53
- action: z
54
- .literal("add_discussion_comment")
55
- .describe("Use this action to add a comment to a discussion."),
56
- params: z.object(ADD_DISCUSSION_COMMENT_SCHEMA),
57
- }),
58
- ]))
59
- .describe("A union of all possible comment operations. Each operation has a specific action and corresponding parameters. Use this schema to validate the input for comment operations such as getting, adding to page, and adding to discussion. Available actions include: 'get_comments', 'add_page_comment', and 'add_discussion_comment'. Each operation requires specific parameters as defined in the corresponding schemas."),
60
- };
@@ -1,57 +0,0 @@
1
- // import { z } from "zod";
2
- // import { richTextSchema } from "./richText.js";
3
- export {};
4
- // export const parentSchema = z
5
- // .object({
6
- // type: z.enum(["page_id", "database_id"]),
7
- // page_id: z.string().optional(),
8
- // database_id: z.string().optional(),
9
- // })
10
- // .refine(
11
- // (data) => {
12
- // if (data.type === "page_id" && !data.page_id) return false;
13
- // if (data.type === "database_id" && !data.database_id) return false;
14
- // return true;
15
- // },
16
- // {
17
- // message:
18
- // "page_id must be provided when type is page_id, database_id must be provided when type is database_id",
19
- // }
20
- // );
21
- // export const pageParentPropertiesSchema = z.object({
22
- // title: z.object({
23
- // title: richTextSchema,
24
- // }),
25
- // });
26
- // export const databaseParentPropertiesSchema = z.record(
27
- // z.string(),
28
- // z.union([
29
- // z.object({ title: richTextSchema }),
30
- // z.object({ rich_text: richTextSchema }),
31
- // z.object({ number: z.number().optional().nullable() }),
32
- // z.object({ select: z.object({ name: z.string() }).optional().nullable() }),
33
- // z.object({
34
- // multi_select: z.array(z.object({ name: z.string() })).optional(),
35
- // }),
36
- // z.object({
37
- // date: z
38
- // .object({
39
- // start: z.string(),
40
- // end: z.string().optional(),
41
- // time_zone: z.string().optional(),
42
- // })
43
- // .optional()
44
- // .nullable(),
45
- // }),
46
- // z.object({ checkbox: z.boolean().optional() }),
47
- // z.object({ url: z.string().url().optional().nullable() }),
48
- // z.object({ email: z.string().email().optional().nullable() }),
49
- // z.object({ phone_number: z.string().optional().nullable() }),
50
- // ])
51
- // );
52
- // export const blockSchema = z
53
- // .object({
54
- // object: z.literal("block"),
55
- // type: z.string(),
56
- // })
57
- // .and(z.record(z.string(), z.any()));