spring-projects / spring-projects/spring-ai
Support JsonFormat when using generateOutputSchema
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description & Expected Behavior
Enable generateOutputSchema to detect and use @JsonFormat.
Without this support, the MCP server is giving the MCP Inspector an error (confirmed gemini cli also breaks so it may be breaking all clients):
Validation failed: structuredContent does not match tool outputSchema. Validation errors: [$.total: string found, number expected]
Steps to reproduce
- Define a return response object that contains a BigDecimal that uses the JsonFormat. Example Below.
Minimal Complete Reproducible example
@Data
public class BalancePayload {
@JsonFormat(shape = JsonFormat.Shape.STRING)
@Schema(accessMode = AccessMode.READ_ONLY, requiredMode = RequiredMode.REQUIRED, description = "The total amount of the balance.", example = "100")
private BigDecimal total;
}
@GetMapping(...)
@Operation(...)
@McpTool(generateOutputSchema = true)
public BalancePayload getBalance(...) {
return new BalancePayload().setTotal(BigDecimal.ONE);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generateOutputSchema handling and the JsonFormat annotation shown in the reproducible example. Reproduce the BigDecimal case with @JsonFormat(shape = JsonFormat.Shape.STRING), then inspect the generated output schema and verify that it represents total as a string so MCP Inspector validation succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100