Skip to content

feat(mcp): expose blocks.delete/deleteRange via superdoc_edit#3587

Draft
jacobjove wants to merge 1 commit into
superdoc-dev:mainfrom
jacobjove:feature/mcp-expose-blocks-delete
Draft

feat(mcp): expose blocks.delete/deleteRange via superdoc_edit#3587
jacobjove wants to merge 1 commit into
superdoc-dev:mainfrom
jacobjove:feature/mcp-expose-blocks-delete

Conversation

@jacobjove
Copy link
Copy Markdown

@jacobjove jacobjove commented May 30, 2026

Summary

Wires the existing document-api blocks.delete / blocks.deleteRange ops into the MCP tool surface as two new superdoc_edit actions — delete_block and delete_block_range — so an MCP client can remove an entire block node, not just its text. Closes the gap where deleting a heading/paragraph's text leaves an empty container that still renders as block spacing.

Proposed in #3586 (surface options A/B/C discussed there). This PR implements option A.

What changed

  • Contract (packages/document-api/src/contract/operation-definitions.ts): intentGroup:'edit' + intentAction:'delete_block' on blocks.delete; intentGroup:'edit' + intentAction:'delete_block_range' on blocks.deleteRange; one disambiguation sentence and one inputExample in INTENT_GROUP_META.edit.
  • Regenerated via pnpm run generate:all: apps/mcp/src/generated/{catalog,intent-dispatch.generated}.ts, packages/sdk/langs/browser/src/intent-dispatch.ts, packages/sdk/tools/intent_dispatch_generated.py.
  • Tests (apps/mcp/src/__tests__/protocol.test.ts): action-enum assertion plus three end-to-end cases asserting physical block removal (block-count decrement + nodeId absence) — one demonstrating the text-delete-leaves-empty-container bug vs delete_block removing it, and one asserting delete_block_range removes a contiguous top-level span (deletedCount + spanned nodeIds absent, with a neighbor outside the range surviving so the delete is proven bounded).

Addressing

delete (existing) takes a text ref; delete_block takes target:{kind:'block',nodeType,nodeId}; delete_block_range takes start/end (each a {kind:'block',nodeType,nodeId} top-level block, inclusive). The delete_block name is forced by the existing delete collision in the edit group.

Verification

apps/mcp 41 pass (4 new) · document-api 1480 pass (blocks + contract-parity) · conformance 1198 pass · codegen incl. cross-lang-parity (Node↔Python) 57 pass · typecheck 0 new errors vs baseline.

Limitations

Wire the existing document-api blocks.delete / blocks.deleteRange ops
into the MCP tool surface as superdoc_edit actions delete_block and
delete_block_range, so clients can remove an entire block node, not
just its text content. Deleting a heading/paragraph's text previously
left an empty container behind, still rendering as block spacing.

Regenerates the MCP catalog and intent-dispatch (Node, browser,
Python) and adds end-to-end protocol tests proving physical block
removal (block-count decrement + nodeId absence).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jacobjove jacobjove force-pushed the feature/mcp-expose-blocks-delete branch from 4c75ffe to b36f627 Compare May 30, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant