Module: Riffer::Mcp::Registry
- Defined in:
- lib/riffer/mcp/registry.rb
Overview
Thread-safe global store for MCP server registrations.
Keyed by manifest name. All public methods are mutex-guarded.
Class Method Summary collapse
-
.find_by_tags(tags) ⇒ Object
Returns all registrations whose manifest tags intersect with the given tags.
-
.register(manifest_or_hash) ⇒ Object
Registers an MCP server and starts async tool discovery.
-
.registrations ⇒ Object
Returns a frozen snapshot of all current registrations.
-
.unregister(name) ⇒ Object
Removes a registration by name.
Class Method Details
.find_by_tags(tags) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/riffer/mcp/registry.rb', line 55 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.
Accepts a Manifest instance or a hash of manifest keyword arguments. Replaces any existing registration with the same name.
– : ((Hash[Symbol, untyped] | Riffer::Mcp::Manifest)) -> Riffer::Mcp::Registration
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/riffer/mcp/registry.rb', line 20 def register(manifest_or_hash) manifest = manifest_or_hash.is_a?(Riffer::Mcp::Manifest) ? manifest_or_hash : Riffer::Mcp::Manifest.new(**manifest_or_hash) 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.
– : () -> Hash[String, Riffer::Mcp::Registration]
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.
– : ((String | Symbol)) -> void
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 |