Skip to content

feat(mcp): publish json and code surfaces over MCP#142

Merged
benvinegar merged 1 commit into
mainfrom
fix/mcp-json-code-parts
Jun 25, 2026
Merged

feat(mcp): publish json and code surfaces over MCP#142
benvinegar merged 1 commit into
mainfrom
fix/mcp-json-code-parts

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

The json and code surface kinds have been publishable over the CLI and REST since they were added, but they were never added to the MCP tool schemas — so MCP agents couldn't publish them and the tool descriptions claimed they didn't exist. This closes that tier-parity gap and adds a structural guard so it can't recur.

Surfaced by a code review of main; the fix was rebased onto #140's post/surface wire-vocabulary rename.

Changes

  • mcpSpec.ts — add json and code to the HTTP JSON-Schema enum and the stdio zod enum (now derived, see below), add their field schemas (data for json; code/language/lineStart for code — title already existed), and refresh the prose in MCP_INSTRUCTIONS, MCP_SURFACES_DESCRIPTION, the publish_post/deprecated-alias tool descriptions, and the surface schema's .describe().
  • types.ts — introduce a canonical SURFACE_KINDS tuple as the single source of truth; SurfaceKind now derives from it.

How we avoid this regression again

The kind list previously lived in four hand-maintained places (the SurfaceKind type, the runtime validator, and two MCP enums) that drifted independently. Now:

  1. The enums can't drift — both MCP kind enums are derived from SURFACE_KINDS ([...SURFACE_KINDS]), so adding a kind to the type adds it to MCP automatically. This is the exact failure that happened, structurally eliminated.
  2. The per-kind fields can't silently lag — those schemas are still hand-written (json needs data, code needs code/language), so test/mcpSpec.test.ts publishes a minimal example of every SURFACE_KINDS member through the real stdio publish schema and the runtime validator, and asserts the advertised HTTP enum equals SURFACE_KINDS. Verified the guard fails (2 failed) when json/code are removed.

Validation

  • npm run typecheck ✅ (node + workers + viewer)
  • npm test ✅ 261 passing (incl. 5 new guards)
  • npm run lint ✅ · npm run format:check
  • Changeset: patch

🤖 Generated with Claude Code

The `json` and `code` part kinds were publishable over the CLI and REST
but never added to the MCP tool schemas, so MCP agents could not publish
them and the tool descriptions claimed they did not exist.

Add both kinds to the HTTP JSON-Schema and stdio zod `kind` enums and
document their fields (`data`; `code`/`language`/`lineStart`).

To prevent the part-kind list from drifting between tiers again, derive
the `SurfaceKind` type and both MCP enums from one canonical
`SURFACE_KINDS` list in server/types.ts, and add test/mcpSpec.test.ts,
which asserts every kind round-trips through the MCP schema and the
runtime validator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@benvinegar benvinegar merged commit faa1322 into main Jun 25, 2026
9 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.

1 participant