spring-projects / spring-projects/spring-ai
[Bug - MCP server] Tool output schemas are not generated for primitives or "simple" types
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
This tool will silently not get an output schema
@McpTool(generateOutputSchema = true)
public int returnsInt() {
return 1;
}
Environment
Spring AI version: 2.0.0
Expected behavior
Generate this output schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "integer",
"format": "int32"
}
Details
Primitive types are filtered here
I know the schema is simple, but what's the reason to not generate it? It's useful for the LLM to know what type a tool returns, even when the type is simple.
I tried to git blame this to see if I could determine the reason this filtering was added, but it was bulk imported as part of a 50k LOC commit.
Probably if generateOutputSchema is set to true, and the code decides that it will not be honoured, then there should be a warning logged
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 in mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/provider/tool/SyncMcpToolProvider.java around lines 124-131, where primitive types are filtered. Check how generateOutputSchema is handled for int and other simple return types, then verify that returnsInt() produces the expected integer JSON schema when the flag is true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100