spring-projects / spring-projects/spring-ai
In the output parameters of the tool, properties annotated with @McpToolParam cannot be null
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
For tools annotated with @McpTool, if the output is a custom class, then any properties within that class annotated with @McpToolParam must not be null, otherwise errors will occur:Validation failed: structuredContent does not match tool outputSchema. Validation errors: [$.current: 已找到 null,必须是 object]
How can I return a null value? Thank you.
Environment
mcp-annotations: 0.6.0
spring-ai: 1.1.0-M4
protocol: stateless
Minimal Complete Reproducible example
@Service
public class TestService {
@McpTool
public TestResponse test() {
return new TestResponse();
}
public static class TestResponse {
@McpToolParam(description = "test", required = false)
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
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 @McpTool and @McpToolParam processing shown by the TestService and TestResponse reproduction, then reproduce the structuredContent validation error with the optional text property left null. Done means a custom tool output with an @McpToolParam(required = false) null property is accepted without the reported schema-validation failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100