Class: Insika::Commands::RefreshMcpTools

Inherits:
Object
  • Object
show all
Defined in:
lib/insika/commands/refresh_mcp_tools.rb

Overview

Control command: LIVE re-discovery of an MCP instance's tools. Delegates to McpToolRegistry#refresh (connect + tools/list + write McpStore#tools_cache) — TOOL EXECUTION never reads that cache; this command only refreshes what entries/Studio/doctor display. The CLI verb / API route / Studio button that call it are later work (PR3/PR4) — the command itself is the seam they'll share. -> { instance:, tools: [name,description,inputSchema, ...] }.

Instance Method Summary collapse

Constructor Details

#initialize(mcp_registry:, event_stream:) ⇒ RefreshMcpTools

Returns a new instance of RefreshMcpTools.



15
16
17
18
# File 'lib/insika/commands/refresh_mcp_tools.rb', line 15

def initialize(mcp_registry:, event_stream:)
  @mcp_registry = mcp_registry
  @event_stream = event_stream
end

Instance Method Details

#call(command) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/insika/commands/refresh_mcp_tools.rb', line 20

def call(command)
  p = symbolize(command.payload)
  name = Insika::Coercion.presence(p[:name]) ||
         (raise Insika::ValidationError, "refresh_mcp_tools: 'name' (MCP instance) is required")

  tools = @mcp_registry.refresh(name)
  emit(name, tools)
  { instance: name, tools: tools }
end