Class: PromptObjects::MCP::Tools::SendMessage
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- PromptObjects::MCP::Tools::SendMessage
- Defined in:
- lib/prompt_objects/mcp/tools/send_message.rb
Overview
Send a message to a prompt object and get its response
Class Method Summary collapse
Class Method Details
.call(po_name:, message:, thread_id: nil, workspace_session_id: nil, client_request_id: nil, deadline: nil, server_context:) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/prompt_objects/mcp/tools/send_message.rb', line 42 def self.call(po_name:, message:, thread_id: nil, workspace_session_id: nil, client_request_id: nil, deadline: nil, server_context:) env = server_context[:env] po = env.registry.get(po_name) unless po.is_a?(PromptObjects::PromptObject) return ::MCP::Tool::Response.new([{ type: "text", text: JSON.generate({ error: "Prompt object '#{po_name}' not found" }) }]) end run, response = env.( target_po: po_name, content: , from_source: "service:mcp", workspace_session_id: workspace_session_id, thread_id: thread_id, client_request_id: client_request_id, deadline: deadline, tui_mode: true ) history_length = Repositories::MessageRepository.new(env.session_store) .list(thread_id: run.thread_id, limit: 10_000).length ::MCP::Tool::Response.new([{ type: "text", text: JSON.generate({ po_name: po_name, response: response, workspace_session_id: run.workspace_session_id, thread_id: run.thread_id, run_id: run.id, status: run.status, history_length: history_length }) }]) end |