feat(go): publish per-tool JSON output schemas (RC3-032 sub-part e) - #90
Merged
Conversation
Wire mcp.Tool.OutputSchema for all 21 registered tools, using the go-sdk's native OutputSchema field (part of the standard tools/list response every MCP client already fetches) rather than a new introspection tool or endpoint. Schemas are hand-authored raw-JSON constants (mirroring the existing input-schema convention) derived from reading each handler's actual return shape, checked into schemas/tools-output-snapshot.json with a TestOutputSchemaParityWithSnapshot test guarding drift, same pattern as the existing input-schema snapshot test. Deliberately permissive by design: no "required", no "additionalProperties": false anywhere, since a tool can return either its rich success shape or a slim structured-error shape (no provider configured, bad input) depending on runtime state, and both must validate against the same schema. In this codebase every handler builds CallToolResult.Content by hand and returns a nil structured-output value, so the SDK's own applySchema output validation never fires at call time regardless — these schemas are advertised metadata, not a runtime enforcement gate. internal/server/output_validation_test.go adds the missing check that gap otherwise leaves uncovered: it drives real success-path tool calls through an in-process MCP session and independently validates the returned JSON against each tool's OutputSchema via the go-sdk's own jsonschema resolve/validate, plus a negative-control test proving that check actually rejects a bad payload rather than passing vacuously. Covers get_price (compute, size_gb, iops, mbps), get_prices_batch, compare_prices, get_price_by_sku, estimate_bom, estimate_unit_economics, compare_bom, compare_bom_regions, find_cheapest_region, and find_available_regions.
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.
Summary
mcp.Tool.OutputSchemafield (already part of the standardtools/listresponse) — no new tool/endpoint needed, since every MCP client already fetches that listing.schemas/tools-output-snapshot.jsonwith a parity test, mirroring the existing input-schema convention.required, noadditionalProperties: falseanywhere — a tool can return either its rich success shape or a slim structured-error shape depending on runtime state, and both must validate against the same schema.CallToolResult.Contentby hand and returns anilstructured-output value, so the SDK's own output-schema validation never fires at call time.internal/server/output_validation_test.gofills that gap — it drives real success-path calls through an in-process MCP session and independently validates the JSON against each tool's schema (plus a negative-control test proving the check isn't vacuous).Test plan
go build ./...,go vet ./...cleango test ./... -count=1— all packages passTestAllToolsPresent/TestSchemaParityWithSnapshot/TestDescriptionParityWithSnapshot/TestOutputSchemaParityWithSnapshotall passoutput_validation_test.go: 14 success-path tests + 1 negative-control test, all passrequired/additionalProperties: falseanywhere in the 21 output schemas (grep, zero matches)