Repository navigation
fix(mcp): move tool error problem to _meta - #91
Merged
Merged
Conversation
A coded tool error wrote its RFC 9457 problem object into structuredContent. The spec reserves that field for the payload the tool's outputSchema describes and requires it to conform, and some clients (the TypeScript SDK 1.x) validate it on error results too, so they replaced the actionable error with a schema-violation error. Every built-in tool that declares an outputSchema was affected. The problem now travels in the result _meta under org.htcom.protean/problem (McpToolResult.PROBLEM_META_KEY), next to any _meta the tool attached. list_runtimes declared runtimes[].scope as a string although it is null whenever auto-provision is off (the default), so every default-install result violated its outputSchema and strict-schema mode rejected the call outright. scope is now nullable. Tests sweep every schema-declaring tool's error path and run list_runtimes under strict validation; guides and changelog (en+ko) document the new error location. Fixes #89, Fixes #90 Co-Authored-By: htjulia <[email protected]>
The error-shape tests drove McpDispatcher directly, so nothing in CI checked what POST /platform/mcp actually puts on the wire. A coded scope_list error must arrive with its problem in _meta and no structuredContent. Related: #90 Co-Authored-By: htjulia <[email protected]>
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.
Fixes #89, Fixes #90
What
#90 — coded tool errors no longer put their problem detail in
structuredContent.A stable-code error (
McpToolResult.error(ErrorCode, …)) now carries its RFC 9457 problem in the result_metaunderorg.htcom.protean/problem(new constantMcpToolResult.PROBLEM_META_KEY), merged with any_metathe tool attached.structuredContentcarries only what the tool itself returns.#89 —
protean.list_runtimesdeclaresruntimes[].scopeas["string","null"].Why
outputSchemais declared, "Servers MUST providestructured results that conform to this schema" — with no exemption for
isErrorresults. The problemobject never matches a tool's success schema, so every built-in tool that declares an
outputSchemawasemitting non-conforming error results (e.g.
scope_listwith auto-provision off,patch_moduleon anunknown module).
@modelcontextprotocol/sdk1.32.2(TypeScript SDK 1.x) validates
structuredContentwhenever it is present, regardless ofisError, andreplaces the actionable error with
Structured content does not match the tool's output schema.(
@modelcontextprotocol/client2.x and the Python SDK skip validation on errors.)list_runtimesreturnsscope: nullwhenever auto-provision is off (the default), so every default-installresult violated its schema, and with
protean.mcp.strict-schema=truethe call failed outright withOUTPUT_SCHEMA_VIOLATION.Compatibility
Wire change for MCP clients: read an error's stable code from
_meta["org.htcom.protean/problem"].codeinstead of
structuredContent.code. The[CODE]-prefixed text content, success results, and JSON-RPCprotocol errors (
error.data) are unchanged. The Java API only gains a constant. Recorded underChanged in
CHANGELOG.md/CHANGELOG.ko.md.Tests
McpOutputSchemaConformanceTest.error_results_never_carry_a_nonconforming_structured_contentsweepsevery tool that declares an
outputSchemawith error-provoking arguments and asserts no non-conformingstructuredContentplus a coded problem in_meta. A floor (named tools + ≥10 exercised) keeps it frompassing vacuously — missing-argument calls are JSON-RPC protocol errors, not tool results, so they
exercise nothing.
list_runtimeswith a null scope; gatedscope_listreportsSTATE_CONFLICTin_meta;list_runtimesadded to the real-output conformance check; tool_meta+ problem merge (tool's objectnot mutated).
structuredContentto_meta.McpHttpControllerTest.coded_tool_error_over_http_carries_its_problem_in_metaPOSTsscope_listto/platform/mcpand asserts the wire shape (_metaproblem, nostructuredContent) — thedispatcher-level tests above never touched the HTTP serialization. Fails against
main's dispatcher.McpDispatcherandListRuntimesToolmakes all six new/changed tests fail; thesweep independently catches
patch_module, not onlyscope_list../gradlew checkpasses locally (603 tests).:examples:quickstart:runMcp(in-process, fresh store): gate-fail deploy →_metaproblemGATE_FAILED/gate=tests, nostructuredContent;config.setwith an unknown key →INVALID_ARGUMENTwithoutcomes;scope_list→STATE_CONFLICT;list_runtimes→scope: null, no error.Not in this PR
this contract after merge.
java_mcpscenario runbooks name the old location in two expected values; handed off, to apply aftermerge.
Docs
docs/guide/08-mcp-integration.md(+ko): new Tool errors section with the result shape; the outputSchemavalidation section notes that a custom tool attaching
structuredContentto an error must keep it conformant.