public static class McpServerFeatures.SyncResourceSpecification
extends java.lang.Object
Example resource specification:
new McpServerFeatures.SyncResourceSpecification(
Resource.builder()
.uri("docs")
.name("Documentation files")
.title("Documentation files")
.mimeType("text/markdown")
.description("Markdown documentation files")
.build(),
(exchange, request) -> {
String content = readFile(request.getPath());
return new ReadResourceResult(content);
})
| 构造器和说明 |
|---|
SyncResourceSpecification(McpSchema.Resource resource,
java.util.function.BiFunction<McpSyncServerExchange,McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> readHandler) |
| 限定符和类型 | 方法和说明 |
|---|---|
java.util.function.BiFunction<McpSyncServerExchange,McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> |
readHandler() |
McpSchema.Resource |
resource() |
public SyncResourceSpecification(McpSchema.Resource resource, java.util.function.BiFunction<McpSyncServerExchange,McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> readHandler)
resource - The resource definition including name, description, and MIME typereadHandler - The function that handles resource read requests. The function's
first argument is an McpSyncServerExchange upon which the server can
interact with the connected client. The second arguments is a
McpSchema.ReadResourceRequest.public McpSchema.Resource resource()
public java.util.function.BiFunction<McpSyncServerExchange,McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> readHandler()