Skip to content

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

Description

@michaelboyles

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

public static McpSchema.Resource asResource(McpResource mcpResourceAnnotation) {

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions