spring-projects / spring-projects/spring-ai
[Bug - MCP server] `McpResource.annotations` is ignored/does nothing
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 5
Description
Bug description
The annotations property of an McpResource is ignored. It is not propagated to the client.
@McpResource(
uri = "test://resource/{id}",
name = "test-resource",
annotations = @McpResource.McpAnnotations(
audience = McpSchema.Role.ASSISTANT,
priority = 1.0,
lastModified = "some time"
)
)
public String myResource() {
return "something";
}
The only accessor of this property is
The only callers of that method are tests
Environment
Spring AI version: 2.0.0
Expected behavior
Properties should be sent to the client.
For lastModified specifically, the design seems wrong. It's quite unlikely that a static lastModified time will be possible. In many cases, the the property must be derived programmatically from the resource.
McpResource is also used for template resources, and for such cases, there is not a single last modified time - it depends on the resource.
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 mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/adapter/ResourceAdapter.java at the referenced accessor, then inspect the tests that call it and trace how the resource reaches the client. Done means the McpResource annotations are propagated to the client, with the handling of lastModified clarified for resources and templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100