ToolRegistry
Thread-safe collection of registered McpTools, keyed by McpTool.name. Backed by a ConcurrentHashMap so tools can be registered and invoked concurrently. Also tracks a host-controlled runtime gate (see setDisabledTools) that hides/blocks tools without unregistering them.
This is the single source of truth the transports and McpProtocol read from for tools/list and tools/call.
Functions
Names currently gated off.
Execute the named tool with params. Returns a tool_disabled error if the tool is gated off, an Unknown tool error if it isn't registered, and converts any exception thrown by McpTool.execute into a failed ToolResult — this method never throws.
Tools currently visible to clients — registered and not gated off.
All registered tools, regardless of gate state. See listEnabledTools for the client-visible set.
Register tool, replacing any existing tool with the same McpTool.name.
Register every tool in toolList (e.g. the output of a module provider's all(context)).
Replace the entire disabled set in one atomic swap (e.g. from a checkbox grid). @Synchronized on the same monitor as setToolEnabled so a full replace can't interleave with a single-tool toggle and lose its update.
Enable or disable a single tool by name. @Synchronized so concurrent single-tool toggles don't lose updates in the copy-on-write swap.