rails-active-mcp 3.1.6 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f28a41a2349fa5ec8f70e64b084914e5e5bd8943684a0b828ae2f4d3b012535
|
|
4
|
+
data.tar.gz: 19e553886e52572e619c682fcef47a0f9c75e834adaba78c7abee6b408efeca6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6daf947e15e1d583db505a3574b432ff7220f08b881651818744df8e0db4946532ab5da568a16a94721e808578609b7af11649c7d162abb3a225d2da8a5f70cf
|
|
7
|
+
data.tar.gz: f89cafda34deb3791ecc426ad7dcba4e46975367c7b3ac9ea9a964ce4ca7b31a3789d2f38ee1bd7c5d9c43599dad7b85e5477b32de8caa3be8fb4c0bbf84c660
|
data/README.md
CHANGED
|
@@ -4,7 +4,9 @@ Note: This is just a personal project and while it works for the most part, I am
|
|
|
4
4
|
|
|
5
5
|
# Rails Active MCP
|
|
6
6
|
|
|
7
|
-
A Ruby gem that provides secure Rails console access through Model Context Protocol (MCP) for AI agents and development tools
|
|
7
|
+
A Ruby gem that provides secure Rails console access through [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) for AI agents and development tools. Built using the official MCP Ruby SDK for professional protocol handling and future-proof compatibility.
|
|
8
|
+
|
|
9
|
+
Works with any MCP-compatible client, including Claude Desktop, Claude Code, VS Code (GitHub Copilot), Cursor, Windsurf, ChatGPT, Gemini CLI, Amazon Q Developer, JetBrains IDEs, Zed, Warp, Cline, and [many more](https://modelcontextprotocol.io/clients).
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
|
|
@@ -30,12 +32,18 @@ bundle install
|
|
|
30
32
|
rails generate rails_active_mcp:install
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
This creates an initializer,
|
|
35
|
+
This creates an initializer, server scripts, and prompts you to select which MCP clients you use. It will automatically generate the correct project-level config files (`.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, etc.) so your MCP client detects the server when you open the project.
|
|
36
|
+
|
|
37
|
+
### 3. Connect your MCP client
|
|
38
|
+
|
|
39
|
+
If you selected your MCP client during installation, you're done — just open the project and the server will be detected automatically.
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
For manual configuration or additional clients, the server uses STDIO transport. Below are configuration examples for popular tools.
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
<details>
|
|
44
|
+
<summary><strong>Claude Desktop</strong></summary>
|
|
38
45
|
|
|
46
|
+
Edit your config file:
|
|
39
47
|
- **macOS/Linux:** `~/.config/claude-desktop/claude_desktop_config.json`
|
|
40
48
|
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
41
49
|
|
|
@@ -51,9 +59,141 @@ Add the following to your Claude Desktop configuration file:
|
|
|
51
59
|
}
|
|
52
60
|
```
|
|
53
61
|
|
|
54
|
-
Restart Claude Desktop
|
|
62
|
+
Restart Claude Desktop and the tools will appear automatically.
|
|
63
|
+
</details>
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary><strong>Claude Code</strong></summary>
|
|
67
|
+
|
|
68
|
+
From your Rails project directory:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
claude mcp add rails-active-mcp -- bundle exec rails-active-mcp-server
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or add it to your project's `.mcp.json`:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"rails-active-mcp": {
|
|
80
|
+
"command": "bundle",
|
|
81
|
+
"args": ["exec", "rails-active-mcp-server"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
<details>
|
|
89
|
+
<summary><strong>VS Code (GitHub Copilot)</strong></summary>
|
|
90
|
+
|
|
91
|
+
Add to your workspace `.vscode/mcp.json`:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"servers": {
|
|
96
|
+
"rails-active-mcp": {
|
|
97
|
+
"command": "bundle",
|
|
98
|
+
"args": ["exec", "rails-active-mcp-server"],
|
|
99
|
+
"cwd": "${workspaceFolder}"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Tools are available in Copilot's Agent mode.
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary><strong>Cursor</strong></summary>
|
|
110
|
+
|
|
111
|
+
Add to your project's `.cursor/mcp.json`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"rails-active-mcp": {
|
|
117
|
+
"command": "bundle",
|
|
118
|
+
"args": ["exec", "rails-active-mcp-server"],
|
|
119
|
+
"cwd": "/path/to/your/rails/project"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><strong>Windsurf</strong></summary>
|
|
128
|
+
|
|
129
|
+
Add to your project's `.windsurf/mcp.json`:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"rails-active-mcp": {
|
|
135
|
+
"command": "bundle",
|
|
136
|
+
"args": ["exec", "rails-active-mcp-server"],
|
|
137
|
+
"cwd": "/path/to/your/rails/project"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><strong>Zed</strong></summary>
|
|
146
|
+
|
|
147
|
+
Add to your Zed settings (`settings.json`):
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"context_servers": {
|
|
152
|
+
"rails-active-mcp": {
|
|
153
|
+
"command": {
|
|
154
|
+
"path": "bundle",
|
|
155
|
+
"args": ["exec", "rails-active-mcp-server"],
|
|
156
|
+
"env": {}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
</details>
|
|
163
|
+
|
|
164
|
+
<details>
|
|
165
|
+
<summary><strong>ChatGPT Desktop</strong></summary>
|
|
166
|
+
|
|
167
|
+
In ChatGPT Desktop, go to **Settings > Connectors > Advanced > Developer Mode**, then add:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"rails-active-mcp": {
|
|
173
|
+
"command": "bundle",
|
|
174
|
+
"args": ["exec", "rails-active-mcp-server"],
|
|
175
|
+
"cwd": "/path/to/your/rails/project"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
</details>
|
|
181
|
+
|
|
182
|
+
<details>
|
|
183
|
+
<summary><strong>Other MCP Clients</strong></summary>
|
|
184
|
+
|
|
185
|
+
Any MCP client that supports STDIO transport can connect to this server. The key details:
|
|
186
|
+
|
|
187
|
+
- **Command:** `bundle exec rails-active-mcp-server`
|
|
188
|
+
- **Working directory:** Your Rails project root
|
|
189
|
+
- **Transport:** STDIO (stdin/stdout)
|
|
190
|
+
|
|
191
|
+
See the [full list of MCP clients](https://modelcontextprotocol.io/clients) for more options.
|
|
192
|
+
</details>
|
|
193
|
+
|
|
194
|
+
Once connected, four tools will appear automatically: `console_execute`, `model_info`, `safe_query`, and `dry_run`.
|
|
55
195
|
|
|
56
|
-
Try asking
|
|
196
|
+
Try asking your AI assistant:
|
|
57
197
|
|
|
58
198
|
- "Show me all users created in the last week"
|
|
59
199
|
- "What's the average order value?"
|
|
@@ -91,9 +231,9 @@ end
|
|
|
91
231
|
|
|
92
232
|
## Usage
|
|
93
233
|
|
|
94
|
-
###
|
|
234
|
+
### MCP Client (Recommended)
|
|
95
235
|
|
|
96
|
-
Once connected (see [Quick Start](#quick-start)),
|
|
236
|
+
Once connected (see [Quick Start](#quick-start)), your MCP client automatically runs the server for you. The server loads your Rails application, initializes models, and provides secure access to your Rails environment via STDIO transport.
|
|
97
237
|
|
|
98
238
|
### Direct Usage
|
|
99
239
|
|
|
@@ -109,7 +249,7 @@ RailsActiveMcp.safe?("User.delete_all") # => false
|
|
|
109
249
|
|
|
110
250
|
### Running the Server Manually
|
|
111
251
|
|
|
112
|
-
If you need to run the server
|
|
252
|
+
If you need to run the server directly (e.g., for debugging):
|
|
113
253
|
|
|
114
254
|
```bash
|
|
115
255
|
bundle exec rails-active-mcp-server
|
|
@@ -120,7 +260,7 @@ RAILS_MCP_DEBUG=1 bundle exec rails-active-mcp-server
|
|
|
120
260
|
|
|
121
261
|
## Available MCP Tools
|
|
122
262
|
|
|
123
|
-
The Rails Active MCP server provides four powerful tools that appear automatically in
|
|
263
|
+
The Rails Active MCP server provides four powerful tools that appear automatically in any connected MCP client:
|
|
124
264
|
|
|
125
265
|
### 1. `console_execute`
|
|
126
266
|
|
|
@@ -131,7 +271,7 @@ Execute Ruby code with safety checks and timeout protection:
|
|
|
131
271
|
- **Timeout**: Configurable execution timeout
|
|
132
272
|
- **Logging**: All executions are logged for audit
|
|
133
273
|
|
|
134
|
-
**Example
|
|
274
|
+
**Example prompt:**
|
|
135
275
|
> "Execute `User.where(active: true).count`"
|
|
136
276
|
|
|
137
277
|
### 2. `model_info`
|
|
@@ -143,7 +283,7 @@ Get detailed information about Rails models:
|
|
|
143
283
|
- **Validations**: All model validations and rules
|
|
144
284
|
- **Methods**: Available instance and class methods
|
|
145
285
|
|
|
146
|
-
**Example
|
|
286
|
+
**Example prompt:**
|
|
147
287
|
> "Show me the User model structure"
|
|
148
288
|
|
|
149
289
|
### 3. `safe_query`
|
|
@@ -155,7 +295,7 @@ Execute safe, read-only database queries:
|
|
|
155
295
|
- **Result Limiting**: Prevents large data dumps
|
|
156
296
|
- **Model Context**: Works within your model definitions
|
|
157
297
|
|
|
158
|
-
**Example
|
|
298
|
+
**Example prompt:**
|
|
159
299
|
> "Get the 10 most recent orders"
|
|
160
300
|
|
|
161
301
|
### 4. `dry_run`
|
|
@@ -167,7 +307,7 @@ Analyze Ruby code for safety without executing:
|
|
|
167
307
|
- **Recommendations**: Suggests safer alternatives
|
|
168
308
|
- **Zero Execution**: Never runs the actual code
|
|
169
309
|
|
|
170
|
-
**Example
|
|
310
|
+
**Example prompt:**
|
|
171
311
|
> "Analyze this code for safety: `User.delete_all`"
|
|
172
312
|
|
|
173
313
|
## Safety Features
|
|
@@ -216,7 +356,7 @@ Rails Active MCP uses the official MCP Ruby SDK (`mcp` gem) for:
|
|
|
216
356
|
|
|
217
357
|
The server is implemented in `lib/rails_active_mcp/sdk/server.rb` and provides:
|
|
218
358
|
|
|
219
|
-
- **STDIO Transport**:
|
|
359
|
+
- **STDIO Transport**: Compatible with all major MCP clients
|
|
220
360
|
- **Tool Registration**: Automatic discovery of available tools
|
|
221
361
|
- **Error Handling**: Comprehensive error reporting and recovery
|
|
222
362
|
- **Rails Integration**: Deep integration with Rails applications
|
|
@@ -7,6 +7,14 @@ module RailsActiveMcp
|
|
|
7
7
|
|
|
8
8
|
desc 'Install Rails Active MCP'
|
|
9
9
|
|
|
10
|
+
MCP_CLIENTS = {
|
|
11
|
+
'claude_code' => { name: 'Claude Code', path: '.mcp.json', key: 'mcpServers' },
|
|
12
|
+
'cursor' => { name: 'Cursor', path: '.cursor/mcp.json', key: 'mcpServers' },
|
|
13
|
+
'vscode' => { name: 'VS Code / GitHub Copilot', path: '.vscode/mcp.json', key: 'servers' },
|
|
14
|
+
'claude_desktop' => { name: 'Claude Desktop', path: nil },
|
|
15
|
+
'windsurf' => { name: 'Windsurf', path: nil }
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
10
18
|
def create_initializer
|
|
11
19
|
template 'initializer.rb', 'config/initializers/rails_active_mcp.rb'
|
|
12
20
|
end
|
|
@@ -25,85 +33,211 @@ module RailsActiveMcp
|
|
|
25
33
|
template 'mcp.ru', 'mcp.ru'
|
|
26
34
|
end
|
|
27
35
|
|
|
28
|
-
def
|
|
29
|
-
|
|
36
|
+
def create_mcp_client_configs
|
|
37
|
+
return unless behavior == :invoke
|
|
38
|
+
|
|
39
|
+
say "\nWhich MCP clients do you use?", :green
|
|
40
|
+
say '(Select all that apply, separated by commas)', :yellow
|
|
41
|
+
say ''
|
|
42
|
+
|
|
43
|
+
client_keys = MCP_CLIENTS.keys
|
|
44
|
+
client_keys.each_with_index do |key, index|
|
|
45
|
+
say " #{index + 1}. #{MCP_CLIENTS[key][:name]}", :cyan
|
|
46
|
+
end
|
|
47
|
+
say " #{client_keys.size + 1}. Skip (configure manually later)", :cyan
|
|
48
|
+
say ''
|
|
49
|
+
|
|
50
|
+
response = ask('Enter your choices (e.g. 1,2,3):', :green)
|
|
51
|
+
@selected_clients = parse_client_selections(response, client_keys)
|
|
52
|
+
|
|
53
|
+
generate_client_configs
|
|
30
54
|
end
|
|
31
55
|
|
|
32
|
-
# rubocop:disable Metrics/AbcSize
|
|
33
56
|
def show_post_install_instructions
|
|
34
57
|
return unless behavior == :invoke
|
|
35
58
|
|
|
36
59
|
say "\n#{'=' * 50}", :green
|
|
37
60
|
say 'Rails Active MCP Installation Complete!', :green
|
|
38
|
-
say
|
|
61
|
+
say('=' * 50, :green)
|
|
62
|
+
|
|
63
|
+
show_created_files
|
|
64
|
+
show_quick_test
|
|
65
|
+
show_global_client_instructions
|
|
66
|
+
show_available_tools
|
|
67
|
+
show_example_prompts
|
|
68
|
+
show_troubleshooting
|
|
69
|
+
show_next_steps
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
def parse_client_selections(response, client_keys)
|
|
75
|
+
return [] if response.blank?
|
|
76
|
+
|
|
77
|
+
indices = response.split(',').map { |s| s.strip.to_i - 1 }
|
|
78
|
+
indices.filter_map { |i| client_keys[i] if i >= 0 && i < client_keys.size }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def generate_client_configs
|
|
82
|
+
@selected_clients.each do |client_key|
|
|
83
|
+
client = MCP_CLIENTS[client_key]
|
|
84
|
+
next unless client[:path]
|
|
85
|
+
|
|
86
|
+
write_client_config(client_key, client)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def write_client_config(client_key, client)
|
|
91
|
+
path = client[:path]
|
|
92
|
+
full_path = File.join(destination_root, path)
|
|
93
|
+
top_key = client[:key]
|
|
94
|
+
|
|
95
|
+
dir = File.dirname(path)
|
|
96
|
+
FileUtils.mkdir_p(File.join(destination_root, dir)) unless dir == '.'
|
|
97
|
+
|
|
98
|
+
server_entry = build_server_entry
|
|
99
|
+
|
|
100
|
+
if File.exist?(full_path)
|
|
101
|
+
merge_into_existing_config(full_path, path, top_key, server_entry, client[:name])
|
|
102
|
+
else
|
|
103
|
+
config = { top_key => { 'rails-active-mcp' => server_entry } }
|
|
104
|
+
create_file path, "#{JSON.pretty_generate(config)}\n"
|
|
105
|
+
say " Created #{path} for #{client[:name]}", :green
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
return unless client_key == 'vscode'
|
|
109
|
+
|
|
110
|
+
append_to_gitignore('.vscode/mcp.json')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def merge_into_existing_config(full_path, path, top_key, server_entry, client_name)
|
|
114
|
+
existing = JSON.parse(File.read(full_path))
|
|
115
|
+
existing[top_key] ||= {}
|
|
116
|
+
|
|
117
|
+
if existing[top_key].key?('rails-active-mcp')
|
|
118
|
+
say " Skipped #{path} — rails-active-mcp already configured for #{client_name}", :yellow
|
|
119
|
+
return
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
existing[top_key]['rails-active-mcp'] = server_entry
|
|
123
|
+
File.write(full_path, "#{JSON.pretty_generate(existing)}\n")
|
|
124
|
+
say " Updated #{path} — added rails-active-mcp for #{client_name}", :green
|
|
125
|
+
rescue JSON::ParserError
|
|
126
|
+
say " Skipped #{path} — file exists but contains invalid JSON", :red
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def build_server_entry
|
|
130
|
+
{
|
|
131
|
+
'command' => Rails.root.join('bin/rails-active-mcp-wrapper').to_s,
|
|
132
|
+
'args' => [],
|
|
133
|
+
'env' => { 'RAILS_ENV' => 'development' }
|
|
134
|
+
}
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def build_mcp_config(top_key)
|
|
138
|
+
{ top_key => { 'rails-active-mcp' => build_server_entry } }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def append_to_gitignore(entry)
|
|
142
|
+
gitignore_path = File.join(destination_root, '.gitignore')
|
|
143
|
+
return unless File.exist?(gitignore_path)
|
|
144
|
+
|
|
145
|
+
content = File.read(gitignore_path)
|
|
146
|
+
return if content.include?(entry)
|
|
147
|
+
|
|
148
|
+
append_to_file '.gitignore', "\n# MCP client config (may contain local paths)\n#{entry}\n"
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def show_created_files
|
|
39
152
|
say "\nFiles created:", :green
|
|
40
|
-
say '
|
|
41
|
-
say '
|
|
42
|
-
say '
|
|
43
|
-
say '
|
|
44
|
-
|
|
153
|
+
say ' config/initializers/rails_active_mcp.rb', :yellow
|
|
154
|
+
say ' bin/rails-active-mcp-wrapper', :yellow
|
|
155
|
+
say ' bin/rails-active-mcp-server', :yellow
|
|
156
|
+
say ' mcp.ru', :yellow
|
|
157
|
+
|
|
158
|
+
return unless @selected_clients&.any?
|
|
159
|
+
|
|
160
|
+
@selected_clients.each do |key|
|
|
161
|
+
path = MCP_CLIENTS[key][:path]
|
|
162
|
+
say " #{path}", :yellow if path
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def show_quick_test
|
|
45
167
|
say "\nQuick Test:", :green
|
|
46
|
-
say '1. Test the server: bin/rails-active-mcp-wrapper', :yellow
|
|
47
|
-
say '2. Should show JSON responses (not plain text)', :yellow
|
|
48
|
-
say '3. Exit with Ctrl+C', :yellow
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
say
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
say
|
|
168
|
+
say ' 1. Test the server: bin/rails-active-mcp-wrapper', :yellow
|
|
169
|
+
say ' 2. Should show JSON responses (not plain text)', :yellow
|
|
170
|
+
say ' 3. Exit with Ctrl+C', :yellow
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def show_global_client_instructions
|
|
174
|
+
global_clients = (@selected_clients || []).select { |key| MCP_CLIENTS[key][:path].nil? }
|
|
175
|
+
return if global_clients.empty?
|
|
176
|
+
|
|
177
|
+
say "\nManual configuration needed for:", :green
|
|
178
|
+
|
|
179
|
+
show_claude_desktop_instructions if global_clients.include?('claude_desktop')
|
|
180
|
+
|
|
181
|
+
return unless global_clients.include?('windsurf')
|
|
182
|
+
|
|
183
|
+
show_windsurf_instructions
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def show_claude_desktop_instructions
|
|
187
|
+
say "\n Claude Desktop:", :cyan
|
|
188
|
+
say ' Add this to your claude_desktop_config.json:', :yellow
|
|
66
189
|
say ' macOS: ~/.config/claude-desktop/claude_desktop_config.json', :yellow
|
|
67
190
|
say ' Windows: %APPDATA%\\Claude\\claude_desktop_config.json', :yellow
|
|
68
|
-
say ''
|
|
69
|
-
say "\
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
say
|
|
74
|
-
say '', :
|
|
75
|
-
say
|
|
76
|
-
say '
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
say
|
|
191
|
+
say ''
|
|
192
|
+
say " #{JSON.pretty_generate(build_mcp_config('mcpServers')).gsub("\n", "\n ")}", :cyan
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def show_windsurf_instructions
|
|
196
|
+
say "\n Windsurf:", :cyan
|
|
197
|
+
say ' Add this to ~/.codeium/windsurf/mcp_config.json:', :yellow
|
|
198
|
+
say ''
|
|
199
|
+
say " #{JSON.pretty_generate(build_mcp_config('mcpServers')).gsub("\n", "\n ")}", :cyan
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def show_available_tools
|
|
203
|
+
say "\nAvailable MCP Tools:", :green
|
|
204
|
+
say ' console_execute - Execute Ruby code with safety checks', :yellow
|
|
205
|
+
say ' model_info - Get detailed information about Rails models', :yellow
|
|
206
|
+
say ' safe_query - Execute safe read-only database queries', :yellow
|
|
207
|
+
say ' dry_run - Analyze Ruby code for safety without execution', :yellow
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def show_example_prompts
|
|
211
|
+
say "\nExample prompts:", :green
|
|
212
|
+
say ' "Show me the User model structure"', :yellow
|
|
213
|
+
say ' "How many users were created in the last week?"', :yellow
|
|
214
|
+
say ' "What are the most recent orders?"', :yellow
|
|
215
|
+
say ' "Check if this code is safe: User.delete_all"', :yellow
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def show_troubleshooting
|
|
81
219
|
say "\nTroubleshooting:", :green
|
|
82
|
-
say '
|
|
83
|
-
say '
|
|
84
|
-
say '- Restart Claude Desktop after config changes', :yellow
|
|
85
|
-
say '- If wrapper fails, try: bin/rails-active-mcp-server', :yellow
|
|
86
|
-
say '', :green
|
|
87
|
-
say "\nNext steps:", :green
|
|
88
|
-
say '1. Test installation: rails rails_active_mcp:test_tools', :yellow
|
|
89
|
-
say '2. Configure Claude Desktop (see above)', :yellow
|
|
90
|
-
say '3. Restart Claude Desktop', :yellow
|
|
91
|
-
say '4. Start chatting with your Rails app!', :yellow
|
|
92
|
-
say '=' * 50, :green
|
|
220
|
+
say ' Debug mode: RAILS_MCP_DEBUG=1 bin/rails-active-mcp-wrapper', :yellow
|
|
221
|
+
say ' If wrapper fails, try: bin/rails-active-mcp-server directly', :yellow
|
|
93
222
|
end
|
|
94
|
-
# rubocop:enable Metrics/AbcSize
|
|
95
223
|
|
|
96
|
-
|
|
224
|
+
def show_next_steps
|
|
225
|
+
say "\nNext steps:", :green
|
|
226
|
+
say ' 1. Test installation: rails rails_active_mcp:test_tools', :yellow
|
|
97
227
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if File.exist?(readme_path)
|
|
101
|
-
say File.read(readme_path), :green
|
|
228
|
+
if @selected_clients.blank?
|
|
229
|
+
say ' 2. Configure your MCP client (see README)', :yellow
|
|
102
230
|
else
|
|
103
|
-
|
|
231
|
+
global_clients = @selected_clients.select { |key| MCP_CLIENTS[key][:path].nil? }
|
|
232
|
+
if global_clients.any?
|
|
233
|
+
say ' 2. Add the config above to your global MCP client settings', :yellow
|
|
234
|
+
else
|
|
235
|
+
say ' 2. Open your project in your MCP client - it should auto-detect the server', :yellow
|
|
236
|
+
end
|
|
104
237
|
end
|
|
105
|
-
|
|
106
|
-
say
|
|
238
|
+
|
|
239
|
+
say ' 3. Start chatting with your Rails app!', :yellow
|
|
240
|
+
say('=' * 50, :green)
|
|
107
241
|
end
|
|
108
242
|
end
|
|
109
243
|
end
|
|
@@ -4,7 +4,7 @@ This Rails application is configured with Rails Active MCP for secure AI-powered
|
|
|
4
4
|
|
|
5
5
|
## What is Rails Active MCP?
|
|
6
6
|
|
|
7
|
-
Rails Active MCP enables secure Rails console access through Model Context Protocol (MCP) for AI agents and development tools
|
|
7
|
+
Rails Active MCP enables secure Rails console access through [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) for AI agents and development tools. It provides four main tools:
|
|
8
8
|
|
|
9
9
|
- **console_execute**: Execute Ruby/Rails code with safety checks
|
|
10
10
|
- **model_info**: Inspect Rails models (schema, associations, validations)
|
|
@@ -23,28 +23,19 @@ bin/rails-active-mcp-wrapper
|
|
|
23
23
|
RAILS_MCP_DEBUG=1 bin/rails-active-mcp-server
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
### 2.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
```
|
|
26
|
+
### 2. Connect Your MCP Client
|
|
27
|
+
|
|
28
|
+
If you selected MCP clients during installation, project-level config files were generated automatically. Open this project in your MCP client and the server should be detected.
|
|
29
|
+
|
|
30
|
+
For manual configuration, point your client at the server with:
|
|
31
|
+
|
|
32
|
+
- **Command:** `bin/rails-active-mcp-wrapper`
|
|
33
|
+
- **Working directory:** This project root
|
|
34
|
+
- **Transport:** STDIO
|
|
35
|
+
|
|
36
|
+
See the [full list of compatible MCP clients](https://modelcontextprotocol.io/clients).
|
|
46
37
|
|
|
47
|
-
### 3. Try These
|
|
38
|
+
### 3. Try These Prompts
|
|
48
39
|
|
|
49
40
|
- "Show me the User model structure"
|
|
50
41
|
- "How many users were created in the last week?"
|
|
@@ -79,7 +70,7 @@ config.allowed_models = %w[User Post Comment]
|
|
|
79
70
|
# Check code safety
|
|
80
71
|
rails rails_active_mcp:check_safety['User.count']
|
|
81
72
|
|
|
82
|
-
# Execute code with safety checks
|
|
73
|
+
# Execute code with safety checks
|
|
83
74
|
rails rails_active_mcp:execute['User.count']
|
|
84
75
|
|
|
85
76
|
# Test MCP tools
|
|
@@ -93,10 +84,10 @@ rails rails_active_mcp:test_tools
|
|
|
93
84
|
- Check Ruby version compatibility
|
|
94
85
|
- Verify all gems are installed: `bundle install`
|
|
95
86
|
|
|
96
|
-
###
|
|
97
|
-
- Restart
|
|
98
|
-
- Check logs: `~/Library/Logs/Claude/mcp*.log` (macOS)
|
|
87
|
+
### MCP Client Connection Issues
|
|
88
|
+
- Restart your MCP client after configuration changes
|
|
99
89
|
- Test server manually: `bin/rails-active-mcp-wrapper`
|
|
90
|
+
- Debug mode: `RAILS_MCP_DEBUG=1 bin/rails-active-mcp-server`
|
|
100
91
|
|
|
101
92
|
### Permission Errors
|
|
102
93
|
- Ensure wrapper script is executable: `chmod +x bin/rails-active-mcp-wrapper`
|
|
@@ -131,4 +122,4 @@ File.delete('file') # File operations
|
|
|
131
122
|
|
|
132
123
|
- **Documentation**: https://github.com/goodpie/rails-active-mcp
|
|
133
124
|
- **Issues**: https://github.com/goodpie/rails-active-mcp/issues
|
|
134
|
-
- **MCP Protocol**: https://modelcontextprotocol.io
|
|
125
|
+
- **MCP Protocol**: https://modelcontextprotocol.io
|
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.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brandyn Britton
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: concurrent-ruby
|