spring-projects / spring-projects/spring-ai

[Bug - MCP server] `McpResource.annotations` is ignored/does nothing

Open
#6,749 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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

https://github.com/spring-projects/spring-ai/blob/ca666e7331c40b00d7da3c535e1a9c8e99e39995/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/adapter/ResourceAdapter.java#L42

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.