-
Notifications
You must be signed in to change notification settings - Fork 856
fix: Remove JsonSchema and use a Map for inputSchema to support json schemas dialect #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6b0a8ee
26ecf80
1fdc258
c2f459e
fc76143
0180bb5
5229550
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1298,27 +1298,6 @@ public ListToolsResult(List<Tool> tools, String nextCursor) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * A JSON Schema object that describes the expected structure of arguments or output. | ||
| * | ||
| * @param type The type of the schema (e.g., "object") | ||
| * @param properties The properties of the schema object | ||
| * @param required List of required property names | ||
| * @param additionalProperties Whether additional properties are allowed | ||
| * @param defs Schema definitions using the newer $defs keyword | ||
| * @param definitions Schema definitions using the legacy definitions keyword | ||
| */ | ||
| @JsonInclude(JsonInclude.Include.NON_ABSENT) | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public record JsonSchema( // @formatter:off | ||
| @JsonProperty("type") String type, | ||
| @JsonProperty("properties") Map<String, Object> properties, | ||
| @JsonProperty("required") List<String> required, | ||
| @JsonProperty("additionalProperties") Boolean additionalProperties, | ||
| @JsonProperty("$defs") Map<String, Object> defs, | ||
| @JsonProperty("definitions") Map<String, Object> definitions) { // @formatter:on | ||
| } | ||
|
|
||
| /** | ||
| * Additional properties describing a Tool to clients. | ||
| * | ||
|
|
@@ -1363,7 +1342,7 @@ public record Tool( // @formatter:off | |
| @JsonProperty("name") String name, | ||
| @JsonProperty("title") String title, | ||
| @JsonProperty("description") String description, | ||
| @JsonProperty("inputSchema") JsonSchema inputSchema, | ||
| @JsonProperty("inputSchema") Map<String, Object> inputSchema, | ||
| @JsonProperty("outputSchema") Map<String, Object> outputSchema, | ||
| @JsonProperty("annotations") ToolAnnotations annotations, | ||
| @JsonProperty("_meta") Map<String, Object> meta) { // @formatter:on | ||
|
|
@@ -1380,7 +1359,7 @@ public static class Builder { | |
|
|
||
| private String description; | ||
|
|
||
| private JsonSchema inputSchema; | ||
| private Map<String, Object> inputSchema; | ||
|
|
||
| private Map<String, Object> outputSchema; | ||
|
|
||
|
|
@@ -1403,13 +1382,13 @@ public Builder description(String description) { | |
| return this; | ||
| } | ||
|
|
||
| public Builder inputSchema(JsonSchema inputSchema) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep this method with /**
* @deprecated use {@link #inputSchema(Map)} instead.
*/
@Deprecated
public Builder inputSchema(JsonSchema inputSchema) {
Map<String, Object> schema = new HashMap<>();
if (inputSchema.type() != null)
schema.put("type", inputSchema.type());
if (inputSchema.properties() != null)
schema.put("properties", inputSchema.properties());
if (inputSchema.required() != null)
schema.put("required", inputSchema.required());
if (inputSchema.additionalProperties() != null)
schema.put("additionalProperties", inputSchema.additionalProperties());
if (inputSchema.defs() != null)
schema.put("$defs", inputSchema.defs());
if (inputSchema.definitions() != null)
schema.put("definitions", inputSchema.definitions());
return inputSchema(schema);
} |
||
| public Builder inputSchema(Map<String, Object> inputSchema) { | ||
| this.inputSchema = inputSchema; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder inputSchema(McpJsonMapper jsonMapper, String inputSchema) { | ||
| this.inputSchema = parseSchema(jsonMapper, inputSchema); | ||
| this.inputSchema = schemaToMap(jsonMapper, inputSchema); | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -1450,15 +1429,6 @@ private static Map<String, Object> schemaToMap(McpJsonMapper jsonMapper, String | |
| } | ||
| } | ||
|
|
||
| private static JsonSchema parseSchema(McpJsonMapper jsonMapper, String schema) { | ||
| try { | ||
| return jsonMapper.readValue(schema, JsonSchema.class); | ||
| } | ||
| catch (IOException e) { | ||
| throw new IllegalArgumentException("Invalid schema: " + schema, e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Used by the client to call a tool provided by the server. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,4 @@ public final class ToolsUtils { | |
| private ToolsUtils() { | ||
| } | ||
|
|
||
| public static final McpSchema.JsonSchema EMPTY_JSON_SCHEMA = new McpSchema.JsonSchema("object", | ||
| Collections.emptyMap(), null, null, null, null); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the empty schema as a This is closer to an empty schema. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep but make
@Deprecated