rails-active-mcp 2.0.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.
- checksums.yaml +4 -4
- data/examples/rails_app_integration.md +405 -0
- data/gemfiles/rails_7.1.gemfile +34 -0
- data/lib/generators/rails_active_mcp/install/templates/README.md +134 -54
- data/lib/generators/rails_active_mcp/install/templates/initializer.rb +44 -6
- data/lib/rails_active_mcp/tasks.rake +236 -80
- data/lib/rails_active_mcp/version.rb +1 -1
- data/rails_active_mcp.gemspec +58 -10
- metadata +62 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c09ba8583ba6900c91cef975c1942d1e5615c27d40c06d4bd58a05e755af0187
|
4
|
+
data.tar.gz: c30c261d6991156ea8f4ab01ab28bd9de1e51443cbd50e1f53b18e0c7cad85f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50e1b520e0ee3b5ceb79543c451176cf40569759a07660c7609b7c4ba4d2c97cbaacd10281c377a323d96600573f36526c9838a4795b120016d5cccace12e690
|
7
|
+
data.tar.gz: 26ed8f90667ceefd1c83240e2f193c8b53bd5b9fe2b2b077cfb7d880fba58b288e03b0a0fe4ed08a463150712286a44d54016f19a1789e5877bcc837334343d2
|
@@ -0,0 +1,405 @@
|
|
1
|
+
# Rails Active MCP - Real-World Integration Examples
|
2
|
+
|
3
|
+
This guide demonstrates how to integrate Rails Active MCP in various real-world scenarios, following the best practices outlined in the [Rails application structure guide](https://dev.to/kimrgrey/tuning-rails-application-structure-5f74).
|
4
|
+
|
5
|
+
## E-commerce Application Example
|
6
|
+
|
7
|
+
### Model Setup
|
8
|
+
```ruby
|
9
|
+
# app/models/user.rb
|
10
|
+
class User < ApplicationRecord
|
11
|
+
has_many :orders, dependent: :destroy
|
12
|
+
has_one :profile, dependent: :destroy
|
13
|
+
|
14
|
+
validates :email, presence: true, uniqueness: true
|
15
|
+
scope :active, -> { where(active: true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
# app/models/order.rb
|
19
|
+
class Order < ApplicationRecord
|
20
|
+
belongs_to :user
|
21
|
+
has_many :order_items, dependent: :destroy
|
22
|
+
has_many :products, through: :order_items
|
23
|
+
|
24
|
+
validates :total_amount, presence: true, numericality: { greater_than: 0 }
|
25
|
+
scope :recent, -> { where('created_at > ?', 1.week.ago) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# app/models/product.rb
|
29
|
+
class Product < ApplicationRecord
|
30
|
+
has_many :order_items
|
31
|
+
has_many :orders, through: :order_items
|
32
|
+
|
33
|
+
validates :name, presence: true
|
34
|
+
validates :price, presence: true, numericality: { greater_than: 0 }
|
35
|
+
scope :available, -> { where(available: true) }
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
### Configuration for E-commerce
|
40
|
+
```ruby
|
41
|
+
# config/initializers/rails_active_mcp.rb
|
42
|
+
RailsActiveMcp.configure do |config|
|
43
|
+
# Core safety settings
|
44
|
+
config.safe_mode = true
|
45
|
+
config.max_results = 100
|
46
|
+
config.command_timeout = 30
|
47
|
+
|
48
|
+
# Environment-specific settings
|
49
|
+
case Rails.env
|
50
|
+
when 'production'
|
51
|
+
# Strict production settings
|
52
|
+
config.safe_mode = true
|
53
|
+
config.max_results = 50
|
54
|
+
config.command_timeout = 15
|
55
|
+
config.log_executions = true
|
56
|
+
|
57
|
+
# Only allow safe models in production
|
58
|
+
config.allowed_models = %w[User Order Product OrderItem]
|
59
|
+
|
60
|
+
when 'development'
|
61
|
+
# More permissive for development
|
62
|
+
config.safe_mode = false
|
63
|
+
config.max_results = 200
|
64
|
+
config.command_timeout = 60
|
65
|
+
config.log_level = :debug
|
66
|
+
|
67
|
+
when 'staging'
|
68
|
+
# Production-like but slightly more permissive
|
69
|
+
config.safe_mode = true
|
70
|
+
config.max_results = 100
|
71
|
+
config.command_timeout = 30
|
72
|
+
config.log_executions = true
|
73
|
+
end
|
74
|
+
|
75
|
+
# Custom safety patterns for e-commerce
|
76
|
+
config.custom_safety_patterns = [
|
77
|
+
{
|
78
|
+
pattern: /payment.*delete|destroy.*payment/i,
|
79
|
+
description: "Payment data modification is dangerous"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
pattern: /User.*\.update_all.*role/i,
|
83
|
+
description: "Mass role updates are dangerous"
|
84
|
+
}
|
85
|
+
]
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
### Claude Desktop Queries for E-commerce
|
90
|
+
|
91
|
+
#### Sales Analytics
|
92
|
+
```ruby
|
93
|
+
# Ask Claude: "What are our sales metrics for the last week?"
|
94
|
+
Order.recent.sum(:total_amount)
|
95
|
+
Order.recent.count
|
96
|
+
Order.recent.average(:total_amount)
|
97
|
+
|
98
|
+
# Ask Claude: "Who are our top customers by order value?"
|
99
|
+
User.joins(:orders)
|
100
|
+
.group('users.id', 'users.email')
|
101
|
+
.order('SUM(orders.total_amount) DESC')
|
102
|
+
.limit(10)
|
103
|
+
.pluck('users.email', 'SUM(orders.total_amount)')
|
104
|
+
```
|
105
|
+
|
106
|
+
#### Inventory Management
|
107
|
+
```ruby
|
108
|
+
# Ask Claude: "Which products are running low on inventory?"
|
109
|
+
Product.where('inventory_count < ?', 10)
|
110
|
+
.order(:inventory_count)
|
111
|
+
.pluck(:name, :inventory_count)
|
112
|
+
|
113
|
+
# Ask Claude: "What are our best-selling products this month?"
|
114
|
+
Product.joins(:order_items)
|
115
|
+
.where(order_items: { created_at: 1.month.ago.. })
|
116
|
+
.group(:name)
|
117
|
+
.order('COUNT(*) DESC')
|
118
|
+
.limit(10)
|
119
|
+
.count
|
120
|
+
```
|
121
|
+
|
122
|
+
#### Customer Support
|
123
|
+
```ruby
|
124
|
+
# Ask Claude: "Find recent orders for customer email@example.com"
|
125
|
+
User.find_by(email: 'email@example.com')
|
126
|
+
&.orders
|
127
|
+
&.recent
|
128
|
+
&.includes(:products)
|
129
|
+
&.map { |o| { id: o.id, total: o.total_amount, products: o.products.pluck(:name) } }
|
130
|
+
|
131
|
+
# Ask Claude: "Check the User model structure"
|
132
|
+
# Uses model_info tool to show schema, associations, validations
|
133
|
+
```
|
134
|
+
|
135
|
+
## SaaS Application Example
|
136
|
+
|
137
|
+
### Multi-tenant Setup
|
138
|
+
```ruby
|
139
|
+
# app/models/account.rb
|
140
|
+
class Account < ApplicationRecord
|
141
|
+
has_many :users, dependent: :destroy
|
142
|
+
has_many :projects, dependent: :destroy
|
143
|
+
|
144
|
+
validates :name, presence: true
|
145
|
+
validates :plan, inclusion: { in: %w[free pro enterprise] }
|
146
|
+
end
|
147
|
+
|
148
|
+
# app/models/project.rb
|
149
|
+
class Project < ApplicationRecord
|
150
|
+
belongs_to :account
|
151
|
+
belongs_to :user, -> { where(role: 'owner') }
|
152
|
+
has_many :tasks, dependent: :destroy
|
153
|
+
|
154
|
+
validates :name, presence: true
|
155
|
+
scope :active, -> { where(archived: false) }
|
156
|
+
end
|
157
|
+
```
|
158
|
+
|
159
|
+
### SaaS-specific Configuration
|
160
|
+
```ruby
|
161
|
+
# config/initializers/rails_active_mcp.rb
|
162
|
+
RailsActiveMcp.configure do |config|
|
163
|
+
config.safe_mode = true
|
164
|
+
config.max_results = 100
|
165
|
+
|
166
|
+
# Tenant isolation safety
|
167
|
+
config.custom_safety_patterns = [
|
168
|
+
{
|
169
|
+
pattern: /Account.*delete_all|destroy_all/i,
|
170
|
+
description: "Account mass operations are forbidden"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
pattern: /User.*update_all.*account_id/i,
|
174
|
+
description: "Cross-tenant user moves are dangerous"
|
175
|
+
}
|
176
|
+
]
|
177
|
+
|
178
|
+
# Production tenant restrictions
|
179
|
+
if Rails.env.production?
|
180
|
+
config.allowed_models = %w[Account User Project Task]
|
181
|
+
config.max_results = 50
|
182
|
+
end
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
### Claude Queries for SaaS Analytics
|
187
|
+
```ruby
|
188
|
+
# Ask Claude: "How many active accounts do we have by plan?"
|
189
|
+
Account.group(:plan).count
|
190
|
+
|
191
|
+
# Ask Claude: "What's our monthly recurring revenue?"
|
192
|
+
Account.where(plan: ['pro', 'enterprise'])
|
193
|
+
.sum('CASE
|
194
|
+
WHEN plan = "pro" THEN 29
|
195
|
+
WHEN plan = "enterprise" THEN 99
|
196
|
+
ELSE 0 END')
|
197
|
+
|
198
|
+
# Ask Claude: "Which accounts have the most projects?"
|
199
|
+
Account.joins(:projects)
|
200
|
+
.group('accounts.name')
|
201
|
+
.order('COUNT(projects.id) DESC')
|
202
|
+
.limit(10)
|
203
|
+
.count
|
204
|
+
```
|
205
|
+
|
206
|
+
## Content Management System Example
|
207
|
+
|
208
|
+
### CMS Model Structure
|
209
|
+
```ruby
|
210
|
+
# app/models/article.rb
|
211
|
+
class Article < ApplicationRecord
|
212
|
+
belongs_to :author, class_name: 'User'
|
213
|
+
belongs_to :category
|
214
|
+
has_many :comments, dependent: :destroy
|
215
|
+
|
216
|
+
validates :title, presence: true
|
217
|
+
validates :content, presence: true
|
218
|
+
|
219
|
+
scope :published, -> { where(published: true) }
|
220
|
+
scope :recent, -> { order(created_at: :desc) }
|
221
|
+
end
|
222
|
+
|
223
|
+
# app/models/category.rb
|
224
|
+
class Category < ApplicationRecord
|
225
|
+
has_many :articles
|
226
|
+
validates :name, presence: true, uniqueness: true
|
227
|
+
end
|
228
|
+
```
|
229
|
+
|
230
|
+
### CMS Configuration
|
231
|
+
```ruby
|
232
|
+
# config/initializers/rails_active_mcp.rb
|
233
|
+
RailsActiveMcp.configure do |config|
|
234
|
+
config.safe_mode = true
|
235
|
+
|
236
|
+
# Content-specific safety patterns
|
237
|
+
config.custom_safety_patterns = [
|
238
|
+
{
|
239
|
+
pattern: /Article.*delete_all.*published.*true/i,
|
240
|
+
description: "Mass deletion of published articles is dangerous"
|
241
|
+
}
|
242
|
+
]
|
243
|
+
|
244
|
+
# Environment-specific settings
|
245
|
+
case Rails.env
|
246
|
+
when 'production'
|
247
|
+
config.allowed_models = %w[Article Category User Comment]
|
248
|
+
config.max_results = 25 # Smaller for content queries
|
249
|
+
end
|
250
|
+
end
|
251
|
+
```
|
252
|
+
|
253
|
+
### Claude Queries for Content Analytics
|
254
|
+
```ruby
|
255
|
+
# Ask Claude: "What are our most popular categories?"
|
256
|
+
Category.joins(:articles)
|
257
|
+
.where(articles: { published: true })
|
258
|
+
.group(:name)
|
259
|
+
.order('COUNT(articles.id) DESC')
|
260
|
+
.count
|
261
|
+
|
262
|
+
# Ask Claude: "Show me recent article performance"
|
263
|
+
Article.published
|
264
|
+
.recent
|
265
|
+
.limit(10)
|
266
|
+
.pluck(:title, :views_count, :created_at)
|
267
|
+
|
268
|
+
# Ask Claude: "Find articles that need moderation"
|
269
|
+
Article.joins(:comments)
|
270
|
+
.where(comments: { flagged: true })
|
271
|
+
.distinct
|
272
|
+
.pluck(:title, :id)
|
273
|
+
```
|
274
|
+
|
275
|
+
## Advanced Safety Patterns
|
276
|
+
|
277
|
+
### Custom Validators
|
278
|
+
```ruby
|
279
|
+
# config/initializers/rails_active_mcp.rb
|
280
|
+
RailsActiveMcp.configure do |config|
|
281
|
+
# Financial data protection
|
282
|
+
config.custom_safety_patterns += [
|
283
|
+
{ pattern: /payment|billing|card|bank/i, description: "Financial data access" },
|
284
|
+
{ pattern: /password|token|secret|key/i, description: "Sensitive credential access" },
|
285
|
+
{ pattern: /delete.*where.*id.*in/i, description: "Bulk deletion by ID list" }
|
286
|
+
]
|
287
|
+
|
288
|
+
# Model-specific restrictions
|
289
|
+
config.allowed_models = case Rails.env
|
290
|
+
when 'production'
|
291
|
+
%w[User Order Product Customer Invoice] # Whitelist approach
|
292
|
+
else
|
293
|
+
[] # Empty = allow all models
|
294
|
+
end
|
295
|
+
end
|
296
|
+
```
|
297
|
+
|
298
|
+
### Environment-specific Presets
|
299
|
+
```ruby
|
300
|
+
# config/initializers/rails_active_mcp.rb
|
301
|
+
RailsActiveMcp.configure do |config|
|
302
|
+
case Rails.env
|
303
|
+
when 'production'
|
304
|
+
# Ultra-safe production mode
|
305
|
+
config.safe_mode = true
|
306
|
+
config.command_timeout = 10
|
307
|
+
config.max_results = 25
|
308
|
+
config.log_executions = true
|
309
|
+
|
310
|
+
when 'staging'
|
311
|
+
# Production-like testing
|
312
|
+
config.safe_mode = true
|
313
|
+
config.command_timeout = 20
|
314
|
+
config.max_results = 50
|
315
|
+
config.log_executions = true
|
316
|
+
|
317
|
+
when 'development'
|
318
|
+
# Developer-friendly
|
319
|
+
config.safe_mode = false
|
320
|
+
config.command_timeout = 60
|
321
|
+
config.max_results = 200
|
322
|
+
config.log_level = :debug
|
323
|
+
|
324
|
+
when 'test'
|
325
|
+
# Fast and minimal for tests
|
326
|
+
config.safe_mode = true
|
327
|
+
config.command_timeout = 5
|
328
|
+
config.max_results = 10
|
329
|
+
config.log_executions = false
|
330
|
+
end
|
331
|
+
end
|
332
|
+
```
|
333
|
+
|
334
|
+
## Best Practices
|
335
|
+
|
336
|
+
### 1. Always Use Limits
|
337
|
+
```ruby
|
338
|
+
# ✅ Good - Always include limits
|
339
|
+
User.where(active: true).limit(10)
|
340
|
+
Order.recent.limit(20)
|
341
|
+
|
342
|
+
# ❌ Avoid - Unlimited queries can overwhelm Claude
|
343
|
+
User.all
|
344
|
+
Order.where(status: 'pending')
|
345
|
+
```
|
346
|
+
|
347
|
+
### 2. Prefer Aggregations Over Raw Data
|
348
|
+
```ruby
|
349
|
+
# ✅ Good - Summary data
|
350
|
+
User.group(:status).count
|
351
|
+
Order.group_by_day(:created_at).sum(:total_amount)
|
352
|
+
|
353
|
+
# ❌ Less useful - Raw data dumps
|
354
|
+
User.pluck(:email, :status, :created_at)
|
355
|
+
```
|
356
|
+
|
357
|
+
### 3. Use Meaningful Scopes
|
358
|
+
```ruby
|
359
|
+
# ✅ Good - Readable business logic
|
360
|
+
User.active.recent_signups.count
|
361
|
+
Order.completed.this_month.sum(:total_amount)
|
362
|
+
|
363
|
+
# ❌ Less clear - Complex inline conditions
|
364
|
+
User.where(active: true, created_at: 1.week.ago..).count
|
365
|
+
```
|
366
|
+
|
367
|
+
### 4. Structure Claude Queries Naturally
|
368
|
+
```ruby
|
369
|
+
# Ask Claude natural questions:
|
370
|
+
# "How many users signed up this week?"
|
371
|
+
# "What's our average order value?"
|
372
|
+
# "Which products need restocking?"
|
373
|
+
# "Show me the User model structure"
|
374
|
+
```
|
375
|
+
|
376
|
+
## Troubleshooting Common Issues
|
377
|
+
|
378
|
+
### Performance Issues
|
379
|
+
```ruby
|
380
|
+
# Monitor execution times
|
381
|
+
rails rails_active_mcp:benchmark
|
382
|
+
|
383
|
+
# Check for slow queries
|
384
|
+
rails rails_active_mcp:status
|
385
|
+
```
|
386
|
+
|
387
|
+
### Safety Violations
|
388
|
+
```ruby
|
389
|
+
# Test code safety before asking Claude
|
390
|
+
rails rails_active_mcp:check_safety['User.delete_all']
|
391
|
+
|
392
|
+
# View current configuration
|
393
|
+
rails rails_active_mcp:validate_config
|
394
|
+
```
|
395
|
+
|
396
|
+
### Claude Desktop Integration
|
397
|
+
```ruby
|
398
|
+
# Generate Claude Desktop config
|
399
|
+
rails rails_active_mcp:install_claude_config
|
400
|
+
|
401
|
+
# Test server connectivity
|
402
|
+
bin/rails-active-mcp-wrapper
|
403
|
+
```
|
404
|
+
|
405
|
+
This comprehensive integration guide helps Rails developers understand how to effectively use Rails Active MCP in real-world applications, following modern Rails patterns and ensuring secure, efficient AI-powered database interactions.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Rails 7.1 Gemfile for CI testing
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
# Specify the Rails version
|
5
|
+
gem 'rails', '~> 7.1.0'
|
6
|
+
|
7
|
+
# Include the main gemspec
|
8
|
+
gemspec path: '../'
|
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
|
+
group :development, :test do
|
31
|
+
gem 'rubocop'
|
32
|
+
gem 'rubocop-rails'
|
33
|
+
gem 'rubocop-rspec'
|
34
|
+
end
|
@@ -1,54 +1,134 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
1
|
+
# Rails Active MCP Integration
|
2
|
+
|
3
|
+
This Rails application is configured with Rails Active MCP for secure AI-powered database querying and model inspection.
|
4
|
+
|
5
|
+
## What is Rails Active MCP?
|
6
|
+
|
7
|
+
Rails Active MCP enables secure Rails console access through Model Context Protocol (MCP) for AI agents and development tools like Claude Desktop. It provides four main tools:
|
8
|
+
|
9
|
+
- **console_execute**: Execute Ruby/Rails code with safety checks
|
10
|
+
- **model_info**: Inspect Rails models (schema, associations, validations)
|
11
|
+
- **safe_query**: Run read-only database queries
|
12
|
+
- **dry_run**: Analyze code safety without execution
|
13
|
+
|
14
|
+
## Quick Start
|
15
|
+
|
16
|
+
### 1. Test the Installation
|
17
|
+
|
18
|
+
```bash
|
19
|
+
# Test the server starts correctly
|
20
|
+
bin/rails-active-mcp-wrapper
|
21
|
+
|
22
|
+
# Enable debug mode for troubleshooting
|
23
|
+
RAILS_MCP_DEBUG=1 bin/rails-active-mcp-server
|
24
|
+
```
|
25
|
+
|
26
|
+
### 2. Configure Claude Desktop
|
27
|
+
|
28
|
+
Add this to your Claude Desktop configuration:
|
29
|
+
|
30
|
+
**macOS/Linux**: `~/.config/claude-desktop/claude_desktop_config.json`
|
31
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
32
|
+
|
33
|
+
```json
|
34
|
+
{
|
35
|
+
"mcpServers": {
|
36
|
+
"rails-active-mcp": {
|
37
|
+
"command": "/path/to/your/rails/app/bin/rails-active-mcp-wrapper",
|
38
|
+
"cwd": "/path/to/your/rails/app",
|
39
|
+
"env": {
|
40
|
+
"RAILS_ENV": "development"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
### 3. Try These Commands in Claude Desktop
|
48
|
+
|
49
|
+
- "Show me the User model structure"
|
50
|
+
- "How many users were created in the last week?"
|
51
|
+
- "What are the most recent orders?"
|
52
|
+
- "Check if this code is safe: `User.delete_all`"
|
53
|
+
|
54
|
+
## Configuration
|
55
|
+
|
56
|
+
Your MCP integration is configured in `config/initializers/rails_active_mcp.rb`.
|
57
|
+
|
58
|
+
### Environment-Specific Settings
|
59
|
+
|
60
|
+
- **Development**: More permissive, verbose logging
|
61
|
+
- **Production**: Strict safety, limited results, audit logging
|
62
|
+
- **Test**: Minimal logging, safety enabled
|
63
|
+
|
64
|
+
### Customizing Safety Rules
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# Add custom safety patterns
|
68
|
+
config.custom_safety_patterns = [
|
69
|
+
{ pattern: /YourDangerousMethod/, description: "Custom dangerous operation" }
|
70
|
+
]
|
71
|
+
|
72
|
+
# Restrict model access (empty = allow all)
|
73
|
+
config.allowed_models = %w[User Post Comment]
|
74
|
+
```
|
75
|
+
|
76
|
+
## Available Rake Tasks
|
77
|
+
|
78
|
+
```bash
|
79
|
+
# Check code safety
|
80
|
+
rails rails_active_mcp:check_safety['User.count']
|
81
|
+
|
82
|
+
# Execute code with safety checks
|
83
|
+
rails rails_active_mcp:execute['User.count']
|
84
|
+
|
85
|
+
# Test MCP tools
|
86
|
+
rails rails_active_mcp:test_tools
|
87
|
+
```
|
88
|
+
|
89
|
+
## Troubleshooting
|
90
|
+
|
91
|
+
### Server Won't Start
|
92
|
+
- Ensure your Rails app starts without errors: `rails console`
|
93
|
+
- Check Ruby version compatibility
|
94
|
+
- Verify all gems are installed: `bundle install`
|
95
|
+
|
96
|
+
### Claude Desktop Connection Issues
|
97
|
+
- Restart Claude Desktop after configuration changes
|
98
|
+
- Check logs: `~/Library/Logs/Claude/mcp*.log` (macOS)
|
99
|
+
- Test server manually: `bin/rails-active-mcp-wrapper`
|
100
|
+
|
101
|
+
### Permission Errors
|
102
|
+
- Ensure wrapper script is executable: `chmod +x bin/rails-active-mcp-wrapper`
|
103
|
+
- Check Ruby path in wrapper script matches your setup
|
104
|
+
|
105
|
+
## Security Notes
|
106
|
+
|
107
|
+
- All dangerous operations are blocked by default in safe mode
|
108
|
+
- Production mode enables the strictest safety settings
|
109
|
+
- All executions can be logged for audit purposes
|
110
|
+
- Model access can be restricted via configuration
|
111
|
+
|
112
|
+
## Examples
|
113
|
+
|
114
|
+
### Safe Operations (Always Allowed)
|
115
|
+
```ruby
|
116
|
+
User.count
|
117
|
+
Post.where(published: true).limit(10)
|
118
|
+
User.find(1).posts.includes(:comments)
|
119
|
+
Rails.env
|
120
|
+
```
|
121
|
+
|
122
|
+
### Risky Operations (Blocked in Safe Mode)
|
123
|
+
```ruby
|
124
|
+
User.delete_all # Mass deletion
|
125
|
+
system('rm -rf /') # System commands
|
126
|
+
eval(user_input) # Code evaluation
|
127
|
+
File.delete('file') # File operations
|
128
|
+
```
|
129
|
+
|
130
|
+
## Getting Help
|
131
|
+
|
132
|
+
- **Documentation**: https://github.com/goodpie/rails-active-mcp
|
133
|
+
- **Issues**: https://github.com/goodpie/rails-active-mcp/issues
|
134
|
+
- **MCP Protocol**: https://modelcontextprotocol.io
|
@@ -16,15 +16,45 @@ RailsActiveMcp.configure do |config|
|
|
16
16
|
config.enable_logging = true
|
17
17
|
config.log_level = :info # :debug, :info, :warn, :error
|
18
18
|
|
19
|
+
# Safety configuration
|
20
|
+
config.safe_mode = true # Enable safety checks by default
|
21
|
+
config.max_results = 100 # Limit query results to prevent large dumps
|
22
|
+
config.log_executions = true # Log all executions for audit trail
|
23
|
+
|
24
|
+
# Model access control (empty arrays allow all)
|
25
|
+
config.allowed_models = [] # Whitelist specific models if needed
|
26
|
+
# config.allowed_models = %w[User Post Comment] # Example: restrict to specific models
|
27
|
+
|
28
|
+
# Custom safety patterns for your application
|
29
|
+
# config.custom_safety_patterns = [
|
30
|
+
# { pattern: /YourDangerousMethod/, description: "Your custom dangerous operation" }
|
31
|
+
# ]
|
32
|
+
|
19
33
|
# Environment-specific adjustments
|
20
|
-
|
21
|
-
|
34
|
+
case Rails.env
|
35
|
+
when 'production'
|
36
|
+
# Strict settings for production
|
37
|
+
config.safe_mode = true
|
22
38
|
config.log_level = :warn
|
23
39
|
config.command_timeout = 15
|
24
|
-
|
40
|
+
config.max_results = 50
|
41
|
+
config.log_executions = true
|
42
|
+
config.allowed_models = [] # Consider restricting models in production
|
43
|
+
|
44
|
+
when 'development'
|
25
45
|
# More permissive settings for development
|
46
|
+
config.safe_mode = false # Allow more operations during development
|
26
47
|
config.log_level = :debug
|
27
48
|
config.command_timeout = 60
|
49
|
+
config.max_results = 200
|
50
|
+
config.log_executions = false
|
51
|
+
|
52
|
+
when 'test'
|
53
|
+
# Test-friendly settings
|
54
|
+
config.safe_mode = true
|
55
|
+
config.log_level = :error
|
56
|
+
config.command_timeout = 30
|
57
|
+
config.log_executions = false
|
28
58
|
end
|
29
59
|
end
|
30
60
|
|
@@ -36,7 +66,15 @@ end
|
|
36
66
|
# - safe_query: Execute safe read-only database queries
|
37
67
|
# - dry_run: Analyze Ruby code for safety without execution
|
38
68
|
#
|
39
|
-
#
|
40
|
-
#
|
69
|
+
# Quick Start:
|
70
|
+
# 1. Start the server: bin/rails-active-mcp-server
|
71
|
+
# 2. Configure Claude Desktop (see post-install instructions)
|
72
|
+
# 3. Try asking Claude: "Show me all users created in the last week"
|
73
|
+
#
|
74
|
+
# Testing the installation:
|
75
|
+
# - Run: bin/rails-active-mcp-wrapper (should output JSON responses)
|
76
|
+
# - Test with: RAILS_MCP_DEBUG=1 bin/rails-active-mcp-server
|
77
|
+
# - Check rake tasks: rails -T rails_active_mcp
|
41
78
|
#
|
42
|
-
#
|
79
|
+
# Documentation: https://github.com/goodpie/rails-active-mcp
|
80
|
+
# Need help? Create an issue or check the troubleshooting guide.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
namespace :rails_active_mcp do
|
2
|
-
desc
|
2
|
+
desc 'Check the safety of Ruby code'
|
3
3
|
task :check_safety, [:code] => :environment do |task, args|
|
4
4
|
code = args[:code]
|
5
5
|
|
@@ -24,7 +24,7 @@ namespace :rails_active_mcp do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
27
|
+
desc 'Execute Ruby code with safety checks'
|
28
28
|
task :execute, [:code] => :environment do |task, args|
|
29
29
|
code = args[:code]
|
30
30
|
|
@@ -44,111 +44,267 @@ namespace :rails_active_mcp do
|
|
44
44
|
puts "Error: #{result[:error]}"
|
45
45
|
puts "Error class: #{result[:error_class]}" if result[:error_class]
|
46
46
|
end
|
47
|
-
rescue => e
|
47
|
+
rescue StandardError => e
|
48
48
|
puts "Failed to execute: #{e.message}"
|
49
49
|
exit 1
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
desc
|
54
|
-
task :
|
55
|
-
puts
|
53
|
+
desc 'Test MCP tools'
|
54
|
+
task test_tools: :environment do
|
55
|
+
puts 'Testing Rails Active MCP tools...'
|
56
56
|
|
57
|
-
# Test
|
58
|
-
puts "\n1. Testing
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
# Test console execution
|
58
|
+
puts "\n1. Testing console_execute tool:"
|
59
|
+
result = RailsActiveMcp.execute('1 + 1')
|
60
|
+
puts " Simple math: #{result[:success] ? 'PASS' : 'FAIL'}"
|
61
|
+
|
62
|
+
# Test safety checking
|
63
|
+
puts "\n2. Testing safety checking:"
|
64
|
+
safe_result = RailsActiveMcp.safe?('User.count')
|
65
|
+
dangerous_result = RailsActiveMcp.safe?('User.delete_all')
|
66
|
+
puts " Safe code detection: #{safe_result ? 'PASS' : 'FAIL'}"
|
67
|
+
puts " Dangerous code detection: #{!dangerous_result ? 'PASS' : 'FAIL'}"
|
68
|
+
|
69
|
+
# Test Rails integration
|
70
|
+
puts "\n3. Testing Rails integration:"
|
71
|
+
if defined?(Rails) && Rails.respond_to?(:env)
|
72
|
+
puts " Rails environment: #{Rails.env} - PASS"
|
63
73
|
else
|
64
|
-
puts
|
74
|
+
puts ' Rails environment: NOT DETECTED - FAIL'
|
65
75
|
end
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
tool = RailsActiveMcp::Tools::ConsoleExecuteTool.new
|
70
|
-
result = tool.call(code: "1 + 1")
|
71
|
-
puts " 1 + 1: #{result[:success] ? result[:return_value] : result[:error]}"
|
77
|
+
puts "\nAll tests completed!"
|
78
|
+
end
|
72
79
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
result = tool.call(code: "User.delete_all")
|
77
|
-
puts " User.delete_all analysis: #{result[:estimated_risk]} risk"
|
80
|
+
desc 'Benchmark MCP tools performance'
|
81
|
+
task benchmark: :environment do
|
82
|
+
require 'benchmark'
|
78
83
|
|
79
|
-
puts
|
80
|
-
|
84
|
+
puts 'Rails Active MCP Performance Benchmark'
|
85
|
+
puts '=' * 50
|
81
86
|
|
82
|
-
|
83
|
-
|
84
|
-
|
87
|
+
# Benchmark safety checking
|
88
|
+
puts "\nSafety Checker Performance:"
|
89
|
+
Benchmark.bm(20) do |x|
|
90
|
+
x.report('Simple check:') do
|
91
|
+
1000.times { RailsActiveMcp.safe?('User.count') }
|
92
|
+
end
|
85
93
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
puts " Default timeout: #{config.default_timeout}s"
|
90
|
-
puts " Max results: #{config.max_results}"
|
91
|
-
puts " Log executions: #{config.log_executions}"
|
92
|
-
puts " Audit file: #{config.audit_file}"
|
93
|
-
puts " Enable mutation tools: #{config.enable_mutation_tools}"
|
94
|
-
puts " Execution environment: #{config.execution_environment}"
|
94
|
+
x.report('Complex check:') do
|
95
|
+
100.times { RailsActiveMcp.safe?('User.where(active: true).includes(:posts).limit(10)') }
|
96
|
+
end
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
+
x.report('Dangerous check:') do
|
99
|
+
1000.times { RailsActiveMcp.safe?('User.delete_all') }
|
100
|
+
end
|
98
101
|
end
|
99
102
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
+
# Benchmark code execution
|
104
|
+
puts "\nCode Execution Performance:"
|
105
|
+
Benchmark.bm(20) do |x|
|
106
|
+
x.report('Simple math:') do
|
107
|
+
100.times { RailsActiveMcp.execute('1 + 1') }
|
108
|
+
end
|
103
109
|
|
104
|
-
|
105
|
-
|
110
|
+
x.report('String operations:') do
|
111
|
+
100.times { RailsActiveMcp.execute('"hello".upcase') }
|
112
|
+
end
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
109
|
-
desc
|
110
|
-
task :
|
111
|
-
|
112
|
-
|
116
|
+
desc 'Validate Rails Active MCP configuration'
|
117
|
+
task validate_config: :environment do
|
118
|
+
puts 'Validating Rails Active MCP configuration...'
|
119
|
+
|
120
|
+
config = RailsActiveMcp.config
|
121
|
+
|
122
|
+
if config.valid?
|
123
|
+
puts '✅ Configuration is valid'
|
113
124
|
|
114
|
-
|
115
|
-
puts "
|
125
|
+
puts "\nCurrent Settings:"
|
126
|
+
puts " Safe mode: #{config.safe_mode}"
|
127
|
+
puts " Command timeout: #{config.command_timeout}s"
|
128
|
+
puts " Max results: #{config.max_results}"
|
129
|
+
puts " Log executions: #{config.log_executions}"
|
130
|
+
puts " Log level: #{config.log_level}"
|
131
|
+
puts " Allowed models: #{config.allowed_models.any? ? config.allowed_models.join(', ') : 'All models allowed'}"
|
132
|
+
puts " Custom safety patterns: #{config.custom_safety_patterns.length} patterns"
|
133
|
+
else
|
134
|
+
puts '❌ Configuration is invalid'
|
135
|
+
puts 'Please check your config/initializers/rails_active_mcp.rb file'
|
116
136
|
exit 1
|
117
137
|
end
|
138
|
+
end
|
139
|
+
|
140
|
+
desc 'Generate example usage documentation'
|
141
|
+
task generate_examples: :environment do
|
142
|
+
examples_file = Rails.root.join('doc', 'rails_active_mcp_examples.md')
|
143
|
+
FileUtils.mkdir_p(File.dirname(examples_file))
|
144
|
+
|
145
|
+
content = <<~MARKDOWN
|
146
|
+
# Rails Active MCP Usage Examples
|
147
|
+
|
148
|
+
Generated on #{Date.current}
|
149
|
+
|
150
|
+
## Safe Operations
|
151
|
+
|
152
|
+
These operations are considered safe and can be executed in safe mode:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
# Basic model queries
|
156
|
+
User.count
|
157
|
+
User.all.limit(10)
|
158
|
+
User.where(active: true)
|
159
|
+
User.find(1)
|
160
|
+
|
161
|
+
# Associations
|
162
|
+
User.includes(:posts).limit(5)
|
163
|
+
Post.joins(:user).where(users: { active: true })
|
164
|
+
|
165
|
+
# Aggregations
|
166
|
+
Order.sum(:total_amount)
|
167
|
+
User.group(:status).count
|
168
|
+
|
169
|
+
# System information
|
170
|
+
Rails.env
|
171
|
+
Rails.version
|
172
|
+
Time.current
|
173
|
+
```
|
174
|
+
|
175
|
+
## Dangerous Operations (Blocked in Safe Mode)
|
176
|
+
|
177
|
+
These operations are blocked when safe_mode is enabled:
|
118
178
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
179
|
+
```ruby
|
180
|
+
# Mass deletions
|
181
|
+
User.delete_all
|
182
|
+
User.destroy_all
|
183
|
+
|
184
|
+
# System commands
|
185
|
+
system('rm -rf /')
|
186
|
+
`ls -la`
|
187
|
+
|
188
|
+
# File operations
|
189
|
+
File.delete('important_file.txt')
|
190
|
+
FileUtils.rm_rf('/important/directory')
|
191
|
+
|
192
|
+
# Code evaluation
|
193
|
+
eval(user_input)
|
194
|
+
send(dynamic_method)
|
195
|
+
```
|
196
|
+
|
197
|
+
## Claude Desktop Usage Examples
|
198
|
+
|
199
|
+
Ask Claude these questions to interact with your Rails app:
|
200
|
+
|
201
|
+
- "How many users do we have?"
|
202
|
+
- "Show me the User model structure"
|
203
|
+
- "What are the most recent orders?"
|
204
|
+
- "Check if this code is safe: User.where(active: false).delete_all"
|
205
|
+
- "Find users created in the last week"
|
206
|
+
- "What associations does the Post model have?"
|
207
|
+
|
208
|
+
## Configuration Examples
|
209
|
+
|
210
|
+
### Development Configuration
|
211
|
+
```ruby
|
212
|
+
RailsActiveMcp.configure do |config|
|
213
|
+
config.safe_mode = false
|
214
|
+
config.log_level = :debug
|
215
|
+
config.command_timeout = 60
|
216
|
+
config.max_results = 200
|
139
217
|
end
|
140
|
-
|
218
|
+
```
|
219
|
+
|
220
|
+
### Production Configuration
|
221
|
+
```ruby
|
222
|
+
RailsActiveMcp.configure do |config|
|
223
|
+
config.safe_mode = true
|
224
|
+
config.log_level = :warn
|
225
|
+
config.command_timeout = 15
|
226
|
+
config.max_results = 50
|
227
|
+
config.allowed_models = %w[User Post Comment]
|
228
|
+
end
|
229
|
+
```
|
230
|
+
MARKDOWN
|
231
|
+
|
232
|
+
File.write(examples_file, content)
|
233
|
+
puts "Examples generated at: #{examples_file}"
|
141
234
|
end
|
142
235
|
|
143
|
-
desc
|
144
|
-
task :
|
145
|
-
|
236
|
+
desc 'Install Claude Desktop configuration'
|
237
|
+
task install_claude_config: :environment do
|
238
|
+
config_template = {
|
239
|
+
mcpServers: {
|
240
|
+
'rails-active-mcp' => {
|
241
|
+
command: Rails.root.join('bin', 'rails-active-mcp-wrapper').to_s,
|
242
|
+
cwd: Rails.root.to_s,
|
243
|
+
env: {
|
244
|
+
RAILS_ENV: Rails.env
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
146
249
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
250
|
+
puts 'Claude Desktop Configuration:'
|
251
|
+
puts JSON.pretty_generate(config_template)
|
252
|
+
puts ''
|
253
|
+
puts 'Add this to your Claude Desktop configuration file:'
|
254
|
+
puts ' macOS/Linux: ~/.config/claude-desktop/claude_desktop_config.json'
|
255
|
+
puts ' Windows: %APPDATA%\\Claude\\claude_desktop_config.json'
|
256
|
+
end
|
257
|
+
|
258
|
+
desc 'Show comprehensive status and diagnostics'
|
259
|
+
task status: :environment do
|
260
|
+
puts 'Rails Active MCP Status Report'
|
261
|
+
puts '=' * 50
|
262
|
+
|
263
|
+
# Basic environment info
|
264
|
+
puts "\n📋 Environment Information:"
|
265
|
+
puts " Rails version: #{Rails.version}"
|
266
|
+
puts " Ruby version: #{RUBY_VERSION}"
|
267
|
+
puts " Rails environment: #{Rails.env}"
|
268
|
+
puts " Rails Active MCP version: #{RailsActiveMcp::VERSION}"
|
269
|
+
|
270
|
+
# Configuration status
|
271
|
+
puts "\n⚙️ Configuration Status:"
|
272
|
+
config = RailsActiveMcp.config
|
273
|
+
puts " Valid: #{config.valid? ? '✅' : '❌'}"
|
274
|
+
puts " Safe mode: #{config.safe_mode ? '🔒 Enabled' : '⚠️ Disabled'}"
|
275
|
+
puts " Timeout: #{config.command_timeout}s"
|
276
|
+
puts " Max results: #{config.max_results}"
|
277
|
+
|
278
|
+
# File status
|
279
|
+
puts "\n📁 File Status:"
|
280
|
+
files_to_check = [
|
281
|
+
'bin/rails-active-mcp-server',
|
282
|
+
'bin/rails-active-mcp-wrapper',
|
283
|
+
'config/initializers/rails_active_mcp.rb'
|
284
|
+
]
|
285
|
+
|
286
|
+
files_to_check.each do |file|
|
287
|
+
full_path = Rails.root.join(file)
|
288
|
+
if File.exist?(full_path)
|
289
|
+
executable = File.executable?(full_path)
|
290
|
+
puts " #{file}: ✅ #{executable ? '(executable)' : ''}"
|
291
|
+
else
|
292
|
+
puts " #{file}: ❌ Missing"
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
# Test basic functionality
|
297
|
+
puts "\n🧪 Functionality Test:"
|
298
|
+
begin
|
299
|
+
test_result = RailsActiveMcp.execute('1 + 1')
|
300
|
+
puts " Basic execution: #{test_result[:success] ? '✅' : '❌'}"
|
301
|
+
rescue StandardError => e
|
302
|
+
puts " Basic execution: ❌ (#{e.message})"
|
152
303
|
end
|
304
|
+
|
305
|
+
puts "\n🔗 Integration URLs:"
|
306
|
+
puts ' Documentation: https://github.com/goodpie/rails-active-mcp'
|
307
|
+
puts ' Issues: https://github.com/goodpie/rails-active-mcp/issues'
|
308
|
+
puts ' MCP Protocol: https://modelcontextprotocol.io'
|
153
309
|
end
|
154
|
-
end
|
310
|
+
end
|
data/rails_active_mcp.gemspec
CHANGED
@@ -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
|
12
|
-
spec.description =
|
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
|
18
|
-
|
19
|
-
|
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) }
|
@@ -44,11 +72,31 @@ Gem::Specification.new do |spec|
|
|
44
72
|
spec.add_dependency 'webrick', '~> 1.8'
|
45
73
|
|
46
74
|
# Development dependencies - keep versions consistent with Gemfile
|
75
|
+
spec.add_development_dependency 'colorize', '~> 0.8'
|
47
76
|
spec.add_development_dependency 'factory_bot_rails', '~> 6.0'
|
77
|
+
spec.add_development_dependency 'faker', '~> 2.19'
|
48
78
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
49
|
-
spec.add_development_dependency 'rspec-rails'
|
79
|
+
spec.add_development_dependency 'rspec-rails', '~> 6.0'
|
50
80
|
spec.add_development_dependency 'rubocop', '~> 1.77'
|
51
81
|
spec.add_development_dependency 'rubocop-rails', '~> 2.32'
|
52
|
-
spec.add_development_dependency 'rubocop-rspec'
|
82
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 3.0'
|
53
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
|
54
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: 2.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandyn Britton
|
@@ -119,6 +119,20 @@ dependencies:
|
|
119
119
|
- - "~>"
|
120
120
|
- !ruby/object:Gem::Version
|
121
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'
|
122
136
|
- !ruby/object:Gem::Dependency
|
123
137
|
name: factory_bot_rails
|
124
138
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +147,20 @@ dependencies:
|
|
133
147
|
- - "~>"
|
134
148
|
- !ruby/object:Gem::Version
|
135
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'
|
136
164
|
- !ruby/object:Gem::Dependency
|
137
165
|
name: rspec
|
138
166
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,16 +179,16 @@ dependencies:
|
|
151
179
|
name: rspec-rails
|
152
180
|
requirement: !ruby/object:Gem::Requirement
|
153
181
|
requirements:
|
154
|
-
- - "
|
182
|
+
- - "~>"
|
155
183
|
- !ruby/object:Gem::Version
|
156
|
-
version: '0'
|
184
|
+
version: '6.0'
|
157
185
|
type: :development
|
158
186
|
prerelease: false
|
159
187
|
version_requirements: !ruby/object:Gem::Requirement
|
160
188
|
requirements:
|
161
|
-
- - "
|
189
|
+
- - "~>"
|
162
190
|
- !ruby/object:Gem::Version
|
163
|
-
version: '0'
|
191
|
+
version: '6.0'
|
164
192
|
- !ruby/object:Gem::Dependency
|
165
193
|
name: rubocop
|
166
194
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,16 +221,16 @@ dependencies:
|
|
193
221
|
name: rubocop-rspec
|
194
222
|
requirement: !ruby/object:Gem::Requirement
|
195
223
|
requirements:
|
196
|
-
- - "
|
224
|
+
- - "~>"
|
197
225
|
- !ruby/object:Gem::Version
|
198
|
-
version: '0'
|
226
|
+
version: '3.0'
|
199
227
|
type: :development
|
200
228
|
prerelease: false
|
201
229
|
version_requirements: !ruby/object:Gem::Requirement
|
202
230
|
requirements:
|
203
|
-
- - "
|
231
|
+
- - "~>"
|
204
232
|
- !ruby/object:Gem::Version
|
205
|
-
version: '0'
|
233
|
+
version: '3.0'
|
206
234
|
- !ruby/object:Gem::Dependency
|
207
235
|
name: sqlite3
|
208
236
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,8 +245,14 @@ dependencies:
|
|
217
245
|
- - "~>"
|
218
246
|
- !ruby/object:Gem::Version
|
219
247
|
version: '2.7'
|
220
|
-
description:
|
221
|
-
|
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"
|
222
256
|
email:
|
223
257
|
- brandynbb96@gmail.com
|
224
258
|
executables:
|
@@ -237,7 +271,9 @@ files:
|
|
237
271
|
- docs/DEBUGGING.md
|
238
272
|
- docs/GENERATOR_TESTING.md
|
239
273
|
- docs/README.md
|
274
|
+
- examples/rails_app_integration.md
|
240
275
|
- exe/rails-active-mcp-server
|
276
|
+
- gemfiles/rails_7.1.gemfile
|
241
277
|
- lib/generators/rails_active_mcp/install/install_generator.rb
|
242
278
|
- lib/generators/rails_active_mcp/install/templates/README.md
|
243
279
|
- lib/generators/rails_active_mcp/install/templates/initializer.rb
|
@@ -261,8 +297,20 @@ licenses:
|
|
261
297
|
- MIT
|
262
298
|
metadata:
|
263
299
|
homepage_uri: https://github.com/goodpie/rails-active-mcp
|
264
|
-
source_code_uri: https://github.com/goodpie/rails-active-mcp
|
265
|
-
changelog_uri: https://github.com/goodpie/rails-active-mcp/blob/main/
|
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"
|
266
314
|
rdoc_options: []
|
267
315
|
require_paths:
|
268
316
|
- lib
|
@@ -279,5 +327,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
327
|
requirements: []
|
280
328
|
rubygems_version: 3.6.2
|
281
329
|
specification_version: 4
|
282
|
-
summary: Rails
|
330
|
+
summary: Secure Rails console access via Model Context Protocol (MCP)
|
283
331
|
test_files: []
|