Module: Evilution::MCP::InfoTool::ResponseFormatter

Defined in:
lib/evilution/mcp/info_tool/response_formatter.rb

Class Method Summary collapse

Class Method Details

.error(type, message) ⇒ Object



27
28
29
30
31
32
# File 'lib/evilution/mcp/info_tool/response_formatter.rb', line 27

def error(type, message)
  ::MCP::Tool::Response.new(
    [{ type: "text", text: ::JSON.generate({ error: { type: type, message: message } }) }],
    error: true
  )
end

.error_for(exception) ⇒ Object



34
35
36
# File 'lib/evilution/mcp/info_tool/response_formatter.rb', line 34

def error_for(exception)
  error(Evilution::MCP::InfoTool::ErrorMapper.type_for(exception), exception.message)
end

.success(payload) ⇒ Object

Wraps the payload as a successful MCP text response and injects the outer-envelope schema_version so agents that cache contracts can detect incompatible servers. Existing schema_version keys in the payload are preserved (e.g. session JSON keeps its own schema_version unchanged).



14
15
16
17
# File 'lib/evilution/mcp/info_tool/response_formatter.rb', line 14

def success(payload)
  versioned = inject_schema_version(payload)
  ::MCP::Tool::Response.new([{ type: "text", text: ::JSON.generate(versioned) }])
end