Class: Insika::Commands::UpsertMcp
- Inherits:
-
Object
- Object
- Insika::Commands::UpsertMcp
- 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). Evicts any memoized client for this name (mcp_registry is
optional so a bare CLI/store-only caller need not wire one) so an edited
command/url/env takes effect on the instance's next call — no restart.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(mcp_store:, event_stream:, mcp_registry: nil) ⇒ UpsertMcp
constructor
A new instance of UpsertMcp.
Constructor Details
#initialize(mcp_store:, event_stream:, mcp_registry: nil) ⇒ UpsertMcp
Returns a new instance of UpsertMcp.
15 16 17 18 19 |
# File 'lib/insika/commands/upsert_mcp.rb', line 15 def initialize(mcp_store:, event_stream:, mcp_registry: nil) @mcp_store = mcp_store @event_stream = event_stream @mcp_registry = mcp_registry end |
Instance Method Details
#call(command) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/insika/commands/upsert_mcp.rb', line 21 def call(command) p = AgentPayload.symbolize(command.payload) masked = @mcp_store.upsert(p) # validates `name`; returns masked @mcp_registry&.evict(masked["name"]) @event_stream.emit(Insika::Event.new( type: :mcp_upserted, data: { name: masked["name"], enabled: masked["enabled"] }, meta: { at: Time.now.utc.iso8601 } )) masked end |