Class InMemorySyncPromptRepository

java.lang.Object
org.springframework.ai.mcp.modern.InMemorySyncPromptRepository
All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository

public final class InMemorySyncPromptRepository extends Object implements io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository
A McpSyncPromptRepository that keeps McpSyncPrompts 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.
Since:
2.1.0
Author:
Christian Tzolov
  • Method Details

    • builder

      public static InMemorySyncPromptRepository.Builder builder()
    • add

      public void add(io.modelcontextprotocol.modern.server.feature.McpSyncPrompt prompt)
      Adds a prompt and notifies listening clients.
      Throws:
      IllegalArgumentException - if a prompt with the same name exists
    • remove

      public boolean remove(String name)
      Removes a prompt by name and notifies listening clients.
      Returns:
      whether a prompt was removed
    • list

      public io.modelcontextprotocol.modern.server.feature.PromptsPage list(io.modelcontextprotocol.modern.server.McpRequestContext ctx, @Nullable String cursor)
      Specified by:
      list in interface io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository
    • find

      public @Nullable io.modelcontextprotocol.modern.server.feature.McpSyncPrompt find(io.modelcontextprotocol.modern.server.McpRequestContext ctx, String name)
      Specified by:
      find in interface io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository