rails-active-mcp 0.1.7 → 2.0.8

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +106 -279
  3. data/changelog.md +69 -0
  4. data/docs/DEBUGGING.md +5 -5
  5. data/docs/README.md +130 -142
  6. data/examples/rails_app_integration.md +405 -0
  7. data/exe/rails-active-mcp-server +153 -76
  8. data/gemfiles/rails_7.1.gemfile +34 -0
  9. data/lib/generators/rails_active_mcp/install/install_generator.rb +19 -39
  10. data/lib/generators/rails_active_mcp/install/templates/README.md +134 -188
  11. data/lib/generators/rails_active_mcp/install/templates/initializer.rb +65 -28
  12. data/lib/generators/rails_active_mcp/install/templates/mcp.ru +7 -3
  13. data/lib/rails_active_mcp/configuration.rb +37 -98
  14. data/lib/rails_active_mcp/console_executor.rb +13 -3
  15. data/lib/rails_active_mcp/engine.rb +36 -24
  16. data/lib/rails_active_mcp/sdk/server.rb +183 -0
  17. data/lib/rails_active_mcp/sdk/tools/console_execute_tool.rb +103 -0
  18. data/lib/rails_active_mcp/sdk/tools/dry_run_tool.rb +73 -0
  19. data/lib/rails_active_mcp/sdk/tools/model_info_tool.rb +106 -0
  20. data/lib/rails_active_mcp/sdk/tools/safe_query_tool.rb +77 -0
  21. data/lib/rails_active_mcp/tasks.rake +236 -80
  22. data/lib/rails_active_mcp/version.rb +1 -1
  23. data/lib/rails_active_mcp.rb +5 -11
  24. data/rails_active_mcp.gemspec +62 -11
  25. metadata +83 -24
  26. data/app/controllers/rails_active_mcp/mcp_controller.rb +0 -80
  27. data/lib/rails_active_mcp/mcp_server.rb +0 -383
  28. data/lib/rails_active_mcp/railtie.rb +0 -70
  29. data/lib/rails_active_mcp/stdio_server.rb +0 -517
  30. data/lib/rails_active_mcp/tools/console_execute_tool.rb +0 -61
  31. data/lib/rails_active_mcp/tools/dry_run_tool.rb +0 -41
  32. data/lib/rails_active_mcp/tools/model_info_tool.rb +0 -70
  33. data/lib/rails_active_mcp/tools/safe_query_tool.rb +0 -41
@@ -8,23 +8,51 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Brandyn Britton']
9
9
  spec.email = ['brandynbb96@gmail.com']
10
10
 
11
- spec.summary = 'Rails Console access via Model Context Protocol (MCP)'
12
- spec.description = 'Secure Rails console access for AI agents through Model Context Protocol with safety features and read-only modes'
11
+ spec.summary = 'Secure Rails console access via Model Context Protocol (MCP)'
12
+ spec.description = <<~DESC
13
+ Rails Active MCP enables secure Rails console access through Model Context Protocol (MCP)#{' '}
14
+ for AI agents and development tools like Claude Desktop. Provides safe database querying,#{' '}
15
+ model introspection, and code execution with comprehensive safety checks and audit logging.
16
+
17
+ Features include:
18
+ • Safe Ruby code execution with configurable safety checks
19
+ • Read-only database query tools with result limiting
20
+ • Rails model introspection (schema, associations, validations)
21
+ • Dry-run code analysis for safety validation
22
+ • Environment-specific configuration presets
23
+ • Comprehensive audit logging and monitoring
24
+ • Claude Desktop integration out of the box
25
+ DESC
26
+
13
27
  spec.homepage = 'https://github.com/goodpie/rails-active-mcp'
14
28
  spec.license = 'MIT'
15
29
  spec.required_ruby_version = '>= 3.0.0'
16
30
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = spec.homepage
19
- spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
31
+ spec.metadata = {
32
+ 'homepage_uri' => spec.homepage,
33
+ 'source_code_uri' => "#{spec.homepage}/tree/main",
34
+ 'changelog_uri' => "#{spec.homepage}/blob/main/changelog.md",
35
+ 'bug_tracker_uri' => "#{spec.homepage}/issues",
36
+ 'documentation_uri' => "#{spec.homepage}#readme",
37
+ 'wiki_uri' => "#{spec.homepage}/wiki",
38
+ 'mailing_list_uri' => "#{spec.homepage}/discussions",
39
+ 'funding_uri' => 'https://github.com/sponsors/goodpie',
40
+ 'rubygems_mfa_required' => 'true'
41
+ }
20
42
 
21
- # Specify which files should be added to the gem when it is released.
43
+ # Specify which files should be added to the gem when it is released
22
44
  spec.files = Dir.chdir(__dir__) do
23
45
  `git ls-files -z`.split("\x0").reject do |f|
24
46
  (File.expand_path(f) == __FILE__) ||
25
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
47
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile]) ||
48
+ f.match?(%r{\A(?:log|tmp|\.)/}) ||
49
+ f.end_with?('.log', '.tmp')
26
50
  end
27
- end
51
+ end + [
52
+ 'examples/rails_app_integration.md',
53
+ 'docs/DEBUGGING.md',
54
+ 'docs/README.md'
55
+ ].select { |f| File.exist?(f) }
28
56
 
29
57
  spec.bindir = 'exe'
30
58
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
@@ -32,7 +60,10 @@ Gem::Specification.new do |spec|
32
60
 
33
61
  # Runtime dependencies - more flexible Rails version support
34
62
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.3'
35
- spec.add_runtime_dependency 'rails', '>= 6.1', '< 8.0'
63
+ spec.add_runtime_dependency 'rails', '>= 6.1', '< 9.0'
64
+
65
+ # MCP SDK - Core protocol implementation
66
+ spec.add_runtime_dependency 'mcp', '~> 0.1.0'
36
67
 
37
68
  # Core dependencies
38
69
  spec.add_dependency 'json', '~> 2.0'
@@ -41,11 +72,31 @@ Gem::Specification.new do |spec|
41
72
  spec.add_dependency 'webrick', '~> 1.8'
42
73
 
43
74
  # Development dependencies - keep versions consistent with Gemfile
75
+ spec.add_development_dependency 'colorize', '~> 0.8'
44
76
  spec.add_development_dependency 'factory_bot_rails', '~> 6.0'
77
+ spec.add_development_dependency 'faker', '~> 2.19'
45
78
  spec.add_development_dependency 'rspec', '~> 3.1'
46
- spec.add_development_dependency 'rspec-rails'
79
+ spec.add_development_dependency 'rspec-rails', '~> 6.0'
47
80
  spec.add_development_dependency 'rubocop', '~> 1.77'
48
81
  spec.add_development_dependency 'rubocop-rails', '~> 2.32'
49
- spec.add_development_dependency 'rubocop-rspec'
82
+ spec.add_development_dependency 'rubocop-rspec', '~> 3.0'
50
83
  spec.add_development_dependency 'sqlite3', '~> 2.7'
84
+
85
+ # Post-install message to help users get started
86
+ spec.post_install_message = <<~MSG
87
+
88
+ 🎉 Thanks for installing Rails Active MCP!
89
+
90
+ Quick Start:
91
+ 1. Add to your Rails app: rails generate rails_active_mcp:install
92
+ 2. Test the setup: rails rails_active_mcp:status
93
+ 3. Configure Claude Desktop: rails rails_active_mcp:install_claude_config
94
+
95
+ 📚 Documentation: #{spec.homepage}#readme
96
+ 🐛 Issues: #{spec.homepage}/issues
97
+ 💬 Discussions: #{spec.homepage}/discussions
98
+
99
+ Follow the project: ⭐ #{spec.homepage}
100
+
101
+ MSG
51
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-active-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandyn Britton
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '6.1'
33
33
  - - "<"
34
34
  - !ruby/object:Gem::Version
35
- version: '8.0'
35
+ version: '9.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,21 @@ dependencies:
42
42
  version: '6.1'
43
43
  - - "<"
44
44
  - !ruby/object:Gem::Version
45
- version: '8.0'
45
+ version: '9.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mcp
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.1.0
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 0.1.0
46
60
  - !ruby/object:Gem::Dependency
47
61
  name: json
48
62
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +119,20 @@ dependencies:
105
119
  - - "~>"
106
120
  - !ruby/object:Gem::Version
107
121
  version: '1.8'
122
+ - !ruby/object:Gem::Dependency
123
+ name: colorize
124
+ requirement: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '0.8'
129
+ type: :development
130
+ prerelease: false
131
+ version_requirements: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: '0.8'
108
136
  - !ruby/object:Gem::Dependency
109
137
  name: factory_bot_rails
110
138
  requirement: !ruby/object:Gem::Requirement
@@ -119,6 +147,20 @@ dependencies:
119
147
  - - "~>"
120
148
  - !ruby/object:Gem::Version
121
149
  version: '6.0'
150
+ - !ruby/object:Gem::Dependency
151
+ name: faker
152
+ requirement: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '2.19'
157
+ type: :development
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '2.19'
122
164
  - !ruby/object:Gem::Dependency
123
165
  name: rspec
124
166
  requirement: !ruby/object:Gem::Requirement
@@ -137,16 +179,16 @@ dependencies:
137
179
  name: rspec-rails
138
180
  requirement: !ruby/object:Gem::Requirement
139
181
  requirements:
140
- - - ">="
182
+ - - "~>"
141
183
  - !ruby/object:Gem::Version
142
- version: '0'
184
+ version: '6.0'
143
185
  type: :development
144
186
  prerelease: false
145
187
  version_requirements: !ruby/object:Gem::Requirement
146
188
  requirements:
147
- - - ">="
189
+ - - "~>"
148
190
  - !ruby/object:Gem::Version
149
- version: '0'
191
+ version: '6.0'
150
192
  - !ruby/object:Gem::Dependency
151
193
  name: rubocop
152
194
  requirement: !ruby/object:Gem::Requirement
@@ -179,16 +221,16 @@ dependencies:
179
221
  name: rubocop-rspec
180
222
  requirement: !ruby/object:Gem::Requirement
181
223
  requirements:
182
- - - ">="
224
+ - - "~>"
183
225
  - !ruby/object:Gem::Version
184
- version: '0'
226
+ version: '3.0'
185
227
  type: :development
186
228
  prerelease: false
187
229
  version_requirements: !ruby/object:Gem::Requirement
188
230
  requirements:
189
- - - ">="
231
+ - - "~>"
190
232
  - !ruby/object:Gem::Version
191
- version: '0'
233
+ version: '3.0'
192
234
  - !ruby/object:Gem::Dependency
193
235
  name: sqlite3
194
236
  requirement: !ruby/object:Gem::Requirement
@@ -203,8 +245,14 @@ dependencies:
203
245
  - - "~>"
204
246
  - !ruby/object:Gem::Version
205
247
  version: '2.7'
206
- description: Secure Rails console access for AI agents through Model Context Protocol
207
- with safety features and read-only modes
248
+ description: "Rails Active MCP enables secure Rails console access through Model Context
249
+ Protocol (MCP) \nfor AI agents and development tools like Claude Desktop. Provides
250
+ safe database querying, \nmodel introspection, and code execution with comprehensive
251
+ safety checks and audit logging.\n\nFeatures include:\n• Safe Ruby code execution
252
+ with configurable safety checks\n• Read-only database query tools with result limiting\n•
253
+ Rails model introspection (schema, associations, validations)\n• Dry-run code analysis
254
+ for safety validation\n• Environment-specific configuration presets\n• Comprehensive
255
+ audit logging and monitoring\n• Claude Desktop integration out of the box\n"
208
256
  email:
209
257
  - brandynbb96@gmail.com
210
258
  executables:
@@ -218,13 +266,14 @@ files:
218
266
  - ".idea/rails-active-mcp-gem.iml"
219
267
  - ".idea/vcs.xml"
220
268
  - README.md
221
- - app/controllers/rails_active_mcp/mcp_controller.rb
222
269
  - changelog.md
223
270
  - claude_desktop_config.json
224
271
  - docs/DEBUGGING.md
225
272
  - docs/GENERATOR_TESTING.md
226
273
  - docs/README.md
274
+ - examples/rails_app_integration.md
227
275
  - exe/rails-active-mcp-server
276
+ - gemfiles/rails_7.1.gemfile
228
277
  - lib/generators/rails_active_mcp/install/install_generator.rb
229
278
  - lib/generators/rails_active_mcp/install/templates/README.md
230
279
  - lib/generators/rails_active_mcp/install/templates/initializer.rb
@@ -233,15 +282,13 @@ files:
233
282
  - lib/rails_active_mcp/configuration.rb
234
283
  - lib/rails_active_mcp/console_executor.rb
235
284
  - lib/rails_active_mcp/engine.rb
236
- - lib/rails_active_mcp/mcp_server.rb
237
- - lib/rails_active_mcp/railtie.rb
238
285
  - lib/rails_active_mcp/safety_checker.rb
239
- - lib/rails_active_mcp/stdio_server.rb
286
+ - lib/rails_active_mcp/sdk/server.rb
287
+ - lib/rails_active_mcp/sdk/tools/console_execute_tool.rb
288
+ - lib/rails_active_mcp/sdk/tools/dry_run_tool.rb
289
+ - lib/rails_active_mcp/sdk/tools/model_info_tool.rb
290
+ - lib/rails_active_mcp/sdk/tools/safe_query_tool.rb
240
291
  - lib/rails_active_mcp/tasks.rake
241
- - lib/rails_active_mcp/tools/console_execute_tool.rb
242
- - lib/rails_active_mcp/tools/dry_run_tool.rb
243
- - lib/rails_active_mcp/tools/model_info_tool.rb
244
- - lib/rails_active_mcp/tools/safe_query_tool.rb
245
292
  - lib/rails_active_mcp/version.rb
246
293
  - mcp.ru
247
294
  - rails_active_mcp.gemspec
@@ -250,8 +297,20 @@ licenses:
250
297
  - MIT
251
298
  metadata:
252
299
  homepage_uri: https://github.com/goodpie/rails-active-mcp
253
- source_code_uri: https://github.com/goodpie/rails-active-mcp
254
- changelog_uri: https://github.com/goodpie/rails-active-mcp/blob/main/CHANGELOG.md
300
+ source_code_uri: https://github.com/goodpie/rails-active-mcp/tree/main
301
+ changelog_uri: https://github.com/goodpie/rails-active-mcp/blob/main/changelog.md
302
+ bug_tracker_uri: https://github.com/goodpie/rails-active-mcp/issues
303
+ documentation_uri: https://github.com/goodpie/rails-active-mcp#readme
304
+ wiki_uri: https://github.com/goodpie/rails-active-mcp/wiki
305
+ mailing_list_uri: https://github.com/goodpie/rails-active-mcp/discussions
306
+ funding_uri: https://github.com/sponsors/goodpie
307
+ rubygems_mfa_required: 'true'
308
+ post_install_message: "\n\U0001F389 Thanks for installing Rails Active MCP!\n\nQuick
309
+ Start:\n1. Add to your Rails app: rails generate rails_active_mcp:install\n2. Test
310
+ the setup: rails rails_active_mcp:status\n3. Configure Claude Desktop: rails rails_active_mcp:install_claude_config\n\n\U0001F4DA
311
+ Documentation: https://github.com/goodpie/rails-active-mcp#readme\n\U0001F41B Issues:
312
+ https://github.com/goodpie/rails-active-mcp/issues\n\U0001F4AC Discussions: https://github.com/goodpie/rails-active-mcp/discussions\n\nFollow
313
+ the project: ⭐ https://github.com/goodpie/rails-active-mcp\n\n"
255
314
  rdoc_options: []
256
315
  require_paths:
257
316
  - lib
@@ -268,5 +327,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
327
  requirements: []
269
328
  rubygems_version: 3.6.2
270
329
  specification_version: 4
271
- summary: Rails Console access via Model Context Protocol (MCP)
330
+ summary: Secure Rails console access via Model Context Protocol (MCP)
272
331
  test_files: []
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsActiveMcp
4
- class McpController < ApplicationController
5
- protect_from_forgery with: :null_session
6
- before_action :check_enabled
7
- before_action :set_cors_headers
8
-
9
- def handle
10
- return head :method_not_allowed unless request.post?
11
- return head :bad_request unless json_request?
12
-
13
- begin
14
- body = request.body.read
15
- data = JSON.parse(body)
16
-
17
- mcp_server = RailsActiveMcp::McpServer.new
18
- response_data = mcp_server.handle_jsonrpc_request(data)
19
-
20
- render json: response_data
21
- rescue JSON::ParserError
22
- render json: { error: 'Invalid JSON' }, status: :bad_request
23
- rescue StandardError => e
24
- RailsActiveMcp.logger.error "MCP Controller Error: #{e.message}"
25
- render json: { error: 'Internal Server Error' }, status: :internal_server_error
26
- end
27
- end
28
-
29
- def sse
30
- response.headers['Content-Type'] = 'text/event-stream'
31
- response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
32
- response.headers['Connection'] = 'keep-alive'
33
- response.headers['X-Accel-Buffering'] = 'no'
34
-
35
- # Send initial connection established event
36
- render plain: ": SSE connection established\n\nevent: endpoint\ndata: #{request.base_url}#{rails_active_mcp.root_path}messages\n\nretry: 100\n\n"
37
- end
38
-
39
- def health
40
- status = RailsActiveMcp.config.enabled ? 'healthy' : 'disabled'
41
- render json: {
42
- status: status,
43
- version: RailsActiveMcp::VERSION,
44
- timestamp: Time.current.iso8601
45
- }
46
- end
47
-
48
- def info
49
- render json: {
50
- name: 'Rails Active MCP',
51
- version: RailsActiveMcp::VERSION,
52
- description: 'Rails Console access via Model Context Protocol (MCP)',
53
- endpoints: {
54
- mcp: rails_active_mcp.root_path,
55
- health: rails_active_mcp.root_path + 'health'
56
- },
57
- enabled: RailsActiveMcp.config.enabled
58
- }
59
- end
60
-
61
- private
62
-
63
- def check_enabled
64
- return if RailsActiveMcp.config.enabled
65
-
66
- render json: { error: 'Rails Active MCP is disabled' }, status: :service_unavailable
67
- end
68
-
69
- def json_request?
70
- request.content_type&.include?('application/json')
71
- end
72
-
73
- def set_cors_headers
74
- response.headers['Access-Control-Allow-Origin'] = '*'
75
- response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
76
- response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
77
- response.headers['Access-Control-Max-Age'] = '86400'
78
- end
79
- end
80
- end