Annotation Interface McpResource
- Author:
- Christian Tzolov, Alexandros Pappas, Vadzim Shurmialiou, Craig Walls
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionOptional annotations for the client.io.modelcontextprotocol.modern.McpSchema.CacheScopeWho may reuse a cached result of reading this resource.A description of what this resource represents.McpIcon[]Optional icons for clients that render a catalogue.Class<? extends MetaProvider>Optional meta provider class that supplies data for "_meta" field for this resource declaration.The MIME type of this resource, if known.Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn’t present).Client capabilities the resource cannot work without.longOptional size of the resource content in bytes, when known up front.Optional human-readable name of the prompt for display purposes.longHow long, in milliseconds, a client may cache the result of reading this resource.the URI of the resource.
-
Element Details
-
name
String nameIntended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn’t present).- Default:
- ""
-
title
String titleOptional human-readable name of the prompt for display purposes.- Default:
- ""
-
uri
String urithe URI of the resource.- Default:
- ""
-
description
String descriptionA description of what this resource represents. This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.- Default:
- ""
-
mimeType
String mimeTypeThe MIME type of this resource, if known.- Default:
- "text/plain"
-
annotations
McpResource.McpAnnotations annotationsOptional annotations for the client. Note: The default annotations value is ignored.- Default:
- @org.springframework.ai.mcp.annotation.McpResource.McpAnnotations(audience={USER}, lastModified="", priority=0.5)
-
metaProvider
Class<? extends MetaProvider> metaProviderOptional meta provider class that supplies data for "_meta" field for this resource declaration. Defaults toDefaultMetaProviderimplementation.- Returns:
- the meta provider class to use for this resource
- Default:
- org.springframework.ai.mcp.annotation.context.DefaultMetaProvider.class
-
icons
McpIcon[] iconsOptional icons for clients that render a catalogue.- Since:
- 2.1.0
- Default:
- {}
-
size
long sizeOptional size of the resource content in bytes, when known up front.-1(the default) leaves it unset.- Since:
- 2.1.0
- Default:
- -1L
-
ttlMs
long ttlMsHow long, in milliseconds, a client may cache the result of reading this resource.0(the default) means the result must not be cached.Only honoured by the 2026-07-28 ("modern") MCP server, which puts the value into the
ttlMsfield of theresources/readresult when the method returns a legacy type. A method that returns a modernReadResourceResultsets its own hints and this attribute is ignored. The legacy servers log a warning and ignore it, because the legacy protocol has no cache hints.- Since:
- 2.1.0
- Default:
- 0L
-
cacheScope
io.modelcontextprotocol.modern.McpSchema.CacheScope cacheScopeWho may reuse a cached result of reading this resource.McpSchema.CacheScope.PRIVATE(the default) restricts reuse to the same authorization context.McpSchema.CacheScope.PUBLICasserts the result carries no user-specific data and may be served to any client.Only honoured by the 2026-07-28 ("modern") MCP server, under the same rules as
ttlMs().- Since:
- 2.1.0
- Default:
- PRIVATE
-
requiredCapabilities
McpClientCapability[] requiredCapabilitiesClient capabilities the resource cannot work without. A client whose request does not declare all of them is answered with JSON-RPC error-32021 Missing required client capability, listing the missing ones, before the method runs.Input the resource can do without is requested only when
McpModernSyncRequestContext.clientCapabilities()declares its capability, and needs no entry here.Only honoured by the 2026-07-28 ("modern") MCP server. The legacy servers ignore it, because their request context checks the capabilities the client sent at initialization.
experimentaland extension capabilities cannot be required this way; a method that depends on one is registered programmatically withClientCapabilities.- Since:
- 2.1.0
- Default:
- {}
-