Package io.modelcontextprotocol.server
Class McpStatelessSyncServer
java.lang.Object
io.modelcontextprotocol.server.McpStatelessSyncServer
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 TypeMethodDescriptionvoidaddPrompt(McpStatelessServerFeatures.SyncPromptSpecification promptSpecification) Add a new prompt handler at runtime.voidaddResource(McpStatelessServerFeatures.SyncResourceSpecification resourceSpecification) Add a new resource handler at runtime.voidaddResourceTemplate(McpStatelessServerFeatures.SyncResourceTemplateSpecification resourceTemplateSpecification) Add a new resource template.voidaddTool(McpStatelessServerFeatures.SyncToolSpecification 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.List all registered prompts.List all registered resources.List all registered resource templates.List all registered tools.voidremovePrompt(String promptName) Remove a prompt handler at runtime.voidremoveResource(String resourceUri) Remove a resource handler at runtime.voidremoveResourceTemplate(String uriTemplate) Remove a resource template.voidremoveTool(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
Add a new tool specification at runtime.- Parameters:
toolSpecification- The tool specification to add
-
listTools
List all registered tools.- Returns:
- A list of all registered tools
-
removeTool
Remove a tool handler at runtime.- Parameters:
toolName- The name of the tool handler to remove
-
addResource
Add a new resource handler at runtime.- Parameters:
resourceSpecification- The resource handler to add
-
listResources
List all registered resources.- Returns:
- A list of all registered resources
-
removeResource
Remove a resource handler at runtime.- Parameters:
resourceUri- The URI of the resource handler to remove
-
addResourceTemplate
public void addResourceTemplate(McpStatelessServerFeatures.SyncResourceTemplateSpecification resourceTemplateSpecification) Add a new resource template.- Parameters:
resourceTemplateSpecification- The resource template specification to add
-
listResourceTemplates
List all registered resource templates.- Returns:
- A list of all registered resource templates
-
removeResourceTemplate
Remove a resource template.- Parameters:
uriTemplate- The URI template of the resource template to remove
-
addPrompt
Add a new prompt handler at runtime.- Parameters:
promptSpecification- The prompt handler to add
-
listPrompts
List all registered prompts.- Returns:
- A list of all registered prompts
-
removePrompt
Remove a prompt handler at runtime.- Parameters:
promptName- The name of the prompt handler to remove
-