rails-active-mcp 3.1.10 → 3.2.0
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/README.md +44 -26
- data/gemfiles/rails_7.0.gemfile +0 -3
- data/gemfiles/rails_7.1.gemfile +0 -3
- data/gemfiles/rails_7.2.gemfile +0 -3
- data/gemfiles/rails_8.0.gemfile +0 -3
- data/gemfiles/rails_8.1.gemfile +0 -3
- data/lib/rails_active_mcp/console_executor.rb +11 -0
- data/lib/rails_active_mcp/sdk/tools/model_info_tool.rb +69 -35
- data/lib/rails_active_mcp/version.rb +1 -1
- data/rails_active_mcp.gemspec +4 -4
- metadata +16 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 151bd5ce3f4d059d3c8afc2481d37ac02766d2660a89a3a51ade7f153373ee54
|
|
4
|
+
data.tar.gz: f119f880f2b8f5b5b4c604e952e9cfff206753ceaf05bc2eb0a199c1640061de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7394eb360c87d5e3c891cb9f3fa330d9062198d5a18d13f2b907cb6dd1ca533b43a761fe56fa955eca71b377ce3801586f05766b45b02e7fc976876478eccd0a
|
|
7
|
+
data.tar.gz: f50dd0fa1ea1a0a026c5442b509fddaea73a31555eb473864cc26d93be5d754d3994c907598ad5b68dcc244b2127a53e0f3626c078bd8c0fc1e763c635eadb16
|
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
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
]
|
|
226
|
-
|
|
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.
|
data/gemfiles/rails_7.0.gemfile
CHANGED
data/gemfiles/rails_7.1.gemfile
CHANGED
data/gemfiles/rails_7.2.gemfile
CHANGED
data/gemfiles/rails_8.0.gemfile
CHANGED
data/gemfiles/rails_8.1.gemfile
CHANGED
|
@@ -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:,
|
|
42
|
-
|
|
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
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
84
|
-
|
|
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
|
|
122
|
+
def error_response
|
|
89
123
|
MCP::Tool::Response.new(
|
|
90
|
-
[{ type: 'text', text:
|
|
124
|
+
[{ type: 'text', text: @result[:error] }],
|
|
91
125
|
error: true
|
|
92
126
|
)
|
|
93
127
|
end
|
data/rails_active_mcp.gemspec
CHANGED
|
@@ -63,7 +63,7 @@ Gem::Specification.new do |spec|
|
|
|
63
63
|
spec.add_dependency 'rails', '>= 7.0', '< 9.0'
|
|
64
64
|
|
|
65
65
|
# MCP SDK - Core protocol implementation (MCP 2025-11-25 spec)
|
|
66
|
-
spec.add_dependency 'mcp', '
|
|
66
|
+
spec.add_dependency 'mcp', '>= 0.9.2', '< 1.0.0'
|
|
67
67
|
|
|
68
68
|
# Core dependencies
|
|
69
69
|
spec.add_dependency 'json', '~> 2.0'
|
|
@@ -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', '~>
|
|
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', '~>
|
|
76
|
+
spec.add_development_dependency 'faker', '~> 3.6'
|
|
77
77
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
|
78
|
-
spec.add_development_dependency 'rspec-rails', '~>
|
|
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.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brandyn Britton
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
10
|
+
date: 2026-04-22 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: concurrent-ruby
|
|
@@ -47,16 +47,22 @@ dependencies:
|
|
|
47
47
|
name: mcp
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
49
|
requirements:
|
|
50
|
-
- - "
|
|
50
|
+
- - ">="
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
52
|
version: 0.9.2
|
|
53
|
+
- - "<"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 1.0.0
|
|
53
56
|
type: :runtime
|
|
54
57
|
prerelease: false
|
|
55
58
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
59
|
requirements:
|
|
57
|
-
- - "
|
|
60
|
+
- - ">="
|
|
58
61
|
- !ruby/object:Gem::Version
|
|
59
62
|
version: 0.9.2
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: 1.0.0
|
|
60
66
|
- !ruby/object:Gem::Dependency
|
|
61
67
|
name: json
|
|
62
68
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,14 +117,14 @@ dependencies:
|
|
|
111
117
|
requirements:
|
|
112
118
|
- - "~>"
|
|
113
119
|
- !ruby/object:Gem::Version
|
|
114
|
-
version: '
|
|
120
|
+
version: '1.1'
|
|
115
121
|
type: :development
|
|
116
122
|
prerelease: false
|
|
117
123
|
version_requirements: !ruby/object:Gem::Requirement
|
|
118
124
|
requirements:
|
|
119
125
|
- - "~>"
|
|
120
126
|
- !ruby/object:Gem::Version
|
|
121
|
-
version: '
|
|
127
|
+
version: '1.1'
|
|
122
128
|
- !ruby/object:Gem::Dependency
|
|
123
129
|
name: factory_bot_rails
|
|
124
130
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -139,14 +145,14 @@ dependencies:
|
|
|
139
145
|
requirements:
|
|
140
146
|
- - "~>"
|
|
141
147
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: '
|
|
148
|
+
version: '3.6'
|
|
143
149
|
type: :development
|
|
144
150
|
prerelease: false
|
|
145
151
|
version_requirements: !ruby/object:Gem::Requirement
|
|
146
152
|
requirements:
|
|
147
153
|
- - "~>"
|
|
148
154
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '
|
|
155
|
+
version: '3.6'
|
|
150
156
|
- !ruby/object:Gem::Dependency
|
|
151
157
|
name: rspec
|
|
152
158
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -167,14 +173,14 @@ dependencies:
|
|
|
167
173
|
requirements:
|
|
168
174
|
- - "~>"
|
|
169
175
|
- !ruby/object:Gem::Version
|
|
170
|
-
version: '
|
|
176
|
+
version: '8.0'
|
|
171
177
|
type: :development
|
|
172
178
|
prerelease: false
|
|
173
179
|
version_requirements: !ruby/object:Gem::Requirement
|
|
174
180
|
requirements:
|
|
175
181
|
- - "~>"
|
|
176
182
|
- !ruby/object:Gem::Version
|
|
177
|
-
version: '
|
|
183
|
+
version: '8.0'
|
|
178
184
|
- !ruby/object:Gem::Dependency
|
|
179
185
|
name: rubocop
|
|
180
186
|
requirement: !ruby/object:Gem::Requirement
|