Skip to content

Commit efa638e

Browse files
committed
fix...
1 parent df9a2ef commit efa638e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

mcp-schema-jackson/src/main/java/io/modelcontextprotocol/schema/McpJacksonSchema.java

+2
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ public interface JsonSchemaMixin {
410410
@JsonProperty("properties") Map<String, Object> properties();
411411
@JsonProperty("required") List<String> required();
412412
@JsonProperty("additionalProperties") Boolean additionalProperties();
413+
@JsonProperty("$defs") Map<String, Object> defs();
414+
@JsonProperty("definitions") Map<String, Object> definitions();
413415
} // @formatter:on
414416

415417
@JsonInclude(JsonInclude.Include.NON_ABSENT)

mcp-schema-jackson/src/test/java/io/modelcontextprotocol/schema/McpSchemaTests.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -487,16 +487,16 @@ void testJsonSchema() throws Exception {
487487
""";
488488

489489
// Deserialize the original string to a JsonSchema object
490-
McpSchema.JsonSchema schema = mapper.readValue(schemaJson, McpSchema.JsonSchema.class);
490+
McpSchema.JsonSchema schema = mcpJacksonCodec.getMapper().readValue(schemaJson, McpSchema.JsonSchema.class);
491491

492492
// Serialize the object back to a string
493-
String serialized = mapper.writeValueAsString(schema);
493+
String serialized = mcpJacksonCodec.getMapper().writeValueAsString(schema);
494494

495495
// Deserialize again
496-
McpSchema.JsonSchema deserialized = mapper.readValue(serialized, McpSchema.JsonSchema.class);
496+
McpSchema.JsonSchema deserialized = mcpJacksonCodec.getMapper().readValue(serialized, McpSchema.JsonSchema.class);
497497

498498
// Serialize one more time and compare with the first serialization
499-
String serializedAgain = mapper.writeValueAsString(deserialized);
499+
String serializedAgain = mcpJacksonCodec.getMapper().writeValueAsString(deserialized);
500500

501501
// The two serialized strings should be the same
502502
assertThatJson(serializedAgain).when(Option.IGNORING_ARRAY_ORDER).isEqualTo(json(serialized));
@@ -530,16 +530,16 @@ void testJsonSchemaWithDefinitions() throws Exception {
530530
""";
531531

532532
// Deserialize the original string to a JsonSchema object
533-
McpSchema.JsonSchema schema = mapper.readValue(schemaJson, McpSchema.JsonSchema.class);
533+
McpSchema.JsonSchema schema = mcpJacksonCodec.getMapper().readValue(schemaJson, McpSchema.JsonSchema.class);
534534

535535
// Serialize the object back to a string
536-
String serialized = mapper.writeValueAsString(schema);
536+
String serialized = mcpJacksonCodec.getMapper().writeValueAsString(schema);
537537

538538
// Deserialize again
539-
McpSchema.JsonSchema deserialized = mapper.readValue(serialized, McpSchema.JsonSchema.class);
539+
McpSchema.JsonSchema deserialized = mcpJacksonCodec.getMapper().readValue(serialized, McpSchema.JsonSchema.class);
540540

541541
// Serialize one more time and compare with the first serialization
542-
String serializedAgain = mapper.writeValueAsString(deserialized);
542+
String serializedAgain = mcpJacksonCodec.getMapper().writeValueAsString(deserialized);
543543

544544
// The two serialized strings should be the same
545545
assertThatJson(serializedAgain).when(Option.IGNORING_ARRAY_ORDER).isEqualTo(json(serialized));
@@ -596,16 +596,17 @@ void testToolWithComplexSchema() throws Exception {
596596
}
597597
""";
598598

599-
McpSchema.Tool tool = new McpSchema.Tool("addressTool", "Handles addresses", complexSchemaJson);
599+
McpSchema.JsonSchema schema = mcpJacksonCodec.getMapper().readValue(complexSchemaJson, McpSchema.JsonSchema.class);
600+
McpSchema.Tool tool = new McpSchema.Tool("addressTool", "Handles addresses", schema);
600601

601602
// Serialize the tool to a string
602-
String serialized = mapper.writeValueAsString(tool);
603+
String serialized = mcpJacksonCodec.getMapper().writeValueAsString(tool);
603604

604605
// Deserialize back to a Tool object
605-
McpSchema.Tool deserializedTool = mapper.readValue(serialized, McpSchema.Tool.class);
606+
McpSchema.Tool deserializedTool = mcpJacksonCodec.getMapper().readValue(serialized, McpSchema.Tool.class);
606607

607608
// Serialize again and compare with first serialization
608-
String serializedAgain = mapper.writeValueAsString(deserializedTool);
609+
String serializedAgain = mcpJacksonCodec.getMapper().writeValueAsString(deserializedTool);
609610

610611
// The two serialized strings should be the same
611612
assertThatJson(serializedAgain).when(Option.IGNORING_ARRAY_ORDER).isEqualTo(json(serialized));

mcp-spi/src/main/java/io/modelcontextprotocol/schema/McpSchema.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,8 @@ public record GetPromptResult(String description, List<PromptMessage> messages)
539539
public record ListToolsResult(List<Tool> tools, String nextCursor) {
540540
}
541541

542-
public record JsonSchema(String type, Map<String, Object> properties,
543-
List<String> required,
544-
Boolean additionalProperties,
545-
Map<String, Object> defs,
546-
Map<String, Object> definitions) {
542+
public record JsonSchema(String type, Map<String, Object> properties, List<String> required,
543+
Boolean additionalProperties, Map<String, Object> defs, Map<String, Object> definitions) {
547544
}
548545

549546
/**

0 commit comments

Comments
 (0)