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 +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 +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4838199f9074adc409c21a05e2ba54fa081d92d19492293f0958de3aca0ad43b
|
|
4
|
+
data.tar.gz: 1717009443494a6d2790436b5c6831c30e149c5b0450abae0af848c4b1ee1c0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
@@ -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.1.
|
|
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-
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
177
|
+
version: '8.0'
|
|
178
178
|
- !ruby/object:Gem::Dependency
|
|
179
179
|
name: rubocop
|
|
180
180
|
requirement: !ruby/object:Gem::Requirement
|