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
34
35
36
37
38
|
# File 'lib/rails-mcp-server/tools/project_info.rb', line 7
def call
unless current_project
message = "No active project. Please switch to a project first."
log(:warn, message)
return message
end
gemfile_path = File.join(active_project_path, "Gemfile")
gemfile_content = File.exist?(gemfile_path) ? File.read(gemfile_path) : "Gemfile not found"
rails_version = gemfile_content.match(/gem ['"]rails['"],\s*['"](.+?)['"]/)&.captures&.first || "Unknown"
config_application_path = File.join(active_project_path, "config", "application.rb")
is_api_only = File.exist?(config_application_path) &&
File.read(config_application_path).include?("config.api_only = true")
log(:info, "Project info: Rails v#{rails_version}, API-only: #{is_api_only}")
" Current project: \#{current_project}\n Path: \#{active_project_path}\n Rails version: \#{rails_version}\n API only: \#{is_api_only ? \"Yes\" : \"No\"}\n \n Project structure:\n \#{get_directory_structure(active_project_path, max_depth: 2)}\n INFO\nend\n"
|