Class: Insika::Commands::DeleteMcp
- Inherits:
-
Object
- Object
- Insika::Commands::DeleteMcp
- Defined in:
- lib/insika/commands/delete_mcp.rb
Overview
Control command: removes an MCP instance from the
McpStore. Idempotent (existed: false if there was none). Evicts any
memoized client for this name — a removed instance stops answering
tool calls right away, not after a restart. -> { existed: bool }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(mcp_store:, event_stream:, mcp_registry: nil) ⇒ DeleteMcp
constructor
A new instance of DeleteMcp.
Constructor Details
#initialize(mcp_store:, event_stream:, mcp_registry: nil) ⇒ DeleteMcp
Returns a new instance of DeleteMcp.
12 13 14 15 16 |
# File 'lib/insika/commands/delete_mcp.rb', line 12 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/insika/commands/delete_mcp.rb', line 18 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) raise Insika::ValidationError, "name is required" if name.nil? existed = @mcp_store.delete(name) @mcp_registry&.evict(name) @event_stream.emit(Insika::Event.new( type: :mcp_deleted, data: { name: name, existed: existed }, meta: { at: Time.now.utc.iso8601 } )) { existed: existed } end |