Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Fix @McpResource title not propagated to Resource/ResourceTemplate#108

Open
mzeijen wants to merge 1 commit intospring-ai-community:mainfrom
mzeijen:feature/resource-title-fix
Open

Fix @McpResource title not propagated to Resource/ResourceTemplate#108
mzeijen wants to merge 1 commit intospring-ai-community:mainfrom
mzeijen:feature/resource-title-fix

Conversation

@mzeijen
Copy link
Copy Markdown

@mzeijen mzeijen commented Apr 9, 2026

Summary

The @McpResource annotation has a title attribute, but none of the resource provider classes (AsyncMcpResourceProvider, AsyncStatelessMcpResourceProvider, SyncMcpResourceProvider, SyncStatelessMcpResourceProvider) copied it into the McpSchema.Resource or McpSchema.ResourceTemplate objects they build. Additionally, ResourceAdapter.asResourceTemplate() was missing the .title() call (while asResource() already had it).

For example, given:

@McpResource(uri = "test://resource", name = "test", title = "My Resource Title", description = "A test resource")
public ReadResourceResult readResource() { ... }

After building via any resource provider's getResourceSpecifications():

  • resource.title() was null (expected: "My Resource Title")

This PR fixes the issue by reading resourceAnnotation.title() and passing it to .title() on both McpSchema.Resource and McpSchema.ResourceTemplate builders in all four provider classes and in ResourceAdapter.asResourceTemplate().

The title attribute from @McpResource was never read or passed to the
McpSchema.Resource and McpSchema.ResourceTemplate builders in all four
resource provider classes and in ResourceAdapter.asResourceTemplate().
This caused the title to always be null in the built objects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant