rails-active-mcp 2.0.8 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +141 -0
- data/README.md +3 -3
- data/exe/rails-active-mcp-server +8 -8
- data/gemfiles/rails_6.0.gemfile +34 -0
- data/gemfiles/rails_6.1.gemfile +34 -0
- data/gemfiles/rails_7.0.gemfile +34 -0
- data/gemfiles/rails_7.1.gemfile +22 -22
- data/gemfiles/rails_7.2.gemfile +34 -0
- data/lib/generators/rails_active_mcp/install/install_generator.rb +44 -94
- data/lib/generators/rails_active_mcp/install/templates/rails-active-mcp-server +104 -0
- data/lib/generators/rails_active_mcp/install/templates/rails-active-mcp-wrapper +94 -0
- data/lib/rails_active_mcp/configuration.rb +44 -4
- data/lib/rails_active_mcp/console_executor.rb +185 -83
- data/lib/rails_active_mcp/engine.rb +2 -2
- data/lib/rails_active_mcp/garbage_collection_utils.rb +13 -0
- data/lib/rails_active_mcp/safety_checker.rb +17 -7
- data/lib/rails_active_mcp/sdk/server.rb +1 -1
- data/lib/rails_active_mcp/sdk/tools/console_execute_tool.rb +0 -2
- data/lib/rails_active_mcp/sdk/tools/dry_run_tool.rb +0 -2
- data/lib/rails_active_mcp/sdk/tools/model_info_tool.rb +1 -3
- data/lib/rails_active_mcp/sdk/tools/safe_query_tool.rb +0 -2
- data/lib/rails_active_mcp/tasks.rake +6 -6
- data/lib/rails_active_mcp/version.rb +1 -1
- data/lib/rails_active_mcp.rb +4 -3
- data/mcp.ru +2 -2
- data/rails_active_mcp.gemspec +4 -4
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fee611445971a5e113a23146281a9f2a68d0c8c0690213df2704ee7fb80f7700
|
4
|
+
data.tar.gz: ce6ba7ab86616fd0a5a0e60aff50e9c4e8f29101a9866597e1dfd99ef2c6ee85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 312b0f2384b4cc7a57b0be9284a52c559897d10e31487eb859cd70b9e5dc385a1005a245cff4a42b7d3abe7f0480b1fdcd8caa317e7ff2388fbeb635ed447c13
|
7
|
+
data.tar.gz: 875467cc1ad75645d32607f2c6c3a98951807da776b626dc113f186720fc6042fe90303fe19ae8c230f036a2a085e6caa1e38e518da0a3ef71356d2cbbce10fd
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
plugins:
|
2
|
+
- rubocop-rails
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
SuggestExtensions: false
|
8
|
+
TargetRubyVersion: 3.1
|
9
|
+
Exclude:
|
10
|
+
- 'bin/bundle'
|
11
|
+
- 'bin/setup'
|
12
|
+
- 'vendor/**/*'
|
13
|
+
- 'tmp/**/*'
|
14
|
+
- 'db/schema.rb'
|
15
|
+
- 'log/**/*'
|
16
|
+
|
17
|
+
# Documentation is not always necessary for utility classes and tools
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Allow longer classes for main functionality classes
|
22
|
+
Metrics/ClassLength:
|
23
|
+
Max: 400
|
24
|
+
Exclude:
|
25
|
+
- 'bin/*'
|
26
|
+
|
27
|
+
# Allow longer methods for setup/configuration methods
|
28
|
+
Metrics/MethodLength:
|
29
|
+
Max: 50
|
30
|
+
Exclude:
|
31
|
+
- 'bin/*'
|
32
|
+
- 'lib/generators/**/*'
|
33
|
+
|
34
|
+
# Allow higher complexity for main execution methods
|
35
|
+
Metrics/AbcSize:
|
36
|
+
Max: 55
|
37
|
+
Exclude:
|
38
|
+
- 'bin/*'
|
39
|
+
|
40
|
+
Metrics/CyclomaticComplexity:
|
41
|
+
Max: 15
|
42
|
+
|
43
|
+
Metrics/PerceivedComplexity:
|
44
|
+
Max: 15
|
45
|
+
|
46
|
+
# Allow longer blocks in specs and configuration
|
47
|
+
Metrics/BlockLength:
|
48
|
+
Max: 50
|
49
|
+
Exclude:
|
50
|
+
- 'spec/**/*'
|
51
|
+
- 'lib/rails_active_mcp/tasks.rake'
|
52
|
+
- 'lib/generators/**/*'
|
53
|
+
|
54
|
+
# Allow longer lines for error messages and documentation
|
55
|
+
Layout/LineLength:
|
56
|
+
Max: 150
|
57
|
+
Exclude:
|
58
|
+
- 'bin/*'
|
59
|
+
- 'exe/*'
|
60
|
+
|
61
|
+
# Disable some style checks that are too strict for utility scripts
|
62
|
+
Lint/UnusedMethodArgument:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# Allow safe navigation preference but don't enforce it everywhere
|
66
|
+
Style/SafeNavigation:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
# Allow both single and double quotes
|
70
|
+
Style/StringLiterals:
|
71
|
+
EnforcedStyle: single_quotes
|
72
|
+
|
73
|
+
# Don't enforce frozen string literals in every file
|
74
|
+
Style/FrozenStringLiteralComment:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
# Allow numeric comparisons with zero
|
78
|
+
Style/NumericPredicate:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
# Rails specific configurations
|
82
|
+
Rails:
|
83
|
+
Enabled: true
|
84
|
+
|
85
|
+
# RSpec specific configurations
|
86
|
+
RSpec:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
# Gemspec specific configurations
|
90
|
+
Gemspec/DevelopmentDependencies:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
# Allow some duplication in methods that handle similar cases
|
94
|
+
Lint/DuplicateMethods:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Lint/DuplicateBranch:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
# RSpec specific overrides for test quality
|
101
|
+
RSpec/MultipleExpectations:
|
102
|
+
Max: 5
|
103
|
+
|
104
|
+
RSpec/ExampleLength:
|
105
|
+
Max: 15
|
106
|
+
|
107
|
+
RSpec/DescribeClass:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
RSpec/InstanceVariable:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
RSpec/BeforeAfterAll:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
RSpec/VerifiedDoubles:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
RSpec/MessageSpies:
|
120
|
+
Enabled: false
|
121
|
+
|
122
|
+
RSpec/MessageChain:
|
123
|
+
Enabled: false
|
124
|
+
|
125
|
+
RSpec/ReceiveMessages:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
RSpec/ScatteredSetup:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
RSpec/SpecFilePathFormat:
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
# Allow Time.zone vs Time.now flexibility
|
135
|
+
Rails/TimeZone:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
# Naming conventions - allow short parameter names in specs/tools
|
139
|
+
Naming/MethodParameterName:
|
140
|
+
Exclude:
|
141
|
+
- 'spec/**/*'
|
data/README.md
CHANGED
@@ -24,13 +24,13 @@ gem 'rails-active-mcp'
|
|
24
24
|
And then execute:
|
25
25
|
|
26
26
|
```bash
|
27
|
-
|
27
|
+
bundle install
|
28
28
|
```
|
29
29
|
|
30
30
|
Run the installer:
|
31
31
|
|
32
32
|
```bash
|
33
|
-
|
33
|
+
rails generate rails_active_mcp:install
|
34
34
|
```
|
35
35
|
|
36
36
|
This will:
|
@@ -298,4 +298,4 @@ The gem is available as open source under the [MIT License](https://opensource.o
|
|
298
298
|
|
299
299
|
### Previous Versions
|
300
300
|
|
301
|
-
See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
|
301
|
+
See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
|
data/exe/rails-active-mcp-server
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
# Require essential gems first
|
5
5
|
require 'json'
|
6
6
|
require 'stringio'
|
7
|
+
require 'fileutils'
|
7
8
|
|
8
9
|
# CRITICAL: Redirect stdout IMMEDIATELY for stdio mode to prevent any output interference
|
9
10
|
# This must happen before any other gem loading
|
10
11
|
original_stdout = $stdout
|
11
|
-
original_stderr = $stderr
|
12
12
|
|
13
13
|
# Determine if we should redirect output (stdio mode or explicit request)
|
14
14
|
should_redirect = (ARGV.first == 'stdio' || ARGV.first.nil?) && !ENV['RAILS_MCP_DEBUG']
|
@@ -16,7 +16,7 @@ should_redirect = (ARGV.first == 'stdio' || ARGV.first.nil?) && !ENV['RAILS_MCP_
|
|
16
16
|
if should_redirect
|
17
17
|
# Create log directory early
|
18
18
|
log_dir = File.join(Dir.pwd, 'log')
|
19
|
-
|
19
|
+
FileUtils.mkdir_p(log_dir)
|
20
20
|
|
21
21
|
# Redirect stderr to log file immediately, before any loading
|
22
22
|
stderr_log = File.join(log_dir, 'rails_mcp_stderr.log')
|
@@ -74,8 +74,8 @@ end
|
|
74
74
|
|
75
75
|
# Parse command line options
|
76
76
|
transport = ARGV[0] || 'stdio'
|
77
|
-
|
78
|
-
|
77
|
+
ARGV.include?('--port') ? ARGV[ARGV.index('--port') + 1].to_i : 3001
|
78
|
+
ARGV.include?('--host') ? ARGV[ARGV.index('--host') + 1] : 'localhost'
|
79
79
|
|
80
80
|
# Determine and set correct working directory
|
81
81
|
def find_rails_root(start_dir = Dir.pwd)
|
@@ -116,7 +116,9 @@ elsif rails_root.nil?
|
|
116
116
|
warn "[#{Time.now}] [RAILS-MCP] ERROR: Could not locate Gemfile in current directory: #{Dir.pwd}"
|
117
117
|
warn "[#{Time.now}] [RAILS-MCP] ERROR: Please ensure you're running from a Rails application root directory"
|
118
118
|
warn "[#{Time.now}] [RAILS-MCP] ERROR: Current directory contents:"
|
119
|
-
Dir.entries('.').each
|
119
|
+
Dir.entries('.').each do |entry|
|
120
|
+
warn "[#{Time.now}] [RAILS-MCP] ERROR: #{entry}" unless entry.start_with?('.')
|
121
|
+
end
|
120
122
|
exit(1)
|
121
123
|
end
|
122
124
|
end
|
@@ -132,9 +134,7 @@ when 'stdio'
|
|
132
134
|
require_relative '../lib/rails_active_mcp/sdk/server'
|
133
135
|
|
134
136
|
# Log startup information
|
135
|
-
if should_redirect
|
136
|
-
warn "[#{Time.now}] [RAILS-MCP] INFO: Starting Rails Active MCP Server v#{RailsActiveMcp::VERSION}"
|
137
|
-
end
|
137
|
+
warn "[#{Time.now}] [RAILS-MCP] INFO: Starting Rails Active MCP Server v#{RailsActiveMcp::VERSION}" if should_redirect
|
138
138
|
warn "[#{Time.now}] [RAILS-MCP] INFO: Rails loaded: #{rails_loaded}" if should_redirect
|
139
139
|
if rails_load_error && should_redirect
|
140
140
|
warn "[#{Time.now}] [RAILS-MCP] WARNING: Rails load error: #{rails_load_error.class.name}: #{rails_load_error.message}"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rails 6.0 Gemfile for CI testing
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
# Specify the Rails version
|
5
|
+
gem 'rails', '~> 6.0'
|
6
|
+
|
7
|
+
# Include the main gemspec
|
8
|
+
gemspec path: '../'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'byebug'
|
12
|
+
gem 'database_cleaner-active_record', '~> 2.1'
|
13
|
+
gem 'factory_bot_rails', '~> 6.0'
|
14
|
+
gem 'rspec', '~> 3.1'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sqlite3', '~> 2.7'
|
17
|
+
gem 'timecop', '~> 0.9.8'
|
18
|
+
gem 'webmock', '~> 3.19'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'redcarpet' # For YARD markdown support
|
23
|
+
gem 'rubocop', '~> 1.77'
|
24
|
+
gem 'rubocop-rails', '~> 2.32'
|
25
|
+
gem 'rubocop-rspec'
|
26
|
+
gem 'simplecov', '~> 0.22'
|
27
|
+
gem 'yard'
|
28
|
+
end
|
29
|
+
|
30
|
+
# For testing the gem in a Rails app
|
31
|
+
gem 'sprockets-rails' # Required for Rails 7+
|
32
|
+
|
33
|
+
# Official MCP Ruby SDK for migration
|
34
|
+
gem 'mcp', '~> 0.1.0'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rails 6.0 Gemfile for CI testing
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
# Specify the Rails version
|
5
|
+
gem 'rails', '~> 6.0'
|
6
|
+
|
7
|
+
# Include the main gemspec
|
8
|
+
gemspec path: '../'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'byebug'
|
12
|
+
gem 'database_cleaner-active_record', '~> 2.1'
|
13
|
+
gem 'factory_bot_rails', '~> 6.0'
|
14
|
+
gem 'rspec', '~> 3.1'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sqlite3', '~> 2.7'
|
17
|
+
gem 'timecop', '~> 0.9.8'
|
18
|
+
gem 'webmock', '~> 3.19'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'redcarpet' # For YARD markdown support
|
23
|
+
gem 'rubocop', '~> 1.77'
|
24
|
+
gem 'rubocop-rails', '~> 2.32'
|
25
|
+
gem 'rubocop-rspec'
|
26
|
+
gem 'simplecov', '~> 0.22'
|
27
|
+
gem 'yard'
|
28
|
+
end
|
29
|
+
|
30
|
+
# For testing the gem in a Rails app
|
31
|
+
gem 'sprockets-rails' # Required for Rails 7+
|
32
|
+
|
33
|
+
# Official MCP Ruby SDK for migration
|
34
|
+
gem 'mcp', '~> 0.1.0'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rails 7.0 Gemfile for CI testing
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
# Specify the Rails version
|
5
|
+
gem 'rails', '~> 7.0.0'
|
6
|
+
|
7
|
+
# Include the main gemspec
|
8
|
+
gemspec path: '../'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'byebug'
|
12
|
+
gem 'database_cleaner-active_record', '~> 2.1'
|
13
|
+
gem 'factory_bot_rails', '~> 6.0'
|
14
|
+
gem 'rspec', '~> 3.1'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sqlite3', '~> 2.7'
|
17
|
+
gem 'timecop', '~> 0.9.8'
|
18
|
+
gem 'webmock', '~> 3.19'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'redcarpet' # For YARD markdown support
|
23
|
+
gem 'rubocop', '~> 1.77'
|
24
|
+
gem 'rubocop-rails', '~> 2.32'
|
25
|
+
gem 'rubocop-rspec'
|
26
|
+
gem 'simplecov', '~> 0.22'
|
27
|
+
gem 'yard'
|
28
|
+
end
|
29
|
+
|
30
|
+
# For testing the gem in a Rails app
|
31
|
+
gem 'sprockets-rails' # Required for Rails 7+
|
32
|
+
|
33
|
+
# Official MCP Ruby SDK for migration
|
34
|
+
gem 'mcp', '~> 0.1.0'
|
data/gemfiles/rails_7.1.gemfile
CHANGED
@@ -7,28 +7,28 @@ gem 'rails', '~> 7.1.0'
|
|
7
7
|
# Include the main gemspec
|
8
8
|
gemspec path: '../'
|
9
9
|
|
10
|
-
# Rails 7.1 specific dependencies
|
11
|
-
gem 'importmap-rails', '>= 1.0'
|
12
|
-
gem 'sprockets-rails', '>= 3.4.0'
|
13
|
-
gem 'stimulus-rails', '>= 1.0'
|
14
|
-
gem 'turbo-rails', '>= 1.0'
|
15
|
-
|
16
|
-
# Database adapters
|
17
|
-
gem 'mysql2', '~> 0.5'
|
18
|
-
gem 'pg', '~> 1.1'
|
19
|
-
gem 'sqlite3', '~> 1.6'
|
20
|
-
|
21
|
-
# Testing gems
|
22
|
-
gem 'factory_bot_rails', '~> 6.0'
|
23
|
-
gem 'faker', '~> 3.0'
|
24
|
-
gem 'rspec-rails', '~> 6.0'
|
25
|
-
|
26
|
-
# Development and debugging
|
27
|
-
gem 'debug', '>= 1.0.0'
|
28
|
-
gem 'web-console', '>= 4.0'
|
29
|
-
|
30
10
|
group :development, :test do
|
31
|
-
gem '
|
32
|
-
gem '
|
11
|
+
gem 'byebug'
|
12
|
+
gem 'database_cleaner-active_record', '~> 2.1'
|
13
|
+
gem 'factory_bot_rails', '~> 6.0'
|
14
|
+
gem 'rspec', '~> 3.1'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sqlite3', '~> 2.7'
|
17
|
+
gem 'timecop', '~> 0.9.8'
|
18
|
+
gem 'webmock', '~> 3.19'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'redcarpet' # For YARD markdown support
|
23
|
+
gem 'rubocop', '~> 1.77'
|
24
|
+
gem 'rubocop-rails', '~> 2.32'
|
33
25
|
gem 'rubocop-rspec'
|
26
|
+
gem 'simplecov', '~> 0.22'
|
27
|
+
gem 'yard'
|
34
28
|
end
|
29
|
+
|
30
|
+
# For testing the gem in a Rails app
|
31
|
+
gem 'sprockets-rails' # Required for Rails 7+
|
32
|
+
|
33
|
+
# Official MCP Ruby SDK for migration
|
34
|
+
gem 'mcp', '~> 0.1.0'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rails 7.2 Gemfile for CI testing
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
# Specify the Rails version
|
5
|
+
gem 'rails', '~> 7.2.0'
|
6
|
+
|
7
|
+
# Include the main gemspec
|
8
|
+
gemspec path: '../'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'byebug'
|
12
|
+
gem 'database_cleaner-active_record', '~> 2.1'
|
13
|
+
gem 'factory_bot_rails', '~> 6.0'
|
14
|
+
gem 'rspec', '~> 3.1'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sqlite3', '~> 2.7'
|
17
|
+
gem 'timecop', '~> 0.9.8'
|
18
|
+
gem 'webmock', '~> 3.19'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
gem 'redcarpet' # For YARD markdown support
|
23
|
+
gem 'rubocop', '~> 1.77'
|
24
|
+
gem 'rubocop-rails', '~> 2.32'
|
25
|
+
gem 'rubocop-rspec'
|
26
|
+
gem 'simplecov', '~> 0.22'
|
27
|
+
gem 'yard'
|
28
|
+
end
|
29
|
+
|
30
|
+
# For testing the gem in a Rails app
|
31
|
+
gem 'sprockets-rails' # Required for Rails 7+
|
32
|
+
|
33
|
+
# Official MCP Ruby SDK for migration
|
34
|
+
gem 'mcp', '~> 0.1.0'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RailsActiveMcp
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path('templates', __dir__)
|
6
|
+
source_root File.expand_path('templates', __dir__ || File.dirname(__FILE__))
|
7
7
|
|
8
8
|
desc 'Install Rails Active MCP'
|
9
9
|
|
@@ -11,81 +11,14 @@ module RailsActiveMcp
|
|
11
11
|
template 'initializer.rb', 'config/initializers/rails_active_mcp.rb'
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# Binstub for Rails Active MCP Server
|
20
|
-
# This ensures the server runs within the Rails project context
|
21
|
-
|
22
|
-
require 'bundler/setup'
|
23
|
-
|
24
|
-
# Set Rails environment
|
25
|
-
ENV['RAILS_ENV'] ||= 'development'
|
26
|
-
|
27
|
-
# Load Rails application first
|
28
|
-
require_relative '../config/environment'
|
29
|
-
|
30
|
-
# Now start the MCP server using the SDK implementation
|
31
|
-
require 'rails_active_mcp/sdk/server'
|
32
|
-
|
33
|
-
begin
|
34
|
-
server = RailsActiveMcp::SDK::Server.new
|
35
|
-
server.run
|
36
|
-
rescue StandardError => e
|
37
|
-
warn "Error starting Rails Active MCP server: \#{e.message}"
|
38
|
-
warn e.backtrace if ENV['RAILS_MCP_DEBUG'] == '1'
|
39
|
-
exit 1
|
40
|
-
end
|
41
|
-
RUBY
|
14
|
+
def create_wrapper_script
|
15
|
+
template 'rails-active-mcp-wrapper', 'bin/rails-active-mcp-wrapper'
|
16
|
+
chmod 'bin/rails-active-mcp-wrapper', 0o755
|
17
|
+
end
|
42
18
|
|
19
|
+
def create_server_script
|
20
|
+
template 'rails-active-mcp-server', 'bin/rails-active-mcp-server'
|
43
21
|
chmod 'bin/rails-active-mcp-server', 0o755
|
44
|
-
say 'Created Rails binstub at bin/rails-active-mcp-server', :green
|
45
|
-
|
46
|
-
# Create environment-aware wrapper for Claude Desktop compatibility
|
47
|
-
ruby_path = `which ruby`.strip
|
48
|
-
|
49
|
-
create_file 'bin/rails-active-mcp-wrapper', <<~BASH
|
50
|
-
#!/usr/bin/env bash
|
51
|
-
|
52
|
-
# Rails Active MCP Wrapper Script
|
53
|
-
# Ensures correct Ruby environment for Claude Desktop execution
|
54
|
-
|
55
|
-
# Fix Claude Desktop environment isolation issues
|
56
|
-
export HOME="${HOME:-#{ENV['HOME']}}"
|
57
|
-
export USER="${USER:-$(whoami)}"
|
58
|
-
|
59
|
-
# Strategy 1: Use absolute Ruby path (most reliable)
|
60
|
-
RUBY_PATH="#{ruby_path}"
|
61
|
-
|
62
|
-
# Strategy 2: Try /usr/local/bin/ruby symlink as fallback
|
63
|
-
if [ ! -x "$RUBY_PATH" ]; then
|
64
|
-
RUBY_PATH="/usr/local/bin/ruby"
|
65
|
-
fi
|
66
|
-
|
67
|
-
# Strategy 3: Setup environment and use PATH resolution as last resort
|
68
|
-
if [ ! -x "$RUBY_PATH" ]; then
|
69
|
-
# Set up asdf environment if available
|
70
|
-
export ASDF_DIR="$HOME/.asdf"
|
71
|
-
if [ -f "$ASDF_DIR/asdf.sh" ]; then
|
72
|
-
source "$ASDF_DIR/asdf.sh"
|
73
|
-
fi
|
74
|
-
#{' '}
|
75
|
-
# Add version manager paths
|
76
|
-
export PATH="$HOME/.asdf/shims:$HOME/.rbenv/shims:$HOME/.rvm/bin:$PATH"
|
77
|
-
RUBY_PATH="ruby"
|
78
|
-
fi
|
79
|
-
|
80
|
-
# Change to the Rails project directory
|
81
|
-
cd "$(dirname "$0")/.."
|
82
|
-
|
83
|
-
# Execute with the determined Ruby path
|
84
|
-
exec "$RUBY_PATH" bin/rails-active-mcp-server "$@"
|
85
|
-
BASH
|
86
|
-
|
87
|
-
chmod 'bin/rails-active-mcp-wrapper', 0o755
|
88
|
-
say 'Created environment wrapper at bin/rails-active-mcp-wrapper', :green
|
89
22
|
end
|
90
23
|
|
91
24
|
def create_mcp_config
|
@@ -96,59 +29,76 @@ module RailsActiveMcp
|
|
96
29
|
readme 'README.md' if behavior == :invoke
|
97
30
|
end
|
98
31
|
|
32
|
+
# rubocop:disable Metrics/AbcSize
|
99
33
|
def show_post_install_instructions
|
100
34
|
return unless behavior == :invoke
|
101
35
|
|
102
|
-
say "\n
|
36
|
+
say "\n#{'=' * 50}", :green
|
103
37
|
say 'Rails Active MCP Installation Complete!', :green
|
104
38
|
say '=' * 50, :green
|
39
|
+
say "\nFiles created:", :green
|
40
|
+
say '✅ config/initializers/rails_active_mcp.rb', :yellow
|
41
|
+
say '✅ bin/rails-active-mcp-wrapper', :yellow
|
42
|
+
say '✅ bin/rails-active-mcp-server', :yellow
|
43
|
+
say '✅ mcp.ru', :yellow
|
44
|
+
say '', :green
|
45
|
+
say "\nQuick Test:", :green
|
46
|
+
say '1. Test the server: bin/rails-active-mcp-wrapper', :yellow
|
47
|
+
say '2. Should show JSON responses (not plain text)', :yellow
|
48
|
+
say '3. Exit with Ctrl+C', :yellow
|
49
|
+
say '', :green
|
105
50
|
say "\nFor Claude Desktop configuration:", :green
|
106
51
|
say 'Add this to your claude_desktop_config.json:', :yellow
|
107
52
|
say '', :green
|
108
53
|
say '{', :cyan
|
109
54
|
say ' "mcpServers": {', :cyan
|
110
55
|
say ' "rails-active-mcp": {', :cyan
|
111
|
-
say " \"command\": \"#{Rails.root
|
56
|
+
say " \"command\": \"#{Rails.root.join('bin/rails-active-mcp-wrapper')}\",", :cyan
|
112
57
|
say " \"cwd\": \"#{Rails.root}\",", :cyan
|
113
58
|
say ' "env": {', :cyan
|
114
|
-
say ' "RAILS_ENV": "development"
|
115
|
-
say " \"HOME\": \"#{ENV['HOME']}\"", :cyan
|
59
|
+
say ' "RAILS_ENV": "development"', :cyan
|
116
60
|
say ' }', :cyan
|
117
61
|
say ' }', :cyan
|
118
62
|
say ' }', :cyan
|
119
63
|
say '}', :cyan
|
120
64
|
say '', :green
|
65
|
+
say 'Config file locations:', :green
|
66
|
+
say ' macOS: ~/.config/claude-desktop/claude_desktop_config.json', :yellow
|
67
|
+
say ' Windows: %APPDATA%\\Claude\\claude_desktop_config.json', :yellow
|
68
|
+
say '', :green
|
121
69
|
say "\nAvailable Tools in Claude Desktop:", :green
|
122
70
|
say '- console_execute: Execute Ruby code with safety checks', :yellow
|
123
71
|
say '- model_info: Get detailed information about Rails models', :yellow
|
124
72
|
say '- safe_query: Execute safe read-only database queries', :yellow
|
125
73
|
say '- dry_run: Analyze Ruby code for safety without execution', :yellow
|
126
74
|
say '', :green
|
127
|
-
say "\
|
128
|
-
say '-
|
129
|
-
say '-
|
130
|
-
say '-
|
131
|
-
say "
|
132
|
-
say '
|
133
|
-
say "\nTesting:", :green
|
134
|
-
say '1. Test manually: bin/rails-active-mcp-wrapper', :yellow
|
135
|
-
say '2. Should output JSON responses (not plain text)', :yellow
|
136
|
-
say '3. Restart Claude Desktop after config changes', :yellow
|
75
|
+
say "\nExample Claude Desktop prompts:", :green
|
76
|
+
say '- "Show me the User model structure"', :yellow
|
77
|
+
say '- "How many users were created in the last week?"', :yellow
|
78
|
+
say '- "What are the most recent orders?"', :yellow
|
79
|
+
say '- "Check if this code is safe: User.delete_all"', :yellow
|
80
|
+
say '', :green
|
137
81
|
say "\nTroubleshooting:", :green
|
138
|
-
say '-
|
139
|
-
say '- Check
|
140
|
-
say
|
141
|
-
say 'If
|
142
|
-
say
|
82
|
+
say '- Debug mode: RAILS_MCP_DEBUG=1 bin/rails-active-mcp-wrapper', :yellow
|
83
|
+
say '- Check status: rails rails_active_mcp:status', :yellow
|
84
|
+
say '- Restart Claude Desktop after config changes', :yellow
|
85
|
+
say '- If wrapper fails, try: bin/rails-active-mcp-server', :yellow
|
86
|
+
say '', :green
|
87
|
+
say "\nNext steps:", :green
|
88
|
+
say '1. Test installation: rails rails_active_mcp:test_tools', :yellow
|
89
|
+
say '2. Configure Claude Desktop (see above)', :yellow
|
90
|
+
say '3. Restart Claude Desktop', :yellow
|
91
|
+
say '4. Start chatting with your Rails app!', :yellow
|
143
92
|
say '=' * 50, :green
|
144
93
|
end
|
94
|
+
# rubocop:enable Metrics/AbcSize
|
145
95
|
|
146
96
|
private
|
147
97
|
|
148
98
|
def readme(path)
|
149
99
|
readme_path = File.join(self.class.source_root, path)
|
150
100
|
if File.exist?(readme_path)
|
151
|
-
say
|
101
|
+
say File.read(readme_path), :green
|
152
102
|
else
|
153
103
|
say "README file not found at #{readme_path}", :green
|
154
104
|
end
|