Module: Riffer::Mcp::Registry
Overview
Thread-safe global store for MCP server registrations, keyed by manifest name.
Instance Method Summary collapse
-
#find_by_tags(tags) ⇒ Object
Returns all registrations whose manifest tags intersect the given tags (normalized to symbols).
-
#register(manifest_or_hash) ⇒ Object
Registers an MCP server and starts async tool discovery, replacing any existing registration with the same name.
-
#registrations ⇒ Object
Returns a frozen snapshot of all current registrations.
-
#unregister(name) ⇒ Object
Removes a registration by name.
Instance Method Details
#find_by_tags(tags) ⇒ Object
Returns all registrations whose manifest tags intersect the given tags (normalized to symbols).
53 54 55 56 57 58 |
# File 'lib/riffer/mcp/registry.rb', line 53 def () normalized = .map(&:to_sym) @mutex.synchronize do @store.values.select { |reg| (reg.manifest. & normalized).any? } end end |
#register(manifest_or_hash) ⇒ Object
Registers an MCP server and starts async tool discovery, replacing any existing registration with the same name.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/riffer/mcp/registry.rb', line 18 def register(manifest_or_hash) # steep cannot verify that an untyped Hash splat supplies Manifest's # required name:/endpoint: keywords; Manifest validates them at runtime. manifest = manifest_or_hash.is_a?(Riffer::Mcp::Manifest) ? manifest_or_hash : Riffer::Mcp::Manifest.new(**manifest_or_hash) # steep:ignore InsufficientKeywordArguments registration = Riffer::Mcp::Registration.new(manifest) old = @mutex.synchronize do previous = @store[manifest.name] @store[manifest.name] = registration previous end old&.retire! registration end |
#registrations ⇒ Object
Returns a frozen snapshot of all current registrations.
--
45 46 47 |
# File 'lib/riffer/mcp/registry.rb', line 45 def registrations @mutex.synchronize { @store.dup.freeze } end |
#unregister(name) ⇒ Object
Removes a registration by name.
--
36 37 38 39 |
# File 'lib/riffer/mcp/registry.rb', line 36 def unregister(name) removed = @mutex.synchronize { @store.delete(name.to_s) } removed&.retire! end |