Annotation Interface McpResource


@Target(METHOD) @Retention(RUNTIME) public @interface McpResource
This annotation is used to mark a method as an MCP (Model Context Protocol) resource method.

The resource's URI must be specified explicitly. Resource metadata such as name, title, description, and MIME type can be specified via the corresponding attributes. If omitted, these metadata fields will default to the literal string "Not specified" and "text/plain".

Example usage:


 @McpResource(uri = "weather://forecast/{city}/{date}")
 public String getWeather() {
     // Method implementation...
 }
 
作者:
codeboyzhou
另请参阅:
  • 必需元素概要

    所需元素
    修饰符和类型
    必需的元素
    说明
    The URI of the resource.
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    The description of the resource.
    The MIME type of the resource.
    The name of the resource.
    double
    The priority of the resource.
    io.modelcontextprotocol.spec.McpSchema.Role[]
    The roles required to access the resource.
    The title of the resource.
  • 元素详细资料

    • uri

      String uri
      The URI of the resource.
      返回:
      the URI of the resource
    • name

      String name
      The name of the resource. Defaults to the name of the annotated method.
      返回:
      the name of the resource
      默认值:
      ""
    • title

      String title
      The title of the resource. Defaults to the literal string "Not specified".
      返回:
      the title of the resource
      默认值:
      ""
    • description

      String description
      The description of the resource. Defaults to the literal string "Not specified".
      返回:
      the description of the resource
      默认值:
      ""
    • mimeType

      String mimeType
      The MIME type of the resource. Defaults to "text/plain".
      返回:
      the MIME type of the resource
      默认值:
      "text/plain"
    • roles

      io.modelcontextprotocol.spec.McpSchema.Role[] roles
      The roles required to access the resource. Defaults to McpSchema.Role.ASSISTANT and McpSchema.Role.USER.
      返回:
      the roles required to access the resource
      默认值:
      {ASSISTANT, USER}
    • priority

      double priority
      The priority of the resource. Defaults to 1.0.
      返回:
      the priority of the resource
      默认值:
      1.0