20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/rails_mcp_insight/tools/stats_overview.rb', line 20
def self.call(server_context:)
config = build_config(server_context)
detector = ProjectDetector.new(config)
info = detector.detect
route_analyzer = Analyzers::RouteAnalyzer.new(config)
gem_analyzer = Analyzers::GemAnalyzer.new(config)
test_analyzer = Analyzers::TestAnalyzer.new(config)
routes = route_analyzer.analyze
gems_info = gem_analyzer.analyze
test_stats = test_analyzer.coverage_stats
app_loc = count_lines(config.app_path)
test_loc = count_lines(config.spec_path) + count_lines(config.test_path)
result = {
project_path: config.project_path,
ruby_version: info[:ruby_version],
rails_version: info[:rails_version],
models: info[:model_count],
controllers: info[:controller_count],
jobs: info[:job_count],
mailers: info[:mailer_count],
migrations: info[:migration_count],
total_routes: routes.length,
gem_count: gems_info.is_a?(Hash) ? (gems_info[:total_gems] || 0) : 0,
lines_of_code: { app: app_loc, test: test_loc },
test_ratio: test_loc.zero? || app_loc.zero? ? 0 : (test_loc.to_f / app_loc).round(2),
test_coverage: test_stats,
has_rspec: info[:has_rspec],
has_minitest: info[:has_minitest]
}
MCP::Tool::Response.new([{
type: "text",
text: JSON.pretty_generate(result)
}])
end
|