Class InMemoryAsyncToolRepository
java.lang.Object
org.springframework.ai.mcp.modern.InMemoryAsyncToolRepository
- All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpAsyncToolRepository
public final class InMemoryAsyncToolRepository
extends Object
implements io.modelcontextprotocol.modern.server.feature.McpAsyncToolRepository
The asynchronous twin of
InMemorySyncToolRepository: a
McpAsyncToolRepository that keeps McpAsyncTools in a sorted, concurrent
map. Tools can be added and removed at runtime; each change is broadcast as
notifications/tools/list_changed when a change broadcaster is configured.
Listings are paged by name with an opaque key cursor when a page size is set.- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(io.modelcontextprotocol.modern.server.feature.McpAsyncTool tool) Adds a tool and notifies listening clients.builder()reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.McpAsyncTool>reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.ToolsPage>booleanRemoves a tool by name and notifies listening clients.
-
Method Details
-
builder
-
add
public void add(io.modelcontextprotocol.modern.server.feature.McpAsyncTool tool) Adds a tool and notifies listening clients.- Throws:
IllegalArgumentException- if a tool with the same name exists
-
remove
Removes a tool by name and notifies listening clients.- Returns:
- whether a tool was removed
-
list
public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.ToolsPage> list(io.modelcontextprotocol.modern.server.McpRequestContext ctx, @Nullable String cursor) - Specified by:
listin interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncToolRepository
-
find
public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.McpAsyncTool> find(io.modelcontextprotocol.modern.server.McpRequestContext ctx, String name) - Specified by:
findin interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncToolRepository
-