Annotation 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 description of the resource.The MIME type of the resource.The name of the resource.doubleThe priority of the resource.io.modelcontextprotocol.spec.McpSchema.Role[]The roles required to access the resource.The title of the resource.
-
元素详细资料
-
uri
String uriThe URI of the resource.- 返回:
- the URI of the resource
-
-
-
name
String nameThe name of the resource. Defaults to the name of the annotated method.- 返回:
- the name of the resource
- 默认值:
- ""
-
title
String titleThe title of the resource. Defaults to the literal string "Not specified".- 返回:
- the title of the resource
- 默认值:
- ""
-
description
String descriptionThe description of the resource. Defaults to the literal string "Not specified".- 返回:
- the description of the resource
- 默认值:
- ""
-
mimeType
String mimeTypeThe MIME type of the resource. Defaults to "text/plain".- 返回:
- the MIME type of the resource
- 默认值:
- "text/plain"
-
roles
io.modelcontextprotocol.spec.McpSchema.Role[] rolesThe roles required to access the resource. Defaults toMcpSchema.Role.ASSISTANTandMcpSchema.Role.USER.- 返回:
- the roles required to access the resource
- 默认值:
- {ASSISTANT, USER}
-
priority
double priorityThe priority of the resource. Defaults to 1.0.- 返回:
- the priority of the resource
- 默认值:
- 1.0
-