Add page-as-Markdown tools (retrieve + update)#320
Merged
Conversation
2 tasks
vshen-notion
approved these changes
Jun 17, 2026
da1bdc9 to
eb9a0eb
Compare
Adds two tools from the public Notion API that fit agentic clients and
were missing from the spec:
- retrieve-page-markdown (GET /v1/pages/{page_id}/markdown)
- update-page-markdown (PATCH /v1/pages/{page_id}/markdown)
They read/write page content as enhanced Markdown instead of block JSON,
which is far more token-efficient for LLMs.
These endpoints require Notion-Version 2026-03-11 while the rest of the
API stays on 2025-09-03, so Notion-Version is now sourced per operation
from the OpenAPI spec: HttpClient applies each operation's header-param
default (resolving $refs), an explicitly-configured Notion-Version still
wins, the proxy no longer hardcodes it, and the parser no longer exposes
header params as model-visible tool inputs.
Also hardens the server-based integration tests against flakiness
(root cause, not retries): a shared startTestServer/stopTestServer helper
binds an ephemeral port (0), awaits the `listening` event before issuing
requests, awaits full shutdown, and uses 127.0.0.1 to avoid localhost
IPv4/IPv6 mismatch. This removes the intermittent ECONNRESET / "socket
hang up" failures from random-port collisions and request-before-bind
races.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eb9a0eb to
1be339c
Compare
Contributor
Author
|
Added a root-cause fix for the flaky server-based integration tests (was intermittently failing CI with Three real races, now fixed via a shared
Verified with 5 consecutive local full-suite runs (89/89 each). This touches |
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
Adds the two page-content-as-Markdown endpoints from the public Notion API, which were missing from the spec and are the highest-value additions for agentic/MCP clients:
retrieve-page-markdown/v1/pages/{page_id}/markdownupdate-page-markdown/v1/pages/{page_id}/markdownThese read/write page content as enhanced Markdown instead of block JSON — far more token-efficient for LLMs (the README already advertises "editing pages in Markdown"; this makes it literally true via the dedicated endpoints).
update-page-markdownsupportsreplace_content(overwrite whole page),update_content(targeted find-and-replace, up to 100 edits), and the deprecatedinsert_content/replace_content_rangevariants.The version problem & how it's solved
The markdown endpoints require
Notion-Version: 2026-03-11, but the rest of the API is on2025-09-03. A global bump to2026-03-11is genuinely breaking (archived→in_trash, append-childrenafter→position,transcription→meeting_notes) and would be a separate migration. Instead, this PR makesNotion-Versionper-operation, sourced from the spec:HttpClientnow applies each operation'sNotion-Versionheader-parameterdefaultas a real request header (resolving$ref'd params). Markdown ops pin2026-03-11; everything else stays2025-09-03. An explicitly-configuredNotion-Version(viaOPENAPI_MCP_HEADERS) still takes precedence.proxy.tsno longer hardcodesNotion-Versionfor theNOTION_TOKENpath — it comes from the spec.parser.tsno longer exposesheaderparams as model-visible tool inputs. PreviouslyNotion-Versionappeared (inertly) on 21 of 22 tools as schema noise; now 0.Tests
http-client.headers.test.ts— per-operation version injection + user-override precedence.notion-markdown-tools.test.ts— markdown tools generate with correct inputs and noNotion-Versionleakage, against the real spec.Notes for review
Notion-Versionin the per-request headers, which would suppress the per-op default for markdown. When both land, reconcile by having Per-request Notion token passthrough for HTTP transport #315 omitNotion-Version(same fix applied here to theNOTION_TOKENpath) so the spec drives it.🤖 Generated with Claude Code