rails-active-mcp 3.1.10 → 3.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a329f65c3253c3a8884bcdd1fb033d7de5b25e8612db59e4dbe5983162a8d41e
4
- data.tar.gz: 1efc1677b2f370fd14bcea83cdb87171f27e3ff466c27affdc14faf6c72f9730
3
+ metadata.gz: 4838199f9074adc409c21a05e2ba54fa081d92d19492293f0958de3aca0ad43b
4
+ data.tar.gz: 1717009443494a6d2790436b5c6831c30e149c5b0450abae0af848c4b1ee1c0c
5
5
  SHA512:
6
- metadata.gz: 852559b1ad8f7e464b6653ca537bfdf8ed64b4c11f776fa444525277e61daba93f9405201c8b1bc4443aed714c9bb0baabb2ee7543d73aef31cf77c249e9e6d8
7
- data.tar.gz: b2786ddb072811c79a993b664b8df73c1fd973df35bb40f5a4c09b44677e43c670d6d1a9f2597e985ff1475a360eda75f5a10f84f1b9e1b87ea2ceffa0e43969
6
+ metadata.gz: 47100e8a9e667123d5465aa1e165392009055e8c084665a19e756c1cd07a609febcfcbeac74d5cf2dba0fc7be703d476911819b64c66143a6489cfff462ca8ca
7
+ data.tar.gz: ab592ed13aea076cb83b8a70969fd85f37ae3283fe01edb301fa0e748eaa4a7b830a34225ce368b73ff426c5e4239357517a99de5d9267d0f2594fa734f80064
data/README.md CHANGED
@@ -126,7 +126,7 @@ Add to your project's `.cursor/mcp.json`:
126
126
  <details>
127
127
  <summary><strong>Windsurf</strong></summary>
128
128
 
129
- Add to your project's `.windsurf/mcp.json`:
129
+ Add to your global Windsurf config at `~/.codeium/windsurf/mcp_config.json`:
130
130
 
131
131
  ```json
132
132
  {
@@ -217,15 +217,23 @@ The installer creates a default configuration at `config/initializers/rails_acti
217
217
 
218
218
  ```ruby
219
219
  RailsActiveMcp.configure do |config|
220
- config.allowed_commands = %w[
221
- ls pwd cat head tail grep find wc
222
- rails console rails runner
223
- bundle exec rspec bundle exec test
224
- git status git log git diff
225
- ]
226
- config.command_timeout = 30
220
+ # Safety and execution
221
+ config.safe_mode = true # Block dangerous operations
222
+ config.command_timeout = 30 # Seconds before timeout
223
+ config.max_results = 100 # Limit query results
224
+ config.allowed_models = [] # Empty = all models allowed
225
+ config.custom_safety_patterns = [] # Additional patterns to block
226
+
227
+ # Logging
227
228
  config.enable_logging = true
228
- config.log_level = :info
229
+ config.log_level = :info # :debug, :info, :warn, :error
230
+ config.log_executions = false # Log all code executions
231
+ config.audit_file = nil # Path to audit log file
232
+
233
+ # Environment presets (call instead of setting individually)
234
+ # config.production_mode!
235
+ # config.development_mode!
236
+ # config.test_mode!
229
237
  end
230
238
  ```
231
239
 
@@ -258,6 +266,33 @@ bundle exec rails-active-mcp-server
258
266
  RAILS_MCP_DEBUG=1 bundle exec rails-active-mcp-server
259
267
  ```
260
268
 
269
+ ### Rake Tasks
270
+
271
+ The gem provides several rake tasks for diagnostics and testing:
272
+
273
+ ```bash
274
+ # Show status and diagnostics
275
+ rails rails_active_mcp:status
276
+
277
+ # Validate configuration
278
+ rails rails_active_mcp:validate_config
279
+
280
+ # Test MCP tools are working
281
+ rails rails_active_mcp:test_tools
282
+
283
+ # Check if code is safe
284
+ rails rails_active_mcp:check_safety['User.delete_all']
285
+
286
+ # Execute code with safety checks
287
+ rails rails_active_mcp:execute['User.count']
288
+
289
+ # Print Claude Desktop configuration
290
+ rails rails_active_mcp:install_claude_config
291
+
292
+ # Run performance benchmarks
293
+ rails rails_active_mcp:benchmark
294
+ ```
295
+
261
296
  ## Available MCP Tools
262
297
 
263
298
  The Rails Active MCP server provides four powerful tools that appear automatically in any connected MCP client:
@@ -401,20 +436,3 @@ bundle exec rspec
401
436
  ## License
402
437
 
403
438
  The gem is available as open source under the [MIT License](https://opensource.org/licenses/MIT).
404
-
405
- ## Changelog
406
-
407
- ### Version 2.0.0 (Latest)
408
-
409
- - **BREAKING**: Migrated to official MCP Ruby SDK
410
- - **BREAKING**: Removed custom MCP server implementation
411
- - **BREAKING**: Simplified configuration options
412
- - **NEW**: Professional protocol handling with built-in instrumentation
413
- - **NEW**: Automatic MCP specification compliance
414
- - **IMPROVED**: 85% reduction in codebase complexity
415
- - **IMPROVED**: Better error handling and reporting
416
- - **IMPROVED**: Future-proof architecture
417
-
418
- ### Previous Versions
419
-
420
- See [CHANGELOG.md](CHANGELOG.md) for detailed version history.
@@ -31,6 +31,3 @@ end
31
31
 
32
32
  # For testing the gem in a Rails app
33
33
  gem 'sprockets-rails' # Required for Rails 7+
34
-
35
- # Official MCP Ruby SDK
36
- gem 'mcp', '~> 0.9.2'
@@ -31,6 +31,3 @@ end
31
31
 
32
32
  # For testing the gem in a Rails app
33
33
  gem 'sprockets-rails' # Required for Rails 7+
34
-
35
- # Official MCP Ruby SDK
36
- gem 'mcp', '~> 0.9.2'
@@ -31,6 +31,3 @@ end
31
31
 
32
32
  # For testing the gem in a Rails app
33
33
  gem 'sprockets-rails' # Required for Rails 7+
34
-
35
- # Official MCP Ruby SDK
36
- gem 'mcp', '~> 0.9.2'
@@ -31,6 +31,3 @@ end
31
31
 
32
32
  # For testing the gem in a Rails app
33
33
  gem 'sprockets-rails' # Required for Rails 7+
34
-
35
- # Official MCP Ruby SDK
36
- gem 'mcp', '~> 0.9.2'
@@ -31,6 +31,3 @@ end
31
31
 
32
32
  # For testing the gem in a Rails app
33
33
  gem 'sprockets-rails' # Required for Rails 7+
34
-
35
- # Official MCP Ruby SDK
36
- gem 'mcp', '~> 0.9.2'
@@ -131,6 +131,8 @@ module RailsActiveMcp
131
131
 
132
132
  validators_info = build_model_validator_info(model_class)
133
133
 
134
+ enums_info = build_model_enums(model_class)
135
+
134
136
  {
135
137
  success: true,
136
138
  model_name: model_name,
@@ -139,6 +141,7 @@ module RailsActiveMcp
139
141
  columns: columns_info,
140
142
  associations: associations_info,
141
143
  validators: validators_info,
144
+ enums: enums_info,
142
145
  extracted_at: Time.now
143
146
  }
144
147
  end
@@ -199,6 +202,14 @@ module RailsActiveMcp
199
202
  end
200
203
  end
201
204
 
205
+ def build_model_enums(model_class)
206
+ return {} unless model_class.respond_to?(:defined_enums)
207
+
208
+ model_class.defined_enums.transform_values do |mapping|
209
+ mapping.transform_values(&:to_s)
210
+ end
211
+ end
212
+
202
213
  def dry_run(code)
203
214
  # Analyze without executing
204
215
  safety_analysis = @safety_checker.analyze(code)
@@ -25,6 +25,10 @@ module RailsActiveMcp
25
25
  include_validations: {
26
26
  type: 'boolean',
27
27
  description: 'Include model validations'
28
+ },
29
+ include_enums: {
30
+ type: 'boolean',
31
+ description: 'Include enum definitions and their values'
28
32
  }
29
33
  },
30
34
  required: ['model']
@@ -38,56 +42,86 @@ module RailsActiveMcp
38
42
  open_world_hint: false
39
43
  )
40
44
 
41
- def self.call(model:, server_context:, include_schema: true, include_associations: true,
42
- include_validations: true)
45
+ def self.call(model:, server_context:, **)
46
+ new(model:, **).call
47
+ end
48
+
49
+ def initialize(model: nil, **options) # rubocop:disable Lint/MissingSuper
50
+ @model = model
51
+ @include_schema = options.fetch(:include_schema, true)
52
+ @include_associations = options.fetch(:include_associations, true)
53
+ @include_validations = options.fetch(:include_validations, true)
54
+ @include_enums = options.fetch(:include_enums, true)
55
+ end
56
+
57
+ def call
43
58
  config = RailsActiveMcp.config
44
59
  executor = RailsActiveMcp::ConsoleExecutor.new(config)
45
- result = executor.get_model_info(model)
60
+ @result = executor.get_model_info(@model)
46
61
 
47
- return error_response(result[:error]) unless result[:success]
62
+ return error_response unless @result[:success]
48
63
 
49
- output = []
50
- output << "Model: #{result[:model_name]}"
51
- output << "Table: #{result[:table_name]}"
52
- output << "Primary Key: #{result[:primary_key]}"
64
+ @output = []
65
+ @output << "Model: #{@result[:model_name]}"
66
+ @output << "Table: #{@result[:table_name]}"
67
+ @output << "Primary Key: #{@result[:primary_key]}"
53
68
 
54
- if include_schema
55
- output << "\nSchema:"
56
- result[:columns].each do |column|
57
- output << " #{column[:name]}: #{column[:type]}"
58
- output << " - Primary: #{column[:primary]}"
59
- end
69
+ append_schema if @include_schema
70
+ append_associations if @include_associations
71
+ append_validations if @include_validations
72
+ append_enums if @include_enums
73
+
74
+ MCP::Tool::Response.new([
75
+ { type: 'text', text: @output.join("\n") }
76
+ ])
77
+ end
78
+
79
+ private
80
+
81
+ def append_schema
82
+ @output << "\nSchema:"
83
+ @result[:columns].each do |column|
84
+ @output << " #{column[:name]}: #{column[:type]}"
85
+ @output << " - Primary: #{column[:primary]}"
60
86
  end
87
+ end
61
88
 
62
- if include_associations
63
- output << "\nAssociations:"
64
- result[:associations].each do |assoc|
65
- output << " #{assoc[:name]}: #{assoc[:type]} -> #{assoc[:class_name]}"
66
- end
89
+ def append_associations
90
+ @output << "\nAssociations:"
91
+ @result[:associations].each do |assoc|
92
+ @output << " #{assoc[:name]}: #{assoc[:type]} -> #{assoc[:class_name]}"
67
93
  end
94
+ end
68
95
 
69
- if include_validations && result[:validators]&.any?
70
- output << "\nValidations:"
71
- validations = {}
72
- result[:validators].each do |validator|
73
- validator[:attributes].each do |attribute|
74
- validations[attribute] ||= []
75
- validations[attribute] << validator[:type].to_s.split('::').last
76
- end
77
- end
78
- validations.each do |attr, validators|
79
- output << " #{attr}: #{validators.join(', ')}"
96
+ def append_validations
97
+ return unless @result[:validators]&.any?
98
+
99
+ @output << "\nValidations:"
100
+ validations = {}
101
+ @result[:validators].each do |validator|
102
+ validator[:attributes].each do |attribute|
103
+ validations[attribute] ||= []
104
+ validations[attribute] << validator[:type].to_s.split('::').last
80
105
  end
81
106
  end
107
+ validations.each do |attr, validators|
108
+ @output << " #{attr}: #{validators.join(', ')}"
109
+ end
110
+ end
82
111
 
83
- MCP::Tool::Response.new([
84
- { type: 'text', text: output.join("\n") }
85
- ])
112
+ def append_enums
113
+ return unless @result[:enums]&.any?
114
+
115
+ @output << "\nEnums:"
116
+ @result[:enums].each do |attribute, mapping|
117
+ values = mapping.map { |label, db_value| "#{label} (#{db_value})" }.join(', ')
118
+ @output << " #{attribute}: #{values}"
119
+ end
86
120
  end
87
121
 
88
- def self.error_response(message)
122
+ def error_response
89
123
  MCP::Tool::Response.new(
90
- [{ type: 'text', text: message }],
124
+ [{ type: 'text', text: @result[:error] }],
91
125
  error: true
92
126
  )
93
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsActiveMcp
4
- VERSION = '3.1.10'
4
+ VERSION = '3.1.11'
5
5
  end
@@ -71,11 +71,11 @@ Gem::Specification.new do |spec|
71
71
  spec.add_dependency 'timeout', '~> 0.4'
72
72
 
73
73
  # Development dependencies - keep versions consistent with Gemfile
74
- spec.add_development_dependency 'colorize', '~> 0.8'
74
+ spec.add_development_dependency 'colorize', '~> 1.1'
75
75
  spec.add_development_dependency 'factory_bot_rails', '~> 6.0'
76
- spec.add_development_dependency 'faker', '~> 2.19'
76
+ spec.add_development_dependency 'faker', '~> 3.6'
77
77
  spec.add_development_dependency 'rspec', '~> 3.1'
78
- spec.add_development_dependency 'rspec-rails', '~> 6.0'
78
+ spec.add_development_dependency 'rspec-rails', '~> 8.0'
79
79
  spec.add_development_dependency 'rubocop', '~> 1.77'
80
80
  spec.add_development_dependency 'rubocop-rails', '~> 2.32'
81
81
  spec.add_development_dependency 'rubocop-rspec', '~> 3.0'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-active-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.10
4
+ version: 3.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandyn Britton
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-04-01 00:00:00.000000000 Z
10
+ date: 2026-04-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: concurrent-ruby
@@ -111,14 +111,14 @@ dependencies:
111
111
  requirements:
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
- version: '0.8'
114
+ version: '1.1'
115
115
  type: :development
116
116
  prerelease: false
117
117
  version_requirements: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: '0.8'
121
+ version: '1.1'
122
122
  - !ruby/object:Gem::Dependency
123
123
  name: factory_bot_rails
124
124
  requirement: !ruby/object:Gem::Requirement
@@ -139,14 +139,14 @@ dependencies:
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '2.19'
142
+ version: '3.6'
143
143
  type: :development
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: '2.19'
149
+ version: '3.6'
150
150
  - !ruby/object:Gem::Dependency
151
151
  name: rspec
152
152
  requirement: !ruby/object:Gem::Requirement
@@ -167,14 +167,14 @@ dependencies:
167
167
  requirements:
168
168
  - - "~>"
169
169
  - !ruby/object:Gem::Version
170
- version: '6.0'
170
+ version: '8.0'
171
171
  type: :development
172
172
  prerelease: false
173
173
  version_requirements: !ruby/object:Gem::Requirement
174
174
  requirements:
175
175
  - - "~>"
176
176
  - !ruby/object:Gem::Version
177
- version: '6.0'
177
+ version: '8.0'
178
178
  - !ruby/object:Gem::Dependency
179
179
  name: rubocop
180
180
  requirement: !ruby/object:Gem::Requirement