Class McpToolListingCache
tools/list answer: the server's tools the caller's scopes allow,
memoised per distinct scope set, then stripped at every read of the tools an
administrator switched off.
The cached entry is built on the scope check alone and never asks the switched-off flag, so it holds no state that another node can change: a tool switched off or on anywhere is listed or dropped at the very next read, whatever this cache holds. The flag is asked once per listing.
The key holds the scopes and not the caller, on an invariant this cache
depends on: the door (McpServerOauthOpaqueTokenIntrospector) has
already refused any caller outside the MCP audience before a handler runs,
and the scope check answers on the global flag and the scopes alone -
all-or-nothing per user, never per tool - so every caller reaching the
listing with the same scopes sees the same list. Should the audience ever
become per-tool or per-group, the caller goes back into the key, and the map
then also needs an eviction policy: it only ever grows until a tool
definition changes.
-
Constructor Summary
ConstructorsConstructorDescriptionMcpToolListingCache(McpServerToolService toolService, Supplier<List<io.modelcontextprotocol.spec.McpSchema.Tool>> toolsSupplier) -
Method Summary
-
Constructor Details
-
McpToolListingCache
public McpToolListingCache(McpServerToolService toolService, Supplier<List<io.modelcontextprotocol.spec.McpSchema.Tool>> toolsSupplier) - Parameters:
toolService- the tool service, asked the scope check and the switched-off toolstoolsSupplier- the tools the MCP server exposes
-
-
Method Details
-
list
public reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ListToolsResult> list(org.springframework.security.core.Authentication authentication) - Parameters:
authentication- the caller's authentication, carrying the token's scopes asSCOPE_*authorities- Returns:
- the tools the caller's scopes allow, but the ones switched off
-
clear
public void clear()Drops every cached answer. Called when a tool definition changes, so a changed approval requirement is visible on the next listing.
-