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

feat: add _meta support to @McpTool and @McpResource annotations#102

Closed
apappascs wants to merge 1 commit intospring-ai-community:mainfrom
apappascs:feat/add-meta-support
Closed

feat: add _meta support to @McpTool and @McpResource annotations#102
apappascs wants to merge 1 commit intospring-ai-community:mainfrom
apappascs:feat/add-meta-support

Conversation

@apappascs
Copy link
Copy Markdown
Contributor

Add meta attribute to both annotations, enabling MCP Apps UI metadata (e.g. _meta.ui.resourceUri, _meta.ui.csp) to be declared directly on annotated methods. Meta propagates to tool/resource declarations and to resource content in ReadResourceResult.

Add `meta` attribute to both annotations, enabling MCP Apps UI
metadata (e.g. _meta.ui.resourceUri, _meta.ui.csp) to be declared
directly on annotated methods. Meta propagates to tool/resource
declarations and to resource content in ReadResourceResult.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
@apappascs apappascs force-pushed the feat/add-meta-support branch from e42f02a to 3dbf7c4 Compare February 16, 2026 14:24
@apappascs
Copy link
Copy Markdown
Contributor Author

@tzolov do you have a standardized way to fully test this ? I realized this dependency is used from the one in Spring ai mcp annotations .

@habuma habuma mentioned this pull request Feb 28, 2026
tzolov pushed a commit that referenced this pull request Mar 2, 2026
…otations

Adds a `metaProvider` attribute to the @mcptool, @McpPrompt, and @McpResource
annotations, allowing users to attach arbitrary `_meta` data to MCP tool,
prompt, and resource declarations. Meta is propagated to both the declarations
and to resource content in ReadResourceResult.

Introduces a `MetaProvider` interface and `DefaultMetaProvider` no-op
implementation, along with a `MetaUtils` helper that instantiates the provider
via a no-arg constructor and returns an unmodifiable metadata map.

Usage:

    @mcptool(metaProvider = MyMetaProvider.class)
    String myTool() { ... }

    class MyMetaProvider implements MetaProvider {
        @OverRide
        public Map<String, Object> getMeta() {
            return Map.of(
                "openai/widgetPrefersBorder", true,
                "openai/widgetDomain", "https://chatgpt.com");
        }
    }

Combines #102 and #83

Resolves: #81

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
Signed-off-by: Vadzim Shurmialiou <vadzim.shurmialiou@check24.de>
Signed-off-by: Craig Walls <habuma@gmail.com>
Co-authored-by: Alexandros Pappas <apappascs@gmail.com>
Co-authored-by: Craig Walls <habuma@gmail.com>
tzolov pushed a commit that referenced this pull request Mar 2, 2026
…otations

Adds a `metaProvider` attribute to the @mcptool, @McpPrompt, and @McpResource
annotations, allowing users to attach arbitrary `_meta` data to MCP tool,
prompt, and resource declarations. Meta is propagated to both the declarations
and to resource content in ReadResourceResult.

Introduces a `MetaProvider` interface and `DefaultMetaProvider` no-op
implementation, along with a `MetaUtils` helper that instantiates the provider
via a no-arg constructor and returns an unmodifiable metadata map.

Usage:

    @mcptool(metaProvider = MyMetaProvider.class)
    String myTool() { ... }

    class MyMetaProvider implements MetaProvider {
        @OverRide
        public Map<String, Object> getMeta() {
            return Map.of(
                "openai/widgetPrefersBorder", true,
                "openai/widgetDomain", "https://chatgpt.com");
        }
    }

Combines #102 and #83

Resolves: #81

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
Signed-off-by: Vadzim Shurmialiou <vadzim.shurmialiou@check24.de>
Signed-off-by: Craig Walls <habuma@gmail.com>
Co-authored-by: Alexandros Pappas <apappascs@gmail.com>
Co-authored-by: Craig Walls <habuma@gmail.com>
@tzolov
Copy link
Copy Markdown
Collaborator

tzolov commented Mar 2, 2026

This PR has been merged as part of the c7ffe98, thank you @apappascs

@tzolov tzolov closed this Mar 2, 2026
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.

2 participants