public static class McpServer.StatelessSyncSpecification
extends java.lang.Object
构造器和说明 |
---|
StatelessSyncSpecification(McpStatelessServerTransport transport) |
限定符和类型 | 方法和说明 |
---|---|
McpStatelessSyncServer |
build() |
McpServer.StatelessSyncSpecification |
capabilities(McpSchema.ServerCapabilities serverCapabilities)
Sets the server capabilities that will be advertised to clients during
connection initialization.
|
McpServer.StatelessSyncSpecification |
completions(java.util.List<McpStatelessServerFeatures.SyncCompletionSpecification> completions)
Registers multiple completions with their handlers using a List.
|
McpServer.StatelessSyncSpecification |
completions(McpStatelessServerFeatures.SyncCompletionSpecification... completions)
Registers multiple completions with their handlers using varargs.
|
McpServer.StatelessSyncSpecification |
immediateExecution(boolean immediateExecution)
Enable on "immediate execution" of the operations on the underlying
McpStatelessAsyncServer . |
McpServer.StatelessSyncSpecification |
instructions(java.lang.String instructions)
Sets the server instructions that will be shared with clients during connection
initialization.
|
McpServer.StatelessSyncSpecification |
jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
Sets the JSON schema validator to use for validating tool and resource schemas.
|
McpServer.StatelessSyncSpecification |
objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets the object mapper to use for serializing and deserializing JSON messages.
|
McpServer.StatelessSyncSpecification |
prompts(java.util.List<McpStatelessServerFeatures.SyncPromptSpecification> prompts)
Registers multiple prompts with their handlers using a List.
|
McpServer.StatelessSyncSpecification |
prompts(java.util.Map<java.lang.String,McpStatelessServerFeatures.SyncPromptSpecification> prompts)
Registers multiple prompts with their handlers using a Map.
|
McpServer.StatelessSyncSpecification |
prompts(McpStatelessServerFeatures.SyncPromptSpecification... prompts)
Registers multiple prompts with their handlers using varargs.
|
McpServer.StatelessSyncSpecification |
requestTimeout(java.time.Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpServer.StatelessSyncSpecification |
resources(java.util.List<McpStatelessServerFeatures.SyncResourceSpecification> resourceSpecifications)
Registers multiple resources with their handlers using a List.
|
McpServer.StatelessSyncSpecification |
resources(java.util.Map<java.lang.String,McpStatelessServerFeatures.SyncResourceSpecification> resourceSpecifications)
Registers multiple resources with their handlers using a Map.
|
McpServer.StatelessSyncSpecification |
resources(McpStatelessServerFeatures.SyncResourceSpecification... resourceSpecifications)
Registers multiple resources with their handlers using varargs.
|
McpServer.StatelessSyncSpecification |
resourceTemplates(java.util.List<McpSchema.ResourceTemplate> resourceTemplates)
Sets the resource templates that define patterns for dynamic resource access.
|
McpServer.StatelessSyncSpecification |
resourceTemplates(McpSchema.ResourceTemplate... resourceTemplates)
Sets the resource templates using varargs for convenience.
|
McpServer.StatelessSyncSpecification |
serverInfo(McpSchema.Implementation serverInfo)
Sets the server implementation information that will be shared with clients
during connection initialization.
|
McpServer.StatelessSyncSpecification |
serverInfo(java.lang.String name,
java.lang.String version)
Sets the server implementation information using name and version strings.
|
McpServer.StatelessSyncSpecification |
toolCall(McpSchema.Tool tool,
java.util.function.BiFunction<McpTransportContext,McpSchema.CallToolRequest,McpSchema.CallToolResult> callHandler)
Adds a single tool with its implementation handler to the server.
|
McpServer.StatelessSyncSpecification |
tools(java.util.List<McpStatelessServerFeatures.SyncToolSpecification> toolSpecifications)
Adds multiple tools with their handlers to the server using a List.
|
McpServer.StatelessSyncSpecification |
tools(McpStatelessServerFeatures.SyncToolSpecification... toolSpecifications)
Adds multiple tools with their handlers to the server using varargs.
|
McpServer.StatelessSyncSpecification |
uriTemplateManagerFactory(McpUriTemplateManagerFactory uriTemplateManagerFactory)
Sets the URI template manager factory to use for creating URI templates.
|
public StatelessSyncSpecification(McpStatelessServerTransport transport)
public McpServer.StatelessSyncSpecification uriTemplateManagerFactory(McpUriTemplateManagerFactory uriTemplateManagerFactory)
uriTemplateManagerFactory
- The factory to use. Must not be null.java.lang.IllegalArgumentException
- if uriTemplateManagerFactory is nullpublic McpServer.StatelessSyncSpecification 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.StatelessSyncSpecification 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.StatelessSyncSpecification 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.StatelessSyncSpecification instructions(java.lang.String instructions)
instructions
- The instructions text. Can be null or empty.public McpServer.StatelessSyncSpecification capabilities(McpSchema.ServerCapabilities serverCapabilities)
serverCapabilities
- The server capabilities configuration. Must not be
null.java.lang.IllegalArgumentException
- if serverCapabilities is nullpublic McpServer.StatelessSyncSpecification toolCall(McpSchema.Tool tool, java.util.function.BiFunction<McpTransportContext,McpSchema.CallToolRequest,McpSchema.CallToolResult> callHandler)
McpServerFeatures.SyncToolSpecification
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 McpSyncServerExchange
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.StatelessSyncSpecification tools(java.util.List<McpStatelessServerFeatures.SyncToolSpecification> toolSpecifications)
toolSpecifications
- The list of tool specifications to add. Must not be
null.java.lang.IllegalArgumentException
- if toolSpecifications is nulltools(McpStatelessServerFeatures.SyncToolSpecification...)
public McpServer.StatelessSyncSpecification tools(McpStatelessServerFeatures.SyncToolSpecification... toolSpecifications)
Example usage:
.tools(
McpServerFeatures.SyncToolSpecification.builder().tool(calculatorTool).callTool(calculatorHandler).build(),
McpServerFeatures.SyncToolSpecification.builder().tool(weatherTool).callTool(weatherHandler).build(),
McpServerFeatures.SyncToolSpecification.builder().tool(fileManagerTool).callTool(fileManagerHandler).build()
)
toolSpecifications
- The tool specifications to add. Must not be null.java.lang.IllegalArgumentException
- if toolSpecifications is nullpublic McpServer.StatelessSyncSpecification resources(java.util.Map<java.lang.String,McpStatelessServerFeatures.SyncResourceSpecification> resourceSpecifications)
resourceSpecifications
- Map of resource name to specification. Must not
be null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullresources(McpStatelessServerFeatures.SyncResourceSpecification...)
public McpServer.StatelessSyncSpecification resources(java.util.List<McpStatelessServerFeatures.SyncResourceSpecification> resourceSpecifications)
resourceSpecifications
- List of resource specifications. Must not be
null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullresources(McpStatelessServerFeatures.SyncResourceSpecification...)
public McpServer.StatelessSyncSpecification resources(McpStatelessServerFeatures.SyncResourceSpecification... resourceSpecifications)
Example usage:
.resources(
new McpServerFeatures.SyncResourceSpecification(fileResource, fileHandler),
new McpServerFeatures.SyncResourceSpecification(dbResource, dbHandler),
new McpServerFeatures.SyncResourceSpecification(apiResource, apiHandler)
)
resourceSpecifications
- The resource specifications to add. Must not be
null.java.lang.IllegalArgumentException
- if resourceSpecifications is nullpublic McpServer.StatelessSyncSpecification 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.StatelessSyncSpecification resourceTemplates(McpSchema.ResourceTemplate... resourceTemplates)
resourceTemplates(List)
.resourceTemplates
- The resource templates to set.java.lang.IllegalArgumentException
- if resourceTemplates is null.resourceTemplates(List)
public McpServer.StatelessSyncSpecification prompts(java.util.Map<java.lang.String,McpStatelessServerFeatures.SyncPromptSpecification> prompts)
Example usage:
.prompts(Map.of("analysis", new McpServerFeatures.SyncPromptSpecification(
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.StatelessSyncSpecification prompts(java.util.List<McpStatelessServerFeatures.SyncPromptSpecification> prompts)
prompts
- List of prompt specifications. Must not be null.java.lang.IllegalArgumentException
- if prompts is nullprompts(McpStatelessServerFeatures.SyncPromptSpecification...)
public McpServer.StatelessSyncSpecification prompts(McpStatelessServerFeatures.SyncPromptSpecification... prompts)
Example usage:
.prompts(
new McpServerFeatures.SyncPromptSpecification(analysisPrompt, analysisHandler),
new McpServerFeatures.SyncPromptSpecification(summaryPrompt, summaryHandler),
new McpServerFeatures.SyncPromptSpecification(reviewPrompt, reviewHandler)
)
prompts
- The prompt specifications to add. Must not be null.java.lang.IllegalArgumentException
- if prompts is nullpublic McpServer.StatelessSyncSpecification completions(java.util.List<McpStatelessServerFeatures.SyncCompletionSpecification> completions)
completions
- List of completion specifications. Must not be null.java.lang.IllegalArgumentException
- if completions is nullpublic McpServer.StatelessSyncSpecification completions(McpStatelessServerFeatures.SyncCompletionSpecification... completions)
completions
- Array of completion specifications. Must not be null.java.lang.IllegalArgumentException
- if completions is nullpublic McpServer.StatelessSyncSpecification objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper
- the instance to use. Must not be null.java.lang.IllegalArgumentException
- if objectMapper is nullpublic McpServer.StatelessSyncSpecification jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
jsonSchemaValidator
- The validator to use. Must not be null.java.lang.IllegalArgumentException
- if jsonSchemaValidator is nullpublic McpServer.StatelessSyncSpecification immediateExecution(boolean immediateExecution)
McpStatelessAsyncServer
. Defaults to false, which does blocking code
offloading to prevent accidental blocking of the non-blocking transport.
Do NOT set to true if the underlying transport is a non-blocking implementation.
immediateExecution
- When true, do not offload work asynchronously.public McpStatelessSyncServer build()