Module: Legion::Catalog
- Defined in:
- lib/legion/catalog.rb
Class Method Summary collapse
- .collect_mcp_tools ⇒ Object
- .register_tools(catalog_url:, api_key:) ⇒ Object
- .register_workers(catalog_url:, api_key:, workers:) ⇒ Object
Class Method Details
.collect_mcp_tools ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/legion/catalog.rb', line 23 def collect_mcp_tools return [] unless defined?(Legion::MCP) && Legion::MCP.respond_to?(:tools) Legion::MCP.tools.map { |t| { name: t[:name], description: t[:description] } } rescue StandardError => e Legion::Logging.warn "Catalog#collect_mcp_tools failed: #{e.}" if defined?(Legion::Logging) [] end |
.register_tools(catalog_url:, api_key:) ⇒ Object
9 10 11 12 13 |
# File 'lib/legion/catalog.rb', line 9 def register_tools(catalog_url:, api_key:) tools = collect_mcp_tools Legion::Logging.info "[Catalog] registering #{tools.size} tools to #{catalog_url}" if defined?(Legion::Logging) post_json("#{catalog_url}/api/tools", { tools: tools }, api_key) end |
.register_workers(catalog_url:, api_key:, workers:) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/legion/catalog.rb', line 15 def register_workers(catalog_url:, api_key:, workers:) entries = workers.map do |w| { id: w[:worker_id], status: w[:status], capabilities: w[:capabilities] || [] } end Legion::Logging.info "[Catalog] registering #{entries.size} workers to #{catalog_url}" if defined?(Legion::Logging) post_json("#{catalog_url}/api/workers", { workers: entries }, api_key) end |