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).
57 58 59 60 61 62 |
# File 'lib/riffer/mcp/registry.rb', line 57 def () normalized = .map(&:to_sym) @mutex.synchronize do @store.values.select { |reg| reg.manifest..intersect?(normalized) } 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 31 32 33 34 |
# 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 = if manifest_or_hash.is_a?(Riffer::Mcp::Manifest) manifest_or_hash else Riffer::Mcp::Manifest.new(**manifest_or_hash) # steep:ignore InsufficientKeywordArguments end 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.
--
49 50 51 |
# File 'lib/riffer/mcp/registry.rb', line 49 def registrations @mutex.synchronize { @store.dup.freeze } end |
#unregister(name) ⇒ Object
Removes a registration by name.
--
40 41 42 43 |
# File 'lib/riffer/mcp/registry.rb', line 40 def unregister(name) removed = @mutex.synchronize { @store.delete(name.to_s) } removed&.retire! end |