Repository navigation
fix(tools): strip non-standard schema formats from tool schemas - #159
Closed
hogan-yuan wants to merge 3 commits into
Closed
hogan-yuan wants to merge 3 commits into
hogan-yuan wants to merge 3 commits into
Conversation
schemars derives non-standard numeric `format` values from Rust integer/ float types (`usize` -> "uint", `u64` -> "uint64", `i64` -> "int64", `f64` -> "double", ...). JSON Schema defines no numeric formats, so strict MCP clients log `unknown format "uint" ignored` on every tool call for fields like `page`, `count`, `total`. Recursively drop these numeric `format` annotations from every tool's input and output schema in the shared list_tools() post-processing pass (alongside the existing null-type stripping). `type` is preserved, so the value is still constrained to an integer/number; only the advisory, unrecognized keyword is removed. String formats (date-time, uri, ...) are left untouched. Add a regression test asserting no tool schema exposes a non-standard numeric format. Resolves longbridge/developers#1264
Generalize the format sanitizer to a whitelist: keep only the JSON Schema 2020-12 standard formats (date-time, uri, uuid, …) and drop every other `format` value, rather than blacklisting the known schemars numeric ones. This future-proofs against any other non-standard format schemars might emit (e.g. `char`). Verified the current tool set: after stripping, zero `format` values remain and all schema keywords are standard.
…path list_tools() nulls output_schema (a jq projection can return any shape), so the previous regression test's output-schema branch never ran. The output-schema contract is actually served as MCP resources from all_tools_full_cached(); assert that path is free of non-standard formats too, split from the input-schema check for a precise failure message.
Member
Author
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.
Problem
schemars derives JSON Schema
formatvalues from Rust numeric types —usize→uint,u64→uint64,i64→int64,f64→double, etc. None of these are in the JSON Schema 2020-12 format-annotation vocabulary, so strict MCP clients logunknown format "uint" ignoredon every tool call.Fix
Recursively drop every
formatannotation whose value is not a standard JSON Schema format (STANDARD_JSON_SCHEMA_FORMATS), applied to both the input schemas and the output schemas served over the resource path. Standard string formats (date-time,uri, …) are preserved.Tests
Added an assertion that the output schemas served via the resource path are format-clean (no non-standard
formatsurvives).cargo test,clippy, and+nightly fmtclean. Only touchessrc/tools/mod.rs.