public static class McpServer.StatelessAsyncSpecification
extends java.lang.Object
构造器和说明 |
---|
StatelessAsyncSpecification(McpStatelessServerTransport transport) |
限定符和类型 | 方法和说明 |
---|---|
McpStatelessAsyncServer |
build() |
McpServer.StatelessAsyncSpecification |
capabilities(McpSchema.ServerCapabilities serverCapabilities)
Sets the server capabilities that will be advertised to clients during
connection initialization.
|
McpServer.StatelessAsyncSpecification |
completions(java.util.List<McpStatelessServerFeatures.AsyncCompletionSpecification> completions)
Registers multiple completions with their handlers using a List.
|
McpServer.StatelessAsyncSpecification |
completions(McpStatelessServerFeatures.AsyncCompletionSpecification... completions)
Registers multiple completions with their handlers using varargs.
|
McpServer.StatelessAsyncSpecification |
instructions(java.lang.String instructions)
Sets the server instructions that will be shared with clients during connection
initialization.
|
McpServer.StatelessAsyncSpecification |
jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
Sets the JSON schema validator to use for validating tool and resource schemas.
|
McpServer.StatelessAsyncSpecification |
objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets the object mapper to use for serializing and deserializing JSON messages.
|
McpServer.StatelessAsyncSpecification |
prompts(java.util.List<McpStatelessServerFeatures.AsyncPromptSpecification> prompts)
Registers multiple prompts with their handlers using a List.
|
McpServer.StatelessAsyncSpecification |
prompts(java.util.Map<java.lang.String,McpStatelessServerFeatures.AsyncPromptSpecification> prompts)
Registers multiple prompts with their handlers using a Map.
|
McpServer.StatelessAsyncSpecification |
prompts(McpStatelessServerFeatures.AsyncPromptSpecification... prompts)
Registers multiple prompts with their handlers using varargs.
|
McpServer.StatelessAsyncSpecification |
requestTimeout(java.time.Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpServer.StatelessAsyncSpecification |
resources(java.util.List<McpStatelessServerFeatures.AsyncResourceSpecification> resourceSpecifications)
Registers multiple resources with their handlers using a List.
|
McpServer.StatelessAsyncSpecification |
resources(java.util.Map<java.lang.String,McpStatelessServerFeatures.AsyncResourceSpecification> resourceSpecifications)
Registers multiple resources with their handlers using a Map.
|
McpServer.StatelessAsyncSpecification |
resources(McpStatelessServerFeatures.AsyncResourceSpecification... resourceSpecifications)
Registers multiple resources with their handlers using varargs.
|
McpServer.StatelessAsyncSpecification |
resourceTemplates(java.util.List<McpSchema.ResourceTemplate> resourceTemplates)
Sets the resource templates that define patterns for dynamic resource access.
|
McpServer.StatelessAsyncSpecification |
resourceTemplates(McpSchema.ResourceTemplate... resourceTemplates)
Sets the resource templates using varargs for convenience.
|
McpServer.StatelessAsyncSpecification |
serverInfo(McpSchema.Implementation serverInfo)
Sets the server implementation information that will be shared with clients
during connection initialization.
|
McpServer.StatelessAsyncSpecification |
serverInfo(java.lang.String name,
java.lang.String version)
Sets the server implementation information using name and version strings.
|
McpServer.StatelessAsyncSpecification |
toolCall(McpSchema.Tool tool,
java.util.function.BiFunction<McpTransportContext,McpSchema.CallToolRequest,reactor.core.publisher.Mono<McpSchema.CallToolResult>> callHandler)
Adds a single tool with its implementation handler to the server.
|
McpServer.StatelessAsyncSpecification |
tools(java.util.List<McpStatelessServerFeatures.AsyncToolSpecification> toolSpecifications)
Adds multiple tools with their handlers to the server using a List.
|
McpServer.StatelessAsyncSpecification |
tools(McpStatelessServerFeatures.AsyncToolSpecification... toolSpecifications)
Adds multiple tools with their handlers to the server using varargs.
|
McpServer.StatelessAsyncSpecification |
uriTemplateManagerFactory(McpUriTemplateManagerFactory uriTemplateManagerFactory)
Sets the URI template manager factory to use for creating URI templates.
|
public StatelessAsyncSpecification(McpStatelessServerTransport transport)
public McpServer.StatelessAsyncSpecification uriTemplateManagerFactory(McpUriTemplateManagerFactory uriTemplateManagerFactory)
uriTemplateManagerFactory
- The factory to use. Must not be null.java.lang.IllegalArgumentException
- if uriTemplateManagerFactory is nullpublic McpServer.StatelessAsyncSpecification requestTimeout(java.time.Duration requestTimeout)
requestTimeout
- The duration to wait before timing out requests. Must not
be null.java.lang.IllegalArgumentException
- if requestTimeout is nullpublic McpServer.StatelessAsyncSpecification serverInfo(McpSchema.Implementation serverInfo)
serverInfo
- The server implementation details including name and version.
Must not be null.java.lang.IllegalArgumentException
- if serverInfo is nullpublic McpServer.StatelessAsyncSpecification serverInfo(java.lang.String name, java.lang.String version)
serverInfo(McpSchema.Implementation)
.name
- The server name. Must not be null or empty.version
- The server version. Must not be null or empty.java.lang.IllegalArgumentException
- if name or version is null or emptyserverInfo(McpSchema.Implementation)
public McpServer.StatelessAsyncSpecification instructions(java.lang.String instructions)
instructions
- The instructions text. Can be null or empty.public McpServer.StatelessAsyncSpecification capabilities(McpSchema.ServerCapabilities serverCapabilities)
serverCapabilities
- The server capabilities configuration. Must not be
null.java.lang.IllegalArgumentException
- if serverCapabilities is nullpublic McpServer.StatelessAsyncSpecification toolCall(McpSchema.Tool tool, java.util.function.BiFunction<McpTransportContext,McpSchema.CallToolRequest,reactor.core.publisher.Mono<McpSchema.CallToolResult>> callHandler)
McpServerFeatures.AsyncToolSpecification
explicitly.tool
- The tool definition including name, description, and schema. Must
not be null.callHandler
- The function that implements the tool's logic. Must not be
null. The function's first argument is an McpAsyncServerExchange
upon
which the server can interact with the connected client. The second argument is
the McpSchema.CallToolRequest
object containing the tool calljava.lang.IllegalArgumentException
- if tool or handler is nullpublic McpServer.StatelessAsyncSpecification tools(java.util.List<McpStatelessServerFeatures.AsyncToolSpecification> toolSpecifications)
toolSpecifications
- The list of tool specifications to add. Must not be
null.java.lang.IllegalArgumentException
- if toolSpecifications is nulltools(McpStatelessServerFeatures.AsyncToolSpecification...)
public McpServer.StatelessAsyncSpecification tools(McpStatelessServerFeatures.AsyncToolSpecification... toolSpecifications)
Example usage:
.tools(
McpServerFeatures.AsyncToolSpecification.builder().tool(calculatorTool).callTool(calculatorHandler).build(),
McpServerFeatures.AsyncToolSpecification.builder().tool(weatherTool).callTool(weatherHandler).build(),
McpServerFeatures.AsyncToolSpecification.builder().tool(fileManagerTool).callTool(fileManagerHandler).build()
)
toolSpecifications
- The tool specifications to add. Must not be null.java.lang.IllegalArgumentException
- if toolSpecifications is nullpublic McpServer.StatelessAsyncSpecification resources(java.util.Map<java.lang.String,McpStatelessServerFeatures.AsyncResourceSpecification> resourceSpecifications)
resourceSpecifications
- Map of resource name to specification. Must not
be null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullresources(McpStatelessServerFeatures.AsyncResourceSpecification...)
public McpServer.StatelessAsyncSpecification resources(java.util.List<McpStatelessServerFeatures.AsyncResourceSpecification> resourceSpecifications)
resourceSpecifications
- List of resource specifications. Must not be
null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullresources(McpStatelessServerFeatures.AsyncResourceSpecification...)
public McpServer.StatelessAsyncSpecification resources(McpStatelessServerFeatures.AsyncResourceSpecification... resourceSpecifications)
Example usage:
.resources(
new McpServerFeatures.AsyncResourceSpecification(fileResource, fileHandler),
new McpServerFeatures.AsyncResourceSpecification(dbResource, dbHandler),
new McpServerFeatures.AsyncResourceSpecification(apiResource, apiHandler)
)
resourceSpecifications
- The resource specifications to add. Must not be
null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullpublic McpServer.StatelessAsyncSpecification resourceTemplates(java.util.List<McpSchema.ResourceTemplate> resourceTemplates)
Example usage:
.resourceTemplates(
new ResourceTemplate("file://{path}", "Access files by path"),
new ResourceTemplate("db://{table}/{id}", "Access database records")
)
resourceTemplates
- List of resource templates. If null, clears existing
templates.java.lang.IllegalArgumentException
- if resourceTemplates is null.#resourceTemplates(ResourceTemplate...)
public McpServer.StatelessAsyncSpecification resourceTemplates(McpSchema.ResourceTemplate... resourceTemplates)
resourceTemplates(List)
.resourceTemplates
- The resource templates to set.java.lang.IllegalArgumentException
- if resourceTemplates is null.resourceTemplates(List)
public McpServer.StatelessAsyncSpecification prompts(java.util.Map<java.lang.String,McpStatelessServerFeatures.AsyncPromptSpecification> prompts)
Example usage:
.prompts(Map.of("analysis", new McpServerFeatures.AsyncPromptSpecification(
new Prompt("analysis", "Code analysis template"),
request -> Mono.fromSupplier(() -> generateAnalysisPrompt(request))
.map(GetPromptResult::new)
)));
prompts
- Map of prompt name to specification. Must not be null.java.lang.IllegalArgumentException
- if prompts is nullpublic McpServer.StatelessAsyncSpecification prompts(java.util.List<McpStatelessServerFeatures.AsyncPromptSpecification> prompts)
prompts
- List of prompt specifications. Must not be null.java.lang.IllegalArgumentException
- if prompts is nullprompts(McpStatelessServerFeatures.AsyncPromptSpecification...)
public McpServer.StatelessAsyncSpecification prompts(McpStatelessServerFeatures.AsyncPromptSpecification... prompts)
Example usage:
.prompts(
new McpServerFeatures.AsyncPromptSpecification(analysisPrompt, analysisHandler),
new McpServerFeatures.AsyncPromptSpecification(summaryPrompt, summaryHandler),
new McpServerFeatures.AsyncPromptSpecification(reviewPrompt, reviewHandler)
)
prompts
- The prompt specifications to add. Must not be null.java.lang.IllegalArgumentException
- if prompts is nullpublic McpServer.StatelessAsyncSpecification completions(java.util.List<McpStatelessServerFeatures.AsyncCompletionSpecification> completions)
completions
- List of completion specifications. Must not be null.java.lang.IllegalArgumentException
- if completions is nullpublic McpServer.StatelessAsyncSpecification completions(McpStatelessServerFeatures.AsyncCompletionSpecification... completions)
completions
- Array of completion specifications. Must not be null.java.lang.IllegalArgumentException
- if completions is nullpublic McpServer.StatelessAsyncSpecification objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper
- the instance to use. Must not be null.java.lang.IllegalArgumentException
- if objectMapper is nullpublic McpServer.StatelessAsyncSpecification jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
jsonSchemaValidator
- The validator to use. Must not be null.java.lang.IllegalArgumentException
- if jsonSchemaValidator is nullpublic McpStatelessAsyncServer build()