Package io.modelcontextprotocol.server
Class McpStatelessAsyncServer
java.lang.Object
io.modelcontextprotocol.server.McpStatelessAsyncServer
A stateless MCP server implementation for use with Streamable HTTP transport types. It
allows simple horizontal scalability since it does not maintain a session and does not
require initialization. Each instance of the server can be reached with no prior
knowledge and can serve the clients with the capabilities it supports.
- Author:
- Dariusz Jędrzejczyk
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>addPrompt(McpStatelessServerFeatures.AsyncPromptSpecification promptSpecification) Add a new prompt handler at runtime.reactor.core.publisher.Mono<Void>addResource(McpStatelessServerFeatures.AsyncResourceSpecification resourceSpecification) Add a new resource handler at runtime.reactor.core.publisher.Mono<Void>addTool(McpStatelessServerFeatures.AsyncToolSpecification toolSpecification) Add a new tool specification at runtime.voidclose()Close the server immediately.reactor.core.publisher.Mono<Void>Gracefully closes the server, allowing any in-progress operations to complete.Get the server capabilities that define the supported features and functionality.Get the server implementation information.reactor.core.publisher.Mono<Void>removePrompt(String promptName) Remove a prompt handler at runtime.reactor.core.publisher.Mono<Void>removeResource(String resourceUri) Remove a resource handler at runtime.reactor.core.publisher.Mono<Void>removeTool(String toolName) Remove a tool handler at runtime.
-
Method Details
-
getServerCapabilities
Get the server capabilities that define the supported features and functionality.- Returns:
- The server capabilities
-
getServerInfo
Get the server implementation information.- Returns:
- The server implementation details
-
closeGracefully
Gracefully closes the server, allowing any in-progress operations to complete.- Returns:
- A Mono that completes when the server has been closed
-
close
public void close()Close the server immediately. -
addTool
public reactor.core.publisher.Mono<Void> addTool(McpStatelessServerFeatures.AsyncToolSpecification toolSpecification) Add a new tool specification at runtime.- Parameters:
toolSpecification- The tool specification to add- Returns:
- Mono that completes when clients have been notified of the change
-
removeTool
Remove a tool handler at runtime.- Parameters:
toolName- The name of the tool handler to remove- Returns:
- Mono that completes when clients have been notified of the change
-
addResource
public reactor.core.publisher.Mono<Void> addResource(McpStatelessServerFeatures.AsyncResourceSpecification resourceSpecification) Add a new resource handler at runtime.- Parameters:
resourceSpecification- The resource handler to add- Returns:
- Mono that completes when clients have been notified of the change
-
removeResource
Remove a resource handler at runtime.- Parameters:
resourceUri- The URI of the resource handler to remove- Returns:
- Mono that completes when clients have been notified of the change
-
addPrompt
public reactor.core.publisher.Mono<Void> addPrompt(McpStatelessServerFeatures.AsyncPromptSpecification promptSpecification) Add a new prompt handler at runtime.- Parameters:
promptSpecification- The prompt handler to add- Returns:
- Mono that completes when clients have been notified of the change
-
removePrompt
Remove a prompt handler at runtime.- Parameters:
promptName- The name of the prompt handler to remove- Returns:
- Mono that completes when clients have been notified of the change
-