test: Make Tool inputSchema tests exercise McpSchema.Tool - #1145
Open
imuromtsev wants to merge 1 commit into
Open
imuromtsev wants to merge 1 commit into
imuromtsev wants to merge 1 commit into
Conversation
testJsonSchema and testJsonSchemaWithDefinitions only round-tripped a HashMap through Jackson since JsonSchema was replaced by Map in modelcontextprotocol#749, so no SDK change could fail them. They now deserialize the schema as a Tool inputSchema and compare the serialized inputSchema with the original document. testToolWithMeta passed Map.of("inputSchema", schemaJson), which is not a schema; it now builds the tool from the parsed schema JSON. Stale comments describing the old JsonSchema round trip are removed. Signed-off-by: Ilya Muromtsev <let4time@gmail.com>
This branch has not been deployed
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.
Test-only follow-up to #749. After
JsonSchemawas replaced byMap<String, Object>, three tests inMcpSchemaTestsstopped checking what they were named for:testJsonSchemaandtestJsonSchemaWithDefinitionsonly round-trip aHashMapthrough Jackson, so no change toMcpSchemacan fail them. Their comments still say "Deserialize the original string to a JsonSchema object". They now deserialize{"name": …, "inputSchema": <schema>}intoMcpSchema.Tooland assert that the serialized$.inputSchemaequals the original schema document, so$defsanddefinitionsare checked end to end through the record.testToolWithMetapassedMap.of("inputSchema", schemaJson)as the input schema: a one-key map holding the whole schema as a string, which is not a schema. It now usesTool.builder(name, JSON_MAPPER, schemaJson), liketestToolandtestToolWithComplexSchema.TypeRefimport.No production code changes.
Verification
./mvnw -pl mcp-test -am -Dtest=McpSchemaTests testwith-Pjackson2and-Pjackson3(JDK 21): 186 tests, 0 failures, 0 errors each;spring-javaformat:validatepasses.inputSchemaproperty inTool.fromJsonfailstestJsonSchemaandtestJsonSchemaWithDefinitions(missing: $.inputSchema.$defs/$.inputSchema.definitions); before this change both passed under the same mutation, since they never touchedTool;metainTool.Builder.metafailstestToolWithMeta.A draft-07
definitionsschema deserializes intoToolwithout any validation error: the 2020-12 meta-schema check (SEP-1613) runs only when a server registers a tool, not during deserialization.Prepared with an AI coding agent and reviewed by me.