Class InMemoryAsyncPromptRepository
java.lang.Object
org.springframework.ai.mcp.modern.InMemoryAsyncPromptRepository
- All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpAsyncPromptRepository
public final class InMemoryAsyncPromptRepository
extends Object
implements io.modelcontextprotocol.modern.server.feature.McpAsyncPromptRepository
The asynchronous twin of
InMemorySyncPromptRepository: a
McpAsyncPromptRepository that keeps McpAsyncPrompts in a sorted,
concurrent map. Prompts can be added and removed at runtime; each change is broadcast
as notifications/prompts/list_changed when a change broadcaster is configured.
Listings are paged by name with an opaque key cursor when a page size is set.
Completion is served from the completionHandler of each prompt, and is
advertised unless the repository is built with completionSupported(false).- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(io.modelcontextprotocol.modern.server.feature.McpAsyncPrompt prompt) Adds a prompt and notifies listening clients.builder()reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.McpAsyncPrompt>reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.PromptsPage>booleanRemoves a prompt by name and notifies listening clients.boolean
-
Method Details
-
builder
-
add
public void add(io.modelcontextprotocol.modern.server.feature.McpAsyncPrompt prompt) Adds a prompt and notifies listening clients.- Throws:
IllegalArgumentException- if a prompt with the same name exists
-
remove
Removes a prompt by name and notifies listening clients.- Returns:
- whether a prompt was removed
-
list
public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.PromptsPage> list(io.modelcontextprotocol.modern.server.McpRequestContext ctx, @Nullable String cursor) - Specified by:
listin interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncPromptRepository
-
find
public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.feature.McpAsyncPrompt> find(io.modelcontextprotocol.modern.server.McpRequestContext ctx, String name) - Specified by:
findin interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncPromptRepository
-
supportsCompletion
public boolean supportsCompletion()- Specified by:
supportsCompletionin interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncPromptRepository
-