Class: RailsMcpInsight::Tools::FindDefinition

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

Class Method Summary collapse

Class Method Details

.call(symbol:, server_context:, type: nil) ⇒ Object



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

def self.call(symbol:, server_context:, type: nil)
  config = Configuration.new(project_path: server_context&.dig(:project_path) || Dir.pwd)
  searcher = Analyzers::CodeSearcher.new(config)
  results = searcher.find_definition(symbol: symbol, type: type)

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