Impact
The LLM thinks the readonly fields are writable, so it wastes tokens trying to figure out default values to pass in.
Bug description & Expected Behavior
I'm using MCP Inspector to view the MCP schema and make calls. The generated input schema from the server is incorrectly mapping the detected @Schema fields. It's rendering "readOnly:true" fields as inputs. Then in the MCP Inspector, it's rendering these as HTML input fields that are not "read only".
The @Schema annotation when using accessMode = AccessMode.READ_ONLY is intended to hint to OpenAPI that these are fields given in the output. Please see the provided example of how the payload is an input and output, and that the accessMode controls the visibility on both sides.
I'm creating this as a Bug an not a Feature Request since @Schema is supported by Spring AI. The annotations are being read for other fields such as `@Schema(description, defaultValue) and both are being populated into the HTML form inputs in MCP Inspector.
Minimal Complete Reproducible example
@PostMapping(...)
@Operation(...)
@McpTool(...)
public ExamplePayload createExample(@RequestBody final ExamplePayload examplePayload) {
...
}
@Data
public class ExamplePayload {
@Schema(accessMode = AccessMode.READ_ONLY, requiredMode = RequiredMode.REQUIRED, description = "An rfc 3339 formatted date: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private ZonedDateTime created; <------ this is an **output** only field
@Schema(description = "The chosen locale of the user.", defaultValue = "EN_US", example = "EN_US")
private Locale locale; <------ this is an **input** and **output** field
@Schema(accessMode = AccessMode.WRITE_ONLY, ...)
private String other; <------ this is an **input** only field
}
Please also check if @Schema(requiredMode = RequiredMode...) is handled correctly or not.