Class: RailVerdict::MCP::Tools::InspectHandoff

Inherits:
Object
  • Object
show all
Defined in:
lib/rail_verdict/mcp/tools/inspect_handoff.rb

Instance Method Summary collapse

Constructor Details

#initialize(server:) ⇒ InspectHandoff

Returns a new instance of InspectHandoff.



7
8
9
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 7

def initialize(server:)
  @server = server
end

Instance Method Details

#call(handoff: nil, handoff_json: nil, **_rest) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 51

def call(handoff: nil, handoff_json: nil, **_rest)
  text = if handoff_json && !handoff_json.to_s.strip.empty?
           handoff_json.to_s
         elsif handoff
           JSON.generate(handoff)
         else
           return Serializers.error_response("handoff or handoff_json is required", code: "invalid_arguments")
         end
  return Serializers.error_response("handoff too large", code: "handoff_too_large") if text.bytesize > Handoff::MAX_DOCUMENT_BYTES
  doc, err = Handoff.parse(text)
  if doc
    Serializers.tool_response({ "valid" => true, "handoff" => Serializers.scrub(doc), "handoff_id" => doc["handoff_id"] }, error: false)
  else
    Serializers.tool_response({ "valid" => false, "error" => err.to_s, "handoff" => nil }, error: false)
  end
rescue StandardError => e
  Serializers.error_response("inspect_handoff failed: #{e.message}", code: "internal_error")
end

#tool_annotationsObject



47
48
49
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 47

def tool_annotations
  { read_only_hint: true, destructive_hint: false, idempotent_hint: true, open_world_hint: false, title: tool_title }
end

#tool_descriptionObject



19
20
21
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 19

def tool_description
  "Parse and validate a Verification Handoff. Bounded, deterministic, tamper-detected via handoff_id. Does not execute analyzers."
end

#tool_input_schemaObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 23

def tool_input_schema
  {
    type: "object",
    properties: {
      handoff: { type: "object", description: "Handoff document to inspect" },
      handoff_json: { type: "string", description: "Handoff JSON string (alternative to handoff object)" }
    },
    additionalProperties: false
  }
end

#tool_nameObject



11
12
13
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 11

def tool_name
  "inspect_handoff"
end

#tool_output_schemaObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 34

def tool_output_schema
  {
    type: "object",
    properties: {
      valid: { type: "boolean" },
      handoff: { type: ["object", "null"] },
      error: { type: "string" },
      handoff_id: { type: "string" }
    },
    required: %w[valid]
  }
end

#tool_titleObject



15
16
17
# File 'lib/rail_verdict/mcp/tools/inspect_handoff.rb', line 15

def tool_title
  "Inspect verification handoff"
end