Class: Riffer::Mcp::Registration
- Inherits:
-
Object
- Object
- Riffer::Mcp::Registration
- Defined in:
- lib/riffer/mcp/registration.rb,
sig/generated/riffer/mcp/registration.rbs
Overview
Per-server state managed by Riffer::Mcp::Registry — discovers tools via
tools/list and generates tool classes when a server is registered.
Instance Attribute Summary collapse
-
#manifest ⇒ Riffer::Mcp::Manifest
readonly
The manifest that describes this server.
Instance Method Summary collapse
-
#build_client ⇒ Riffer::Mcp::Client
-- : () -> Riffer::Mcp::Client.
-
#initialize(manifest) ⇒ Registration
constructor
-- : (Riffer::Mcp::Manifest) -> void.
-
#retire! ⇒ void
Retires this registration, preventing in-flight discovery from publishing state.
-
#retired? ⇒ Boolean
Returns true if this registration has been retired.
-
#run_discovery ⇒ void
-- : () -> void.
-
#tools ⇒ Array[singleton(Riffer::Mcp::Tool)]
Generated Riffer::Mcp::Tool subclasses.
Constructor Details
#initialize(manifest) ⇒ Registration
-- : (Riffer::Mcp::Manifest) -> void
24 25 26 27 28 29 30 |
# File 'lib/riffer/mcp/registration.rb', line 24 def initialize(manifest) @manifest = manifest @cancelled = false @tools = [] #: Array[singleton(Riffer::Mcp::Tool)] @mutex = Mutex.new run_discovery end |
Instance Attribute Details
#manifest ⇒ Riffer::Mcp::Manifest (readonly)
The manifest that describes this server.
12 13 14 |
# File 'lib/riffer/mcp/registration.rb', line 12 def manifest @manifest end |
Instance Method Details
#build_client ⇒ Riffer::Mcp::Client
-- : () -> Riffer::Mcp::Client
67 68 69 |
# File 'lib/riffer/mcp/registration.rb', line 67 def build_client Riffer::Mcp::Client.new(endpoint: @manifest.endpoint, headers: @manifest.discovery_headers || {}) end |
#retire! ⇒ void
This method returns an undefined value.
Retires this registration, preventing in-flight discovery from publishing state.
-- : () -> void
37 38 39 |
# File 'lib/riffer/mcp/registration.rb', line 37 def retire! @mutex.synchronize { @cancelled = true } end |
#retired? ⇒ Boolean
Returns true if this registration has been retired.
-- : () -> bool
45 46 47 |
# File 'lib/riffer/mcp/registration.rb', line 45 def retired? @mutex.synchronize { @cancelled } end |
#run_discovery ⇒ void
This method returns an undefined value.
-- : () -> void
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/riffer/mcp/registration.rb', line 53 def run_discovery Riffer.config.mcp.discovery_runner.map([nil], context: nil) do |_| client = build_client tool_defs = client.tools_list tools = Riffer::Mcp::ToolFactory.build(@manifest.name, client, tool_defs) @mutex.synchronize do @tools = tools.freeze unless @cancelled end end end |
#tools ⇒ Array[singleton(Riffer::Mcp::Tool)]
Generated Riffer::Mcp::Tool subclasses.
-- : () -> Array
18 19 20 |
# File 'lib/riffer/mcp/registration.rb', line 18 def tools @mutex.synchronize { @tools } end |