Annotation Interface McpResource


Declares an exact-URI or URI-template MCP resource-read handler.

A URI containing RFC 6570 Level 1 variables is a template registration; each variable is bound to exactly one McpResourceUriParameter method parameter. An exact URI contributes a descriptor to the static resources/list fallback. A URI template is advertised separately by resources/templates/list.

Level 1 simple variables cannot consume a raw slash: file:///{path} matches file:///src%2Fmain.rs, yielding src/main.rs, but not file:///src/main.rs. Reserved expansion ({+path}), explode and prefix modifiers are unsupported. Captured values are UTF-8 percent-decoded exactly once.

Author:
Mark Allen
  • Element Details

    • protocolVersions

      Returns:
      the required exact MCP revisions on which this resource is available
    • uri

      The absolute resource URI or RFC 6570 Level 1 URI template.
      Returns:
      resource URI or URI template
    • name

      The resource name published to MCP clients.
      Returns:
      nonblank resource name
    • title

      The optional human-readable resource title.
      Returns:
      title, or an empty string if none is configured
      Default:
      ""
    • description

      The optional human-readable resource description.
      Returns:
      description, or an empty string if none is configured
      Default:
      ""
    • mimeType

      The optional resource MIME type.
      Returns:
      MIME type, or an empty string if none is configured
      Default:
      ""
    • sizeInBytes

      The raw size of an exact resource in bytes.

      URI templates cannot declare a size because their concrete resources may differ. The default -1 means that no size is published.

      Returns:
      nonnegative exact-resource size, or -1 when absent
      Default:
      -1L
    • cacheTimeToLiveInMilliseconds

      The default cache time to live for reads through this registration.
      Returns:
      nonnegative whole-millisecond time to live
      Default:
      0L
    • cacheScope

      The fixed cache scope for reads through this registration.
      Returns:
      cache scope
      Default:
      PRIVATE
    • mayRequestInput

      Client requests this resource-read operation may emit during multi-round-trip handling.

      A nonempty declaration requires the method to return McpOperationResult or a subtype.

      Returns:
      input-request declarations
      Default:
      {}
    • requestStateMode

      The request-state contract for this resource-read operation.

      A mode other than McpRequestStateMode.NONE requires the method to return McpOperationResult or a subtype.

      Returns:
      request-state mode
      Default:
      NONE