Class: RailsMcpInsight::Tools::SearchRoutes

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/rails_mcp_insight/tools/search_routes.rb

Class Method Summary collapse

Class Method Details

.call(server_context:, query: nil, method: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_mcp_insight/tools/search_routes.rb', line 22

def self.call(server_context:, query: nil, method: nil)
  config = Configuration.new(project_path: server_context&.dig(:project_path) || Dir.pwd)
  analyzer = Analyzers::RouteAnalyzer.new(config)
  results = analyzer.search(query: query, method: method)

  MCP::Tool::Response.new([{
                            type: "text",
                            text: JSON.pretty_generate({ total: results.length, routes: results })
                          }])
end