Skip to content

feat(go): publish per-tool JSON output schemas (RC3-032 sub-part e) - #90

Merged
x7even merged 1 commit into
mainfrom
rc3-032e-output-schemas
Jul 6, 2026
Merged

feat(go): publish per-tool JSON output schemas (RC3-032 sub-part e)#90
x7even merged 1 commit into
mainfrom
rc3-032e-output-schemas

Conversation

@x7even

@x7even x7even commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Closes the last open sub-part of RC3-032 (P1, PARTIAL — see #74): no canonical price field/unit across tools — naming, size_gb scaling, monthly_estimate mixing, egress unit label, no published schema #30 (RC3-032): publishes a JSON output schema per tool.
  • Uses the go-sdk's native mcp.Tool.OutputSchema field (already part of the standard tools/list response) — no new tool/endpoint needed, since every MCP client already fetches that listing.
  • Schemas hand-authored from each handler's real return shape (21 tools), checked into schemas/tools-output-snapshot.json with a parity test, mirroring the existing input-schema convention.
  • Deliberately permissive: no required, no additionalProperties: false anywhere — 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.
  • Notable finding: every handler in this codebase builds CallToolResult.Content by hand and returns a nil structured-output value, so the SDK's own output-schema validation never fires at call time. internal/server/output_validation_test.go fills 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 ./... clean
  • go test ./... -count=1 — all packages pass
  • TestAllToolsPresent / TestSchemaParityWithSnapshot / TestDescriptionParityWithSnapshot / TestOutputSchemaParityWithSnapshot all pass
  • New output_validation_test.go: 14 success-path tests + 1 negative-control test, all pass
  • Verified no required / additionalProperties: false anywhere in the 21 output schemas (grep, zero matches)

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.
@x7even
x7even marked this pull request as ready for review July 6, 2026 06:50
@x7even
x7even merged commit d4647c4 into main Jul 6, 2026
1 check passed
@x7even
x7even deleted the rc3-032e-output-schemas branch July 6, 2026 06:50
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