4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/rails-mcp-server/analyzers/get_routes.rb', line 4
def call(controller: nil, verb: nil, path_contains: nil, named_only: false, detail_level: "full")
unless current_project
message = "No active project. Please switch to a project first."
log(:warn, message)
return message
end
detail_level = "full" unless %w[names summary full].include?(detail_level)
routes_data = fetch_routes_via_introspection
if routes_data[:error]
log(:warn, "Error fetching routes: #{routes_data[:error]}")
return "Error fetching routes: #{routes_data[:error]}"
end
routes = routes_data[:routes] || []
routes = filter_routes(routes, controller: controller, verb: verb, path_contains: path_contains, named_only: named_only)
if routes.empty?
message = "No routes found"
message += " matching filters" if controller || verb || path_contains || named_only
return message
end
log(:debug, "Found #{routes.size} matching routes")
format_routes(routes, detail_level)
end
|