Commit 00f82e1
notion: AI-optimize MCP actions (flatten schemas, consolidate, enrich descriptions) (#21274)
* notion: AI-optimize MCP actions (flatten schemas, consolidate, enrich descriptions)
Modernize the Notion action set for MCP/LLM use (11 tools):
- Flatten additionalProps/reloadProps to static schemas: create-page,
update-page, append-block, create-database, update-database
- Consolidate create-page + create-page-from-database into Create Page
(parent accepts a page or data-source ID; Markdown content)
- Consolidate retrieve-page + retrieve-block into Get Page
(returns properties + Markdown content)
- Rewrite search standalone; compact results; document the 2025-09-03
data-sources model and the ID-resolution role
- query-database: omit empty filter/sorts (Notion API rejects null),
correct readOnlyHint to true
- Behavioral descriptions with bold cross-references; accept ID or URL
- Shared helpers in common/utils.mjs: extractNotionId,
parsePropertiesObject, normalizeDatabaseSchema
- Bump @pipedream/notion 1.0.11 -> 1.0.12
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* notion: bump versions of components depending on common/utils.mjs
The version-check CI requires every component whose (transitive)
dependencies changed to bump its version. These 9 legacy actions pull in
common/utils.mjs via base-page-builder, so bump their patch versions.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* notion: address CodeRabbit review
- base-page-builder `_filterProps`: check key presence instead of
truthiness so valid falsy property values (0, false, "") are preserved
instead of silently dropped (affects create-page / update-page).
- create-page: narrow the parent-type probe catch to 404/object_not_found
only — re-throw auth/permission/rate-limit/network errors instead of
falling through to the page path; chunk subpage Markdown into
MAX_BLOCKS appends like the data-source path.
- query-database: `sorts` is now a JSON string (was string[], which
contradicted the description); add `start_cursor` pagination; fix the
doc-link text to "[See the documentation]".
- search: add `start_cursor` pagination.
- append-block: inline Markdown example on `content`.
- create-comment: show the expected `discussionId` format inline.
- utils: `parsePropertiesObject` / `normalizeDatabaseSchema` now reject
non-object JSON (arrays/strings/null) with a clear error instead of
forwarding invalid payloads to Notion.
- Version bumps for breaking prop-contract changes (major): search 1.0.0,
create-page 1.0.0, append-block 1.0.0, create-database 1.0.0,
update-database 2.0.0, update-page 3.0.0; package.json -> 2.0.0.
Re-validated: 11/11 evals pass, all 11 tools exercised.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* notion: fix query-database empty-filter bug; sharpen create-page,
update-block, duplicate-page descriptions for AI agents
One real bug and three description fixes, all surfaced by running the
eval suite against this PR.
1. (BUG) `query-database`: when the caller omitted `filter`, the action
ended up sending `filter: {}` (empty object), which the data-source
query API rejects with "body.filter.or should be defined, body.filter.and
should be defined, ...". Root cause: the previous code called
`parseStringToJSON(filter, undefined)` to coerce the absent filter to
`undefined`, but `parseStringToJSON` has `defaultValue = {}` as a
default parameter — passing `undefined` as the second arg activates
that default and returns `{}`. Replace the call with an explicit
`typeof filter === "string" && filter.length > 0` check that defaults
to a `{ and: [] }` no-op when the caller hasn't provided a filter, so
"omit filter to return all rows" actually works.
Tighten the prop description as well: spell out that a single-condition
filter MUST include both a `property` key and a type-specific operator
(`title`, `rich_text`, `select`, …), and point the caller at Retrieve
Database Schema for the exact column names. AI agents were repeatedly
building partial filters like `{ "title": { "contains": "..." } }` with
no `property`, which the API also rejects.
2. (DESCRIPTION) `update-block`: the terse "Updates a child block object"
description was getting picked up for "update a page's properties"
and "append content to a page" — both of which are properly handled
by Update Page and Append Block respectively. Rewrite to call out
what this tool does NOT do and which tool to use instead, so the
model stops reaching for it for page-level operations.
3. (DESCRIPTION) `duplicate-page`: the previous name + "Create a new page
copied from an existing page block" description made this tool look
like a general-purpose page creator. Rename to "Copy Page From
Template" and rewrite the description to make the template-copy
semantics unambiguous: this tool reuses an existing page's structure,
and for brand-new content the caller should use Create Page.
4. (DESCRIPTION) `create-page`: previous parent description said "use
Search to resolve a name into an ID", but agents were still passing
bare strings like `"root"` or `"workspace"` and getting opaque UUID
validation errors. Make the description very explicit about the value
being a UUID (or a Notion URL containing one), and call out the
common non-UUID placeholders the API will reject.
Validated against the project's MCP eval harness: pass rate moved from
~30% to ~90% across the 20-eval Notion suite after these changes
together with the eval-side fixes (Notion-Version header forwarding and
verifier-block adjustments) that live in the eval-monster repo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* notion: document timestamp filter shape in query-database
The previous filter description claimed every single-condition filter
"MUST include both a `property` key and a type-specific operator key"
— that's true for property filters but wrong for timestamp filters,
which use a top-level `timestamp` key set to `created_time` or
`last_edited_time` (no `property` at all). Agents that read the old
description tried to wedge a `property` into timestamp filters and the
API rejected them.
Rewrite the description to document both single-condition shapes
explicitly:
- **Property filter** (unchanged guidance): `{ property, <type>: { <op>: ... } }`.
- **Timestamp filter** (new): `{ timestamp: "created_time" | "last_edited_time", <same key>: { <op>: ... } }` — note the lack of `property`.
Example added: `{ "timestamp": "created_time", "created_time": { "past_week": {} } }`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Michelle Bergeron <michelle.bergeron@workday.com>
Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>1 parent d7e7a92 commit 00f82e1
22 files changed
Lines changed: 572 additions & 422 deletions
File tree
- components/notion
- actions
- append-block
- common
- complete-file-upload
- create-comment
- create-database
- create-file-upload
- create-page-from-database
- create-page
- delete-block
- duplicate-page
- list-file-uploads
- query-database
- retrieve-database-schema
- retrieve-file-upload
- retrieve-page
- search
- send-file-upload
- update-block
- update-database
- update-page
- common
Lines changed: 30 additions & 107 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
63 | 30 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
69 | 35 | | |
70 | 36 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | 37 | | |
85 | | - | |
86 | | - | |
| 38 | + | |
| 39 | + | |
87 | 40 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 41 | + | |
122 | 42 | | |
123 | 43 | | |
124 | 44 | | |
125 | 45 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
131 | 52 | | |
132 | | - | |
133 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
134 | 57 | | |
135 | 58 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 17 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 21 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | | - | |
| 30 | + | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | | - | |
| 36 | + | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | | - | |
48 | | - | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
Lines changed: 17 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | | - | |
10 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 41 | + | |
75 | 42 | | |
76 | 43 | | |
77 | 44 | | |
78 | 45 | | |
79 | | - | |
| 46 | + | |
80 | 47 | | |
81 | 48 | | |
82 | 49 | | |
| |||
91 | 58 | | |
92 | 59 | | |
93 | 60 | | |
94 | | - | |
| 61 | + | |
95 | 62 | | |
96 | 63 | | |
97 | 64 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments