39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/debug_mcp/tools/rails_routes.rb', line 39
def call(controller: nil, path: nil, session_id: nil, server_context:)
client = server_context[:session_manager].client(session_id)
client.auto_repause!
RailsHelper.require_rails!(client)
text = fetch_routes_base64(client, controller, path)
return MCP::Tool::Response.new([{ type: "text", text: text }]) if text
text = fetch_routes_lightweight(client, controller, path)
return MCP::Tool::Response.new([{ type: "text", text: text }]) if text
text = "Routes: unavailable."
text += "\n\n#{RailsHelper::TRAP_CONTEXT_HINT}" if RailsHelper.trap_context?(client)
MCP::Tool::Response.new([{ type: "text", text: text }])
rescue DebugMcp::Error => e
text = "Error: #{e.message}"
text += "\n\n#{RailsHelper::TRAP_CONTEXT_HINT}" if begin
RailsHelper.trap_context?(client)
rescue StandardError
false
end
MCP::Tool::Response.new([{ type: "text", text: text }])
end
|