Skip to content

feat(serveapi): #498 Lane B M2 — request-scoped MCP adapter and frozen wire envelopes - #592

Merged
sunholo-voight-kampff merged 2 commits into
devfrom
sprint/m-mcp-exact-tool-surface-lane-b-m2
Aug 5, 2026
Merged

feat(serveapi): #498 Lane B M2 — request-scoped MCP adapter and frozen wire envelopes#592
sunholo-voight-kampff merged 2 commits into
devfrom
sprint/m-mcp-exact-tool-surface-lane-b-m2

Conversation

@sunholo-voight-kampff

Copy link
Copy Markdown
Collaborator

M2 of M-MCP-EXACT-TOOL-SURFACE-LANE-B (sprint plan: design_docs/planned/v1_0_0/m-mcp-exact-tool-surface-lane-b-sprint-plan.md).

serveapi.Server.MCPHandler() now serves a stateless, request-scoped MCP surface built per authorized request from caller-supplied descriptors — no ambient submit_feedback, exact A/B surfaces, frozen -32603 callback envelopes (timeout / capacity / cancel), 401/403 for typed authorization errors, and a recover() backstop mapping SDK AddTool panics to the frozen envelope while the gateway rejects every known-invalid descriptor class loudly (§0.5 both halves).

  • Executor: codex gpt-5.6-sol (sandboxed, snapshot protocol) · Controller re-ran all gates outside the sandbox: go test ./internal/apiserver ./serveapi rc=0, full go test ./... rc=0, gofmt/vet clean.
  • Mutations: 3 controller + 2 evaluator, all red with byte-identical reverts. One executor-shipped weak assertion found and fixed: the AC5 test originally could not distinguish gateway validation from the recover backstop (the validation-removed mutant survived); it now asserts the gateway's specific rejection messages.
  • Evaluator: sonnet, PASS 94/100 round 1, zero blocking. NB-1 (overload envelope HTTP 200 assertion) reproduced and applied as 811ac16b4.

Refs #498

🤖 Generated with Claude Code

sunholo-voight-kampff and others added 2 commits August 5, 2026 09:05
…n wire envelopes

M2 of M-MCP-EXACT-TOOL-SURFACE-LANE-B: serveapi.Server.MCPHandler() now serves
a stateless, request-scoped MCP surface built per authorized request from
caller-supplied descriptors.

- internal/apiserver/embedded_mcp.go (NEW): wrapper handler per the pinned
  architecture — bounded body read (4<<20 cap), JSON-RPC id decode,
  ResolveSession -> Tools -> gateway validation, frozen -32603 envelopes for
  callback timeout/capacity/cancel, 401/403 for typed authorization errors,
  recover() backstop mapping SDK AddTool panics to the frozen envelope,
  per-request *mcp.Server via StreamableHTTPOptions{Stateless: true}.
- internal/apiserver/authorized_surface.go: validateToolDescriptor gains the
  x-mcp-header parameter-annotation check (SDK panic class 5, plan §0.5a) —
  invalid descriptors are rejected loudly at the gateway, never silently
  absorbed by the recover backstop.
- internal/apiserver/mcp.go: mcpError moved to embedded_mcp.go for reuse;
  standalone server semantics unchanged.
- serveapi/serveapi.go: MCPHandler wired; AuthorizationError type maps
  resolver rejection to 401/403.

Verification (controller, outside sandbox): go test ./internal/apiserver
./serveapi rc=0; full go test ./... rc=0; gofmt/vet clean. Three mutations
run red with byte-identical reverts. Controller strengthened the AC5 test
after mutation 1 SURVIVED as shipped: the gateway-validation-removed mutant
still passed because the recover() backstop also produces an error envelope —
the test now asserts the gateway's specific rejection message, discriminating
loud validation from the backstop (the plan's "(b) alone is FORBIDDEN" class).

Refs #498

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Fable <noreply@anthropic.com>
…B-1)

The AC7 spec freezes the overload envelope as HTTP 200 + -32603; the test
counted envelopes by JSON body only. Raised by the sonnet evaluator,
reproduced by the controller before adoption.

Co-Authored-By: Claude Fable <noreply@anthropic.com>
@sunholo-voight-kampff
sunholo-voight-kampff enabled auto-merge (squash) August 5, 2026 07:14
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@sunholo-voight-kampff
sunholo-voight-kampff merged commit 6166ada into dev Aug 5, 2026
20 checks passed
@sunholo-voight-kampff
sunholo-voight-kampff deleted the sprint/m-mcp-exact-tool-surface-lane-b-m2 branch August 5, 2026 07:33
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