-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Bug description
Jackson annotations on MCP tool return value are not taken into account for output schema generation.
Environment
- Java version : 21
- Spring MCP version : 1.1.0-M2
Steps to reproduce
- Create a tool method annotated with
@McpTool
andgenerateOutputSchema
totrue
. - Return an object or a record from this method with some
@JsonProperty
annotations to override default properties names - Start the server & call this tool
- An error occurs due to structured content not matching the tool output schema.
This is due to an invalid output schema ignoring Jackson properties names override : the schema property name do not match the serialized property name.
Expected behavior
The output schema generation should generate properties names the same way as the output is serialized.
Possible cause
This issue seams to be related to the fact that the SchemaGeneratorConfig
used to generate the output schema does not have the Jackson module registered : https://github.com/spring-ai-community/mcp-annotations/blob/main/mcp-annotations/src/main/java/org/springaicommunity/mcp/method/tool/utils/JsonSchemaGenerator.java#L184
Minimal Complete Reproducible example
public record ToolResult(
@JsonProperty("tool_result_value") String toolResultValue
) {}
@Service
public class ExampleTool {
@McpTool(
name = "example_tool",
generateOutputSchema = true
)
public ToolResult exampleTool() {
return new ToolResult("result");
}
}
jack-livo and okohub
Metadata
Metadata
Assignees
Labels
No labels