Class: McpToolkit::Authority::RegistryToolProvider
- Inherits:
-
Object
- Object
- McpToolkit::Authority::RegistryToolProvider
- Defined in:
- lib/mcp_toolkit/authority/registry_tool_provider.rb
Overview
A tool_provider (the dispatcher's api-agnostic seam) that serves the four
GENERIC, Registry-backed tools — resources, resource_schema, get, list —
over the resources a host registered in config.registry. It is the authority-
path counterpart to the satellite's SDK tools (McpToolkit::Tools::*): same
generic contract (discover resources, learn a shape, read one/many rows, all
account-scoped and read-only), but plugged into the hand-rolled dispatcher.
Satisfies the provider contract the dispatcher calls:
tool_definitions(context) -> the four static generic tool definitions
find(name) -> a tool instance bound to this config, or nil
The top-level definitions are context-independent (per-resource visibility and
scope are enforced inside each tool at call time), so tool_definitions ignores
the context. Compose this with bespoke host tools via CompositeToolProvider.
Constant Summary collapse
- TOOLS =
BASE tool name (the api-agnostic identity of each generic tool) => the tool class. The four generic read tools; nothing here names an app concept. The name actually advertised in
tools/listand matched intools/callis this base name PREFIXED withconfig.generic_tool_name_prefix(empty by default, so the bare base name), letting a host namespace its generic tools. { "resources" => McpToolkit::Authority::Tools::Resources, "resource_schema" => McpToolkit::Authority::Tools::ResourceSchema, "get" => McpToolkit::Authority::Tools::Get, "list" => McpToolkit::Authority::Tools::List }.freeze
Instance Method Summary collapse
-
#find(name) ⇒ Object
A tool instance bound to this provider's config, or nil for an unknown name.
-
#initialize(config:) ⇒ RegistryToolProvider
constructor
A new instance of RegistryToolProvider.
-
#tool_definitions(_context) ⇒ Object
The four static generic tool definitions (context-independent), each advertised under its PREFIXED name so
tools/listshows the host's namespaced names.
Constructor Details
#initialize(config:) ⇒ RegistryToolProvider
Returns a new instance of RegistryToolProvider.
30 31 32 |
# File 'lib/mcp_toolkit/authority/registry_tool_provider.rb', line 30 def initialize(config:) @config = config end |
Instance Method Details
#find(name) ⇒ Object
A tool instance bound to this provider's config, or nil for an unknown name. The incoming name is matched against the PREFIXED names: the prefix is stripped to recover the base tool, so a name that does not carry the configured prefix (e.g. a sibling provider's unprefixed tool) is left for another provider.
44 45 46 47 48 |
# File 'lib/mcp_toolkit/authority/registry_tool_provider.rb', line 44 def find(name) base_name = base_name_for(name.to_s) klass = base_name && TOOLS[base_name] klass&.new(config: @config) end |
#tool_definitions(_context) ⇒ Object
The four static generic tool definitions (context-independent), each advertised
under its PREFIXED name so tools/list shows the host's namespaced names.
36 37 38 |
# File 'lib/mcp_toolkit/authority/registry_tool_provider.rb', line 36 def tool_definitions(_context) TOOLS.map { |base_name, klass| klass.definition.merge(name: prefixed(base_name)) } end |