Class: Insika::Commands::UpsertMcp

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

Overview

Control command: creates/edits an MCP instance (transport/command/url/enabled + env credentials) in the McpStore. The credentials are sentinel-aware per key (OCULTO preserves; "" clears; a new string replaces). Returns the MASKED record (env never comes back in plaintext). Durable config CRUD — running an MCP client against the instance is later runtime.

Instance Method Summary collapse

Constructor Details

#initialize(mcp_store:, event_stream:) ⇒ UpsertMcp

Returns a new instance of UpsertMcp.



14
15
16
17
# File 'lib/insika/commands/upsert_mcp.rb', line 14

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

Instance Method Details

#call(command) ⇒ Object



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

def call(command)
  p = AgentPayload.symbolize(command.payload)
  masked = @mcp_store.upsert(p) # validates `name`; returns masked

  @event_stream.emit(Insika::Event.new(
                       type: :mcp_upserted,
                       data: { name: masked["name"], enabled: masked["enabled"] },
                       meta: { at: Time.now.utc.iso8601 }
                     ))
  masked
end