feat(debugmcp): declare outputSchema for every tool - #8
Merged
Conversation
Every tool already reports success as structuredContent, but none declared an outputSchema. A client therefore had no contract for the structured object it receives — it could only guess the shape or fall back to parsing the text block. A tool that emits structured output should describe it. - declare outputSchema on all 11 tools; the control tools share one schema, since a run either stops or finishes - require only the key present in every success (event, id) and declare the union of the rest, so the tools with two success shapes stay honest rather than promising keys they sometimes omit - emit an empty object rather than null for the no-argument inputSchema properties, which was not valid JSON Schema The declarations are held to the handlers by tests: one asserts every tool declares both schemas with required a subset of properties, the other drives a real debug session and validates each emitted payload against its declared schema, covering both success shapes. Tags: #lua-pure #debugmcp #mcp #schema #contract Co-Authored-By: htjulia <htjulia1@gmail.com>
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.
Every
debugmcptool already returns its success asstructuredContent, but none declared anoutputSchema. A client had no contract for the object it receives — it could only guess the shape or fall back to parsing the text block. This adds the missing half of the contract.Where to look first
The two-shape tools are the only judgement call here.
launch/continue/step_*return either astoppedevent (reason,source,line,function,depth) or afinishedone (results, optionalerror);get_sourcereturns either the whole text or a snippet. For those,requiredlists only the discriminating key (event,id) and the schema declares the union of the rest as optional. Requiring anything more would make the schema promise keys that a legitimate success sometimes omits.The schemas describe successful results only. A tool-level failure comes back as an
isErrorresult carrying{"error": …}, which is deliberately a different shape and is not covered — consistent with howoutputSchemais specified. Worth confirming you agree with that reading, since it is the one place the declaration does not describe everything the tool can emit.Changes
outputSchemaon all 11 tools. The four control tools share one schema through a smallcontrol()helper, since their contract is identical and only the description differs.inputSchema:obj(nil)was serialising"properties": null, which is not valid JSON Schema. Now{}.What keeps this honest
Declarations rot when the handler that feeds them changes. Two tests prevent that:
TestToolSchemasAreComplete— every tool declares both schemas, both are well-formed objects, everyrequiredkey is actually declared, and handlers and definitions agree in both directions (a handler with no definition is invisible; a definition with no handler is a dead promise).TestToolOutputMatchesDeclaredSchema— drives a real debug session and validates each emitted payload against its declared schema: required keys present, no undeclared keys, declared types and enums honoured, descending into arrays and the nested frame/variable shapes. It runs the program to completion so both thestoppedandfinishedvariants are covered, and callsget_sourceboth ways.The second test was checked to be non-vacuous: dropping a single key (
depth) from the declaration fails it withemitted undeclared key "depth".Verification
gofmtclean ·go vetok ·go test -race ./debugmcpok ·make check30/33 (RUN-ERR 1 =gc.lua, SKIP 2 = driver scripts) — the existing ceiling, no regression.