Module: OmnifocusMcp::Tools::Definitions::McpEnvelope

Defined in:
lib/omnifocus_mcp/tools/definitions/mcp_envelope.rb

Defined Under Namespace

Classes: ToolReply

Class Method Summary collapse

Class Method Details

.safely(scope, custom_message: nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/omnifocus_mcp/tools/definitions/mcp_envelope.rb', line 19

def safely(scope, custom_message: nil)
  result = yield
  result.is_a?(ToolReply) ? result.to_envelope : result
rescue StandardError => e
  default = "Error #{scope}: #{e.message}"
  OmnifocusMcp.logger.warn(default)
  text_error(custom_message || default)
end

.text_error(text) ⇒ Object



17
# File 'lib/omnifocus_mcp/tools/definitions/mcp_envelope.rb', line 17

def text_error(text) = { content: [{ type: "text", text: text }], isError: true }

.text_result(text) ⇒ Object



15
# File 'lib/omnifocus_mcp/tools/definitions/mcp_envelope.rb', line 15

def text_result(text) = { content: [{ type: "text", text: text }] }