fix: correct children items schema in POST /v1/pages to use blockObjectRequest ref#242
Open
4444J99 wants to merge 1 commit into
Open
fix: correct children items schema in POST /v1/pages to use blockObjectRequest ref#2424444J99 wants to merge 1 commit into
4444J99 wants to merge 1 commit into
Conversation
The OpenAPI spec for POST /v1/pages declared children.items as
{type: "string"} instead of {$ref: "#/components/schemas/blockObjectRequest"},
causing MCP clients to serialize block objects as strings rather than
structured objects. This is inconsistent with the PATCH /v1/blocks/{block_id}/children
endpoint which correctly uses the $ref.
Fixes makenotion#82
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Gentle ping — this fixes the |
8 tasks
Author
|
Hi — following up on this. The fix corrects the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAPI spec for
POST /v1/pagesdeclareschildren.itemsas{"type": "string"}, while the equivalentPATCH /v1/blocks/{block_id}/childrenendpoint correctly uses{"$ref": "#/components/schemas/blockObjectRequest"}. This inconsistency causes MCP clients to treat block objects as plain strings, producing"Expected object, received string"validation errors when creating pages with content blocks.Root cause: A single incorrect type declaration in
scripts/notion-openapi.jsonat thePOST /v1/pagesendpoint'schildrenproperty.Fix: Replace
{"type": "string"}with{"$ref": "#/components/schemas/blockObjectRequest"}to match the schema already used byPATCH /v1/blocks/{block_id}/children.Changes
scripts/notion-openapi.json— Fixchildren.itemstype fromstringto$ref: blockObjectRequestin thePOST /v1/pagesschemasrc/openapi-mcp-server/openapi/__tests__/parser.test.ts— Add tests verifyingchildrenitems use$ref(notstring) and both page-creation and block-append endpoints produce matching schema structuressrc/openapi-mcp-server/mcp/__tests__/proxy.test.ts— Add test for full-array stringification deserialization (entirechildrenarray arriving as a JSON string)Context
This interacts with two existing defenses already in the codebase:
deserializeParams()inproxy.ts(from fix: handle double-serialized JSON parameters from MCP clients #180) handles runtime recovery when clients double-serialize parameterswithStringFallback()inparser.tswraps complex schemas withanyOf: [schema, {type: "string"}]to accept stringified inputThis PR fixes the schema declaration so clients receive correct type information upfront, reducing reliance on the runtime workarounds above.
Fixes #82
Test plan
tsc --noEmit)createPageandappendBlockChildrenproduce matchingchildrenschema structurechildren.itemsis not typed as plainstringchildrenas JSON string) is deserialized correctly