Skip to content

Keep the preview flag out of the MCP tools - #5

Merged
afternoon merged 1 commit into
mainfrom
claude/named-files-auto-save-x3k4vf
Aug 31, 2026
Merged

afternoon merged 1 commit into
mainfrom
claude/named-files-auto-save-x3k4vf

Conversation

@afternoon

Copy link
Copy Markdown
Owner

Follow-up to the auto-save work in #3, which landed alongside the MCP surface from #2.

The problem the merge created

Auto-save added capturePreview to UpdateDocumentSchema. The MCP update_document tool takes that same object as its input schema:

inputSchema: UpdateDocumentSchema.extend(DocumentIdSchema.shape),

Neither branch conflicted with the other, so on main an agent is now asked to fill in a flag that exists to pace a browser against a stream of keystrokes. An agent writes a document at a time — it has no pacing problem, and the field is a question with no meaning on that surface.

The fix

capturePreview moves to UpdateDocumentRequestSchema, which only the HTTP route parses. The content schema goes back to being the content, and the tool's inputs are id, html, css again. No behaviour changes for either caller.

Tests

  • src/server/mcpServer.test.ts now asserts the fields update_document asks for. Verified it fails on main's schema (expected [ 'capturePreview', 'css', …(2) ] to deeply equal [ 'css', 'html', 'id' ]) and passes with the split — this reached the MCP surface by being added somewhere that looked unrelated to it, so the assertion is the guard against it happening again.
  • Expose the document API to agents over MCP #2's cloudflare:workers stub makes route handlers reachable from a unit test for the first time, so both halves of the preview split are now covered against the real queries and the real migrations: POST /api/documents/:id/thumbnail (renders the stored content, 204 when the revision already has a capture, 404 — and no capture queued — for someone else's document) and PUT (captures by default, quiet only when asked).

bun run test (431 unit + 12 e2e), bun run check and bun run build all clean.


Generated by Claude Code

`capturePreview` was added to `UpdateDocumentSchema`, and the MCP
`update_document` tool takes that object as its input schema directly — so
an agent is now asked to fill in a flag that exists to pace a browser
against a stream of keystrokes. An agent writes a document at a time and
has no such problem; the field is a question with no meaning on that
surface.

It moves to `UpdateDocumentRequestSchema`, which only the HTTP route
parses. The content schema goes back to being the content, and the tool's
inputs are `id`, `html` and `css` again — asserted now, since this reached
the MCP surface by being added somewhere that looked unrelated to it.

Main's `cloudflare:workers` stub makes the route handlers reachable from a
unit test, so both halves of the preview split are covered too: what the
new POST renders and for whom, and that a save captures unless it is asked
not to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MTqa7LTmuJMFEmNohAka5n
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
htmlcsspdf e54ce78 Commit Preview URL

Branch Preview URL
Aug 31 2026, 09:06 PM

@afternoon
afternoon marked this pull request as ready for review August 31, 2026 21:22
@afternoon
afternoon merged commit 7d37ad4 into main Aug 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants