You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
"error": {
"message": "Invalid schema for function 'entity-live': schema must be a JSON Schema of 'type: \"object\"', got 'type: \"None\"'.",
"type": "invalid_request_error",
"param": "tools[1].function.parameters",
"code": "invalid_function_parameters"
}
}
However, it works fine if I specify the schema with a String, like this:
private static final String COMMON_INPUT_SCHEMA = """
{
"type": "object",
"properties": {
"entityId": {
"type": "string",
"description": "Entity ID"
}
},
"required": ["entityId"]
}
""";
...
private McpServer.ToolRegistration themeParkApiEntityScheduleToolRegistration() {
return new McpServer.ToolRegistration(
new McpSchema.Tool(
"entity-schedule",
"Return schedule data about an entity, including hours of operation",
COMMON_INPUT_SCHEMA),
(arguments) -> {
String entityId = (String) arguments.get("entityId");
var entityScheduleJson = themeParkService.getEntitySchedule(entityId);
McpSchema.TextContent content = new McpSchema.TextContent(entityScheduleJson);
return new McpSchema.CallToolResult(List.of(content), false);
});
}
- Change Tool.inputSchema type from Map<String, Object> to String to store raw JSON schema
- Enhance StdioClientTransport error logging with more context
- Add ToolHelper utility class for:
- Converting Spring AI FunctionCallbacks to MCP tools
- Generating JSON schemas for tool input validation
- Facilitating integration between Spring AI functions and MCP tools
- Update tests and samples to use the new Tool schema format
Resolves#52
Following the example set in the sample application (at https://github.com/spring-projects-experimental/spring-ai-mcp/blob/main/spring-ai-mcp-sample/src/main/java/org/springframework/ai/mcp/sample/server/McpServerConfig.java#L135), I'm trying to specify the input schema with a
Map
. Specifically, if I specify the schema withMap.of("entityId", "String")
, I get the following error:However, it works fine if I specify the schema with a
String
, like this:(The entire project can be found at https://github.com/habuma/spring-ai-examples/tree/main/spring-ai-mcp)
HOWEVER, I can get it to work with a Map-based schema is the
Map
is defined like this:Which is, incidentally, the same
Map
that is produced internally when given theString
schema above.So, my take on this is that one of the two things is true:
Map
-based schema.McpSchema.Tool
should somehow wrap the incomingMap
with the outerMap
as the value of the "properties" key.The text was updated successfully, but these errors were encountered: