Class: PromptObjects::Connectors::MCP::Tools::RespondToRequest

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/prompt_objects/connectors/mcp.rb

Overview

Respond to a capability-approval request.

Class Method Summary collapse

Class Method Details

.call(request_id:, response:, server_context:) ⇒ Object



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/prompt_objects/connectors/mcp.rb', line 435

def self.call(request_id:, response:, server_context:)
  env = server_context[:env]

  success = env.human_queue.respond(request_id, response)

  if success
    ::MCP::Tool::Response.new([{
      type: "text",
      text: JSON.generate({ success: true, request_id: request_id })
    }])
  else
    ::MCP::Tool::Response.new([{
      type: "text",
      text: JSON.generate({ error: "Request not found or already responded", request_id: request_id })
    }])
  end
end