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 value of the name attribute and "text/plain".
Example usage:
@McpResource(uri = "weather://forecast/{city}/{date}")
public String getWeather() {
// Method implementation...
}
- Author:
- codeboyzhou
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe 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.
-
Element Details
-
uri
String uriThe URI of the resource.- Returns:
- the URI of the resource
-
-
-
name
String nameThe name of the resource. Defaults to the name of the annotated method.- Returns:
- the name of the resource
- Default:
- ""
-
title
String titleThe title of the resource. Defaults to the value of thenameattribute.- Returns:
- the title of the resource
- Default:
- ""
-
description
String descriptionThe description of the resource. Defaults to the value of thenameattribute.- Returns:
- the description of the resource
- Default:
- ""
-
mimeType
String mimeTypeThe MIME type of the resource. Defaults to "text/plain".- Returns:
- the MIME type of the resource
- Default:
- "text/plain"
-
roles
io.modelcontextprotocol.spec.McpSchema.Role[] rolesThe roles required to access the resource. Defaults toMcpSchema.Role.ASSISTANTandMcpSchema.Role.USER.- Returns:
- the roles required to access the resource
- Default:
- {ASSISTANT, USER}
-
priority
double priorityThe priority of the resource. Defaults to 1.0.- Returns:
- the priority of the resource
- Default:
- 1.0
-