feat(serveapi): #498 Lane B M2 — request-scoped MCP adapter and frozen wire envelopes - #592
Merged
sunholo-voight-kampff merged 2 commits intoAug 5, 2026
Conversation
…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
enabled auto-merge (squash)
August 5, 2026 07:14
|
sunholo-voight-kampff
deleted the
sprint/m-mcp-exact-tool-surface-lane-b-m2
branch
August 5, 2026 07:33
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.



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 ambientsubmit_feedback, exact A/B surfaces, frozen-32603callback envelopes (timeout / capacity / cancel), 401/403 for typed authorization errors, and arecover()backstop mapping SDKAddToolpanics to the frozen envelope while the gateway rejects every known-invalid descriptor class loudly (§0.5 both halves).gpt-5.6-sol(sandboxed, snapshot protocol) · Controller re-ran all gates outside the sandbox:go test ./internal/apiserver ./serveapirc=0, fullgo test ./...rc=0, gofmt/vet clean.811ac16b4.Refs #498
🤖 Generated with Claude Code