Repository navigation
Issue #41 : fix(tools): keep null branch in registered outputSchema - #46
Shreyavemana wants to merge 8 commits into
Conversation
…ase PR. Keep pyproject.toml and uv.lock in sync, skip a bump while a version is still unpublished, and only hit the PyPI environment when an upload will actually run.
Bring the bump/publish workflows in line with develop (via main) so the PR can merge.
…ure/release-automation Automate version bumps and PyPI publishes from main
…ase/0.4.0 Release version bump to 0.4.0
|
The fix makes |
Verification of the proposed fix (
|
Summary
Registered output schemas lose the
nullbranch of Optional fields. A tool that returnsNonefor anX | Nonefield produces a result that a client validating against the advertisedoutputSchemarejects.Observed
A tool declares an output model with Optional fields (
str | None = None,int | None = None) and returnsNonefor them. A client that validatesstructuredContentagainst the advertisedoutputSchemafails the call with errors such as:Cause
In
nitrostack/core/app.py:inspector_friendly_schema(via_unwrap_nullable_schema) rewritesanyOf: [T, null]to plainT. Its docstring says this is so MCP Inspector can render form fields.tool_json_schemaapplies the same rewrite to the output schema, so the registeredoutputSchemano longer allows null.Repro
Run on main (0.4.0):
Pydantic emits
anyOf: [{type: string}, {type: null}]formaybe.tool_json_schemareturns:NitroTestingModule.call_toolreturns the null value without validating it against the schema, so the in-process harness does not catch this.Expected
The registered
outputSchemakeeps the null branch, because it describes what the tool returns. The Inspector rewrite is only needed for input forms.Workaround
Remove
output_schemafrom@tool.Proposal
inspector_friendly_schemato input schemas only.