rails-mcp-server 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -2
- data/README.md +168 -166
- data/docs/AGENT.md +345 -0
- data/exe/rails-mcp-config +1411 -0
- data/exe/rails-mcp-server +23 -10
- data/exe/rails-mcp-setup-claude +1 -1
- data/lib/rails-mcp-server/analyzers/analyze_controller_views.rb +253 -0
- data/lib/rails-mcp-server/analyzers/analyze_environment_config.rb +79 -0
- data/lib/rails-mcp-server/analyzers/analyze_models.rb +251 -0
- data/lib/rails-mcp-server/analyzers/base_analyzer.rb +42 -0
- data/lib/rails-mcp-server/analyzers/get_file.rb +40 -0
- data/lib/rails-mcp-server/analyzers/get_routes.rb +212 -0
- data/lib/rails-mcp-server/analyzers/get_schema.rb +216 -0
- data/lib/rails-mcp-server/analyzers/list_files.rb +43 -0
- data/lib/rails-mcp-server/analyzers/load_guide.rb +84 -0
- data/lib/rails-mcp-server/analyzers/project_info.rb +136 -0
- data/lib/rails-mcp-server/tools/base_tool.rb +2 -0
- data/lib/rails-mcp-server/tools/execute_ruby.rb +409 -0
- data/lib/rails-mcp-server/tools/execute_tool.rb +115 -0
- data/lib/rails-mcp-server/tools/search_tools.rb +186 -0
- data/lib/rails-mcp-server/tools/switch_project.rb +16 -1
- data/lib/rails-mcp-server/version.rb +1 -1
- data/lib/rails_mcp_server.rb +19 -53
- metadata +68 -21
- data/lib/rails-mcp-server/extensions/resource_templating.rb +0 -182
- data/lib/rails-mcp-server/extensions/server_templating.rb +0 -333
- data/lib/rails-mcp-server/tools/analyze_controller_views.rb +0 -239
- data/lib/rails-mcp-server/tools/analyze_environment_config.rb +0 -427
- data/lib/rails-mcp-server/tools/analyze_models.rb +0 -116
- data/lib/rails-mcp-server/tools/get_file.rb +0 -55
- data/lib/rails-mcp-server/tools/get_routes.rb +0 -24
- data/lib/rails-mcp-server/tools/get_schema.rb +0 -141
- data/lib/rails-mcp-server/tools/list_files.rb +0 -54
- data/lib/rails-mcp-server/tools/load_guide.rb +0 -370
- data/lib/rails-mcp-server/tools/project_info.rb +0 -86
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25c3767eb1c84eb4ac69450ab2118659b7b8eeca87722bfb3456be06543182b6
|
|
4
|
+
data.tar.gz: e0c62dcc4abba55695290ba082007f0ea6b5bd19dae7bf257f51f4d426a51de5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0677e15106d3574a9f061022aa4f37977a1d3e79166d54b59293127ae84f806d8f4f19d03384924072b455c1787bb68016d8cdc486ca6e5a0f7822848766403b
|
|
7
|
+
data.tar.gz: d13b1175daf7fc56b1d245994d2ed741d33fd6f073acabbd899a89cd3608d23782c5fe9e671716087ae81b52b33090791dc8fcc0a1aab68432442cc434e02148
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.3] - 2025-12-10
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Setup Script Compatibility**: Fixed `rails-mcp-setup-claude` failing on readonly filesystems (thanks to @emptyflask)
|
|
13
|
+
- Only runs `chmod` when the file is not already executable
|
|
14
|
+
- Resolves issues on NixOS and similar platforms with readonly filesystems
|
|
15
|
+
- Fixes failures when the current user is not the owner of the executable
|
|
16
|
+
|
|
8
17
|
## [1.2.2] - 2025-07-21
|
|
9
18
|
|
|
10
19
|
### Added
|
|
@@ -192,6 +201,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
192
201
|
|
|
193
202
|
## Version History Summary
|
|
194
203
|
|
|
204
|
+
- **v1.2.3** (2025-12-10): Setup script fix for readonly filesystems (NixOS compatibility)
|
|
195
205
|
- **v1.2.2** (2025-07-21): Network access support with --bind-all flag
|
|
196
206
|
- **v1.2.1** (2025-06-09): Bug fixes for STDIO output and tool naming
|
|
197
207
|
- **v1.2.0** (2025-06-03): Major documentation and resource system addition
|
|
@@ -214,9 +224,9 @@ This project follows [Semantic Versioning](https://semver.org/):
|
|
|
214
224
|
1. Update version in `lib/rails-mcp-server/version.rb`
|
|
215
225
|
2. Update this CHANGELOG.md with new features and changes
|
|
216
226
|
3. Update README.md and documentation if needed
|
|
217
|
-
4. Create a git tag: `git tag -a v1.2.
|
|
227
|
+
4. Create a git tag: `git tag -a v1.2.3 -m "Release version 1.2.3"`
|
|
218
228
|
5. Push tags: `git push origin --tags`
|
|
219
|
-
6. Build and publish gem: `gem build rails-mcp-server.gemspec && gem push rails-mcp-server-1.2.
|
|
229
|
+
6. Build and publish gem: `gem build rails-mcp-server.gemspec && gem push rails-mcp-server-1.2.3.gem`
|
|
220
230
|
|
|
221
231
|
### Changelog Categories
|
|
222
232
|
|
data/README.md
CHANGED
|
@@ -12,13 +12,14 @@ This Rails MCP Server implements the MCP specification to give AI models access
|
|
|
12
12
|
|
|
13
13
|
- Manage multiple Rails projects
|
|
14
14
|
- Browse project files and structures
|
|
15
|
-
- View Rails routes
|
|
16
|
-
- Inspect model information and relationships
|
|
15
|
+
- View Rails routes with filtering options
|
|
16
|
+
- Inspect model information and relationships (with Prism static analysis)
|
|
17
17
|
- Get database schema information
|
|
18
18
|
- Analyze controller-view relationships
|
|
19
19
|
- Analyze environment configurations
|
|
20
|
+
- Execute sandboxed Ruby code for custom queries
|
|
20
21
|
- Access comprehensive Rails, Turbo, Stimulus, and Kamal documentation
|
|
21
|
-
-
|
|
22
|
+
- Context-efficient architecture with progressive tool discovery
|
|
22
23
|
- Seamless integration with LLM clients
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
@@ -29,10 +30,41 @@ Install the gem:
|
|
|
29
30
|
gem install rails-mcp-server
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
After installation, the
|
|
33
|
+
After installation, the following executables will be available in your PATH:
|
|
34
|
+
|
|
35
|
+
- `rails-mcp-server` - The MCP server itself
|
|
36
|
+
- `rails-mcp-config` - Interactive configuration tool (recommended)
|
|
37
|
+
- `rails-mcp-setup-claude` - Legacy Claude Desktop setup script
|
|
38
|
+
- `rails-mcp-server-download-resources` - Legacy resource download script
|
|
33
39
|
|
|
34
40
|
## Configuration
|
|
35
41
|
|
|
42
|
+
### Using the Configuration Tool (Recommended)
|
|
43
|
+
|
|
44
|
+
The easiest way to configure the Rails MCP Server is using the interactive configuration tool:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
rails-mcp-config
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This provides a user-friendly TUI (Terminal User Interface) for:
|
|
51
|
+
|
|
52
|
+
- **Managing Projects**: Add, edit, remove, and validate Rails projects
|
|
53
|
+
- **Downloading Guides**: Download Rails, Turbo, Stimulus, and Kamal documentation
|
|
54
|
+
- **Importing Custom Guides**: Add your own markdown documentation
|
|
55
|
+
- **Claude Desktop Integration**: Automatically configure Claude Desktop
|
|
56
|
+
|
|
57
|
+
The tool uses [Gum](https://github.com/charmbracelet/gum) for an enhanced experience if installed, but works with a basic terminal fallback.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Install Gum for best experience (optional)
|
|
61
|
+
brew install gum # macOS
|
|
62
|
+
sudo apt install gum # Debian/Ubuntu
|
|
63
|
+
yay -S gum # Arch Linux
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Manual Configuration
|
|
67
|
+
|
|
36
68
|
The Rails MCP Server follows the XDG Base Directory Specification for configuration files:
|
|
37
69
|
|
|
38
70
|
- On macOS: `$XDG_CONFIG_HOME/rails-mcp` or `~/.config/rails-mcp` if XDG_CONFIG_HOME is not set
|
|
@@ -40,7 +72,7 @@ The Rails MCP Server follows the XDG Base Directory Specification for configurat
|
|
|
40
72
|
|
|
41
73
|
The server will automatically create these directories and an empty `projects.yml` file the first time it runs.
|
|
42
74
|
|
|
43
|
-
To configure your projects:
|
|
75
|
+
To configure your projects manually:
|
|
44
76
|
|
|
45
77
|
1. Edit the `projects.yml` file in your config directory to include your Rails projects:
|
|
46
78
|
|
|
@@ -112,11 +144,27 @@ rails-mcp-server --log-level debug
|
|
|
112
144
|
|
|
113
145
|
## Claude Desktop Integration
|
|
114
146
|
|
|
115
|
-
The Rails MCP Server can be used with Claude Desktop. There are
|
|
147
|
+
The Rails MCP Server can be used with Claude Desktop. There are multiple options to set this up:
|
|
148
|
+
|
|
149
|
+
### Option 1: Use the configuration tool (recommended)
|
|
116
150
|
|
|
117
|
-
|
|
151
|
+
Run the interactive configuration tool and select "Claude Desktop integration":
|
|
118
152
|
|
|
119
|
-
|
|
153
|
+
```bash
|
|
154
|
+
rails-mcp-config
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The tool will:
|
|
158
|
+
|
|
159
|
+
- Detect your current Claude Desktop configuration
|
|
160
|
+
- Let you choose between STDIO or HTTP mode
|
|
161
|
+
- Automatically find the correct Ruby and server paths
|
|
162
|
+
- Create a backup before making changes
|
|
163
|
+
- Update the Claude Desktop configuration
|
|
164
|
+
|
|
165
|
+
### Option 2: Use the setup script (legacy)
|
|
166
|
+
|
|
167
|
+
Run the setup script which will automatically configure Claude Desktop:
|
|
120
168
|
|
|
121
169
|
```bash
|
|
122
170
|
rails-mcp-setup-claude
|
|
@@ -130,7 +178,7 @@ The script will:
|
|
|
130
178
|
|
|
131
179
|
After running the script, restart Claude Desktop to apply the changes.
|
|
132
180
|
|
|
133
|
-
### Option
|
|
181
|
+
### Option 3: Direct Configuration
|
|
134
182
|
|
|
135
183
|
1. Create the appropriate config directory for your platform:
|
|
136
184
|
- macOS: `$XDG_CONFIG_HOME/rails-mcp` or `~/.config/rails-mcp` if XDG_CONFIG_HOME is not set
|
|
@@ -176,6 +224,8 @@ If you are using a Ruby version manager such as rbenv, you can use the Ruby shim
|
|
|
176
224
|
|
|
177
225
|
Replace "/home/your_user/.rbenv/shims/ruby" with your actual path for the Ruby shim.
|
|
178
226
|
|
|
227
|
+
**Tip**: The `rails-mcp-config` tool automatically detects your Ruby path and uses the correct shim path when configuring Claude Desktop.
|
|
228
|
+
|
|
179
229
|
### Using an MCP Proxy (Advanced)
|
|
180
230
|
|
|
181
231
|
Claude Desktop and many other LLM clients only support STDIO mode communication, but you might want to use the HTTP/SSE capabilities of the server. An MCP proxy can bridge this gap:
|
|
@@ -211,6 +261,8 @@ npx mcp-remote http://localhost:6029/mcp/sse
|
|
|
211
261
|
|
|
212
262
|
This setup allows STDIO-only clients to communicate with the Rails MCP Server through the proxy, benefiting from the HTTP/SSE capabilities while maintaining client compatibility.
|
|
213
263
|
|
|
264
|
+
**Tip**: The `rails-mcp-config` tool can configure HTTP mode with mcp-remote automatically.
|
|
265
|
+
|
|
214
266
|
## How the Server Works
|
|
215
267
|
|
|
216
268
|
The Rails MCP Server implements the Model Context Protocol using either:
|
|
@@ -220,240 +272,175 @@ The Rails MCP Server implements the Model Context Protocol using either:
|
|
|
220
272
|
|
|
221
273
|
Each request includes a sequence number to match requests with responses, as defined in the MCP specification. The server maintains project context and provides Rails-specific analysis capabilities across multiple codebases.
|
|
222
274
|
|
|
223
|
-
|
|
275
|
+
### Context-Efficient Architecture
|
|
224
276
|
|
|
225
|
-
The server provides
|
|
277
|
+
The server uses a progressive tool discovery architecture to minimize context usage. Instead of exposing all tools upfront, it provides 4 bootstrap tools that allow LLMs to discover and invoke additional analyzers on-demand:
|
|
226
278
|
|
|
227
|
-
|
|
279
|
+
- **`switch_project`** - Select the active Rails project
|
|
280
|
+
- **`search_tools`** - Discover available tools by category or keyword
|
|
281
|
+
- **`execute_tool`** - Invoke internal analyzers with parameters
|
|
282
|
+
- **`execute_ruby`** - Run sandboxed Ruby code for custom queries
|
|
228
283
|
|
|
229
|
-
|
|
284
|
+
This design reduces initial context from ~2,400 tokens to ~800 tokens while maintaining full functionality.
|
|
230
285
|
|
|
231
|
-
|
|
286
|
+
## AI Agent Guide
|
|
232
287
|
|
|
233
|
-
|
|
288
|
+
For AI agents (Claude, GPT, etc.) using this server, see the comprehensive **[AI Agent Guide](docs/AGENT.md)** which covers:
|
|
234
289
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
290
|
+
- Quick start workflow
|
|
291
|
+
- Tool selection guide for common tasks
|
|
292
|
+
- Helper methods available in `execute_ruby`
|
|
293
|
+
- Common pitfalls and how to avoid them
|
|
294
|
+
- Error handling and fallback strategies
|
|
295
|
+
- Integration with other MCP servers (e.g., Neovim MCP)
|
|
240
296
|
|
|
241
|
-
|
|
242
|
-
I'd like to analyze my "blog" application. Please switch to that project first.
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
```
|
|
246
|
-
Switch to the "ecommerce" project and give me a summary of the codebase.
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### 2. `project_info`
|
|
250
|
-
|
|
251
|
-
**Description:** Retrieve comprehensive information about the current Rails project, including Rails version, directory structure, API-only status, and overall project organization. Useful for initial project exploration and understanding the codebase structure.
|
|
297
|
+
## Available Tools
|
|
252
298
|
|
|
253
|
-
|
|
299
|
+
The server provides 4 registered tools plus internal analyzers accessible via `execute_tool`.
|
|
254
300
|
|
|
255
|
-
|
|
301
|
+
### Registered Tools
|
|
256
302
|
|
|
257
|
-
|
|
258
|
-
Now that we're in the blog project, can you give me an overview of the project structure and Rails version?
|
|
259
|
-
```
|
|
303
|
+
#### 1. `switch_project`
|
|
260
304
|
|
|
261
|
-
|
|
262
|
-
Tell me about this Rails application. What version is it running and how is it organized?
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
```
|
|
266
|
-
I'd like to understand the high-level architecture of this project. Can you provide the project information?
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### 3. `list_files`
|
|
270
|
-
|
|
271
|
-
**Description:** List files in the Rails project matching specific criteria. Use this to explore project directories or locate specific file types. If no parameters are provided, lists files in the project root.
|
|
305
|
+
**Description:** Change the active Rails project. Must be called before using other tools.
|
|
272
306
|
|
|
273
307
|
**Parameters:**
|
|
274
308
|
|
|
275
|
-
- `
|
|
276
|
-
- `pattern`: (String, optional) File pattern using glob syntax (e.g., '*.rb' for Ruby files, '*.erb' for ERB templates, '*_controller.rb' for controllers)
|
|
309
|
+
- `project_name`: (String, required) Name of the project as defined in projects.yml
|
|
277
310
|
|
|
278
|
-
|
|
311
|
+
After switching, you'll see a Quick Start guide with common commands.
|
|
279
312
|
|
|
280
|
-
|
|
281
|
-
Can you list all the model files in this project?
|
|
282
|
-
```
|
|
313
|
+
#### 2. `search_tools`
|
|
283
314
|
|
|
284
|
-
|
|
285
|
-
Show me all the controller files in the app/controllers directory.
|
|
286
|
-
```
|
|
315
|
+
**Description:** Discover available tools by category or keyword.
|
|
287
316
|
|
|
288
|
-
|
|
289
|
-
I need to see all the view templates in the users section. Can you list the files in app/views/users?
|
|
290
|
-
```
|
|
317
|
+
**Parameters:**
|
|
291
318
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
319
|
+
- `query`: (String, optional) Search term (e.g., 'routes', 'model', 'schema')
|
|
320
|
+
- `category`: (String, optional) Filter by category: models, database, routing, controllers, files, project, guides
|
|
321
|
+
- `detail_level`: (String, optional) Output detail: 'names', 'summary', or 'full' (default: 'summary')
|
|
295
322
|
|
|
296
|
-
|
|
323
|
+
#### 3. `execute_tool`
|
|
297
324
|
|
|
298
|
-
**Description:**
|
|
325
|
+
**Description:** Invoke internal analyzers by name.
|
|
299
326
|
|
|
300
327
|
**Parameters:**
|
|
301
328
|
|
|
302
|
-
- `
|
|
329
|
+
- `tool_name`: (String, required) Name of the analyzer (e.g., 'get_routes', 'analyze_models')
|
|
330
|
+
- `params`: (Hash, optional) Parameters for the analyzer
|
|
303
331
|
|
|
304
|
-
####
|
|
332
|
+
#### 4. `execute_ruby`
|
|
305
333
|
|
|
306
|
-
|
|
307
|
-
Can you show me the content of the User model file?
|
|
308
|
-
```
|
|
334
|
+
**Description:** Execute sandboxed Ruby code in the Rails project context.
|
|
309
335
|
|
|
310
|
-
|
|
311
|
-
I need to see what's in app/controllers/products_controller.rb. Can you retrieve that file?
|
|
312
|
-
```
|
|
336
|
+
**Parameters:**
|
|
313
337
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
```
|
|
338
|
+
- `code`: (String, required) Ruby code to execute
|
|
339
|
+
- `timeout`: (Integer, optional) Timeout in seconds (default: 30, max: 60)
|
|
317
340
|
|
|
318
|
-
|
|
319
|
-
I'd like to examine the routes file. Can you display the content of config/routes.rb?
|
|
320
|
-
```
|
|
341
|
+
**Available helper methods:**
|
|
321
342
|
|
|
322
|
-
|
|
343
|
+
- `read_file(path)` - Read a file safely
|
|
344
|
+
- `file_exists?(path)` - Check if a file exists
|
|
345
|
+
- `list_files(pattern)` - Glob files (e.g., `'app/models/**/*.rb'`)
|
|
346
|
+
- `project_root` - Get the project root path
|
|
323
347
|
|
|
324
|
-
**
|
|
348
|
+
**Note:** Use `puts` to see output from your code.
|
|
325
349
|
|
|
326
|
-
**
|
|
350
|
+
**Security:** The sandbox prevents file writes, system calls, network access, and reading sensitive files (.env, credentials, etc.).
|
|
327
351
|
|
|
328
|
-
|
|
352
|
+
### Internal Analyzers (via execute_tool)
|
|
329
353
|
|
|
330
|
-
|
|
331
|
-
Can you show me all the routes defined in this application?
|
|
332
|
-
```
|
|
354
|
+
#### `project_info`
|
|
333
355
|
|
|
334
|
-
|
|
335
|
-
I need to understand the API endpoints available in this project. Can you list the routes?
|
|
336
|
-
```
|
|
356
|
+
Retrieve comprehensive project information including Rails version, directory structure, and organization.
|
|
337
357
|
|
|
338
358
|
```
|
|
339
|
-
|
|
359
|
+
execute_tool(tool_name: "project_info")
|
|
340
360
|
```
|
|
341
361
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
**Description:** Retrieve detailed information about Active Record models in the project. When called without parameters, lists all model files. When a specific model is specified, returns its schema, associations (has_many, belongs_to, has_one), and complete source code.
|
|
345
|
-
|
|
346
|
-
**Parameters:**
|
|
347
|
-
|
|
348
|
-
- `model_name`: (String, optional) Class name of a specific model to get detailed information for (e.g., 'User', 'Product'). Use CamelCase, not snake_case. If omitted, returns a list of all models.
|
|
362
|
+
#### `list_files`
|
|
349
363
|
|
|
350
|
-
|
|
364
|
+
List files matching a pattern in a directory.
|
|
351
365
|
|
|
352
366
|
```
|
|
353
|
-
|
|
367
|
+
execute_tool(tool_name: "list_files", params: { directory: "app/models", pattern: "*.rb" })
|
|
354
368
|
```
|
|
355
369
|
|
|
356
|
-
|
|
357
|
-
I'd like to understand the User model in detail. Can you show me its schema, associations, and code?
|
|
358
|
-
```
|
|
370
|
+
#### `get_file`
|
|
359
371
|
|
|
360
|
-
|
|
361
|
-
Show me the Product model's definition, including its relationships with other models.
|
|
362
|
-
```
|
|
372
|
+
Retrieve the content of a specific file.
|
|
363
373
|
|
|
364
374
|
```
|
|
365
|
-
|
|
375
|
+
execute_tool(tool_name: "get_file", params: { path: "app/models/user.rb" })
|
|
366
376
|
```
|
|
367
377
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
**Description:** Retrieve database schema information for the Rails application. Without parameters, returns all tables and the complete schema.rb. With a table name, returns detailed column information including data types, constraints, and foreign keys for that specific table.
|
|
378
|
+
#### `get_routes`
|
|
371
379
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
- `table_name`: (String, optional) Database table name to get detailed schema information for (e.g., 'users', 'products'). Use snake_case, plural form. If omitted, returns complete database schema.
|
|
375
|
-
|
|
376
|
-
#### Examples
|
|
380
|
+
Retrieve Rails routes with optional filtering.
|
|
377
381
|
|
|
378
382
|
```
|
|
379
|
-
|
|
383
|
+
execute_tool(tool_name: "get_routes")
|
|
384
|
+
execute_tool(tool_name: "get_routes", params: { controller: "users" })
|
|
385
|
+
execute_tool(tool_name: "get_routes", params: { verb: "POST" })
|
|
386
|
+
execute_tool(tool_name: "get_routes", params: { path_contains: "api" })
|
|
380
387
|
```
|
|
381
388
|
|
|
382
|
-
|
|
383
|
-
I'd like to see the structure of the users table. Can you retrieve that schema information?
|
|
384
|
-
```
|
|
389
|
+
#### `analyze_models`
|
|
385
390
|
|
|
386
|
-
|
|
387
|
-
Show me the columns and their data types in the products table.
|
|
388
|
-
```
|
|
391
|
+
Analyze Active Record models with associations, validations, and optional Prism static analysis.
|
|
389
392
|
|
|
390
393
|
```
|
|
391
|
-
|
|
394
|
+
execute_tool(tool_name: "analyze_models")
|
|
395
|
+
execute_tool(tool_name: "analyze_models", params: { model_name: "User" })
|
|
396
|
+
execute_tool(tool_name: "analyze_models", params: { model_name: "User", analysis_type: "full" })
|
|
397
|
+
execute_tool(tool_name: "analyze_models", params: { detail_level: "names" })
|
|
392
398
|
```
|
|
393
399
|
|
|
394
|
-
### 8. `analyze_controller_views`
|
|
395
|
-
|
|
396
|
-
**Description:** Analyze the relationships between controllers, their actions, and corresponding views to understand the application's UI flow.
|
|
397
|
-
|
|
398
400
|
**Parameters:**
|
|
399
401
|
|
|
400
|
-
- `
|
|
402
|
+
- `model_name`: Specific model to analyze
|
|
403
|
+
- `model_names`: Array of models to analyze
|
|
404
|
+
- `detail_level`: 'names', 'summary', or 'full'
|
|
405
|
+
- `analysis_type`: 'introspection', 'static', or 'full' (includes Prism AST analysis)
|
|
401
406
|
|
|
402
|
-
####
|
|
407
|
+
#### `get_schema`
|
|
403
408
|
|
|
404
|
-
|
|
405
|
-
Can you analyze the Users controller and its views to help me understand the UI flow?
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
```
|
|
409
|
-
Show me how the ProductsController connects to its views and what actions are available.
|
|
410
|
-
```
|
|
409
|
+
Retrieve database schema information.
|
|
411
410
|
|
|
412
411
|
```
|
|
413
|
-
|
|
412
|
+
execute_tool(tool_name: "get_schema")
|
|
413
|
+
execute_tool(tool_name: "get_schema", params: { table_name: "users" })
|
|
414
|
+
execute_tool(tool_name: "get_schema", params: { detail_level: "tables" })
|
|
414
415
|
```
|
|
415
416
|
|
|
416
|
-
|
|
417
|
+
#### `analyze_controller_views`
|
|
417
418
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
**Parameters:** None
|
|
421
|
-
|
|
422
|
-
#### Examples
|
|
419
|
+
Analyze controller-view relationships with optional Prism static analysis.
|
|
423
420
|
|
|
424
421
|
```
|
|
425
|
-
|
|
422
|
+
execute_tool(tool_name: "analyze_controller_views")
|
|
423
|
+
execute_tool(tool_name: "analyze_controller_views", params: { controller_name: "users" })
|
|
424
|
+
execute_tool(tool_name: "analyze_controller_views", params: { controller_name: "users", analysis_type: "full" })
|
|
426
425
|
```
|
|
427
426
|
|
|
428
|
-
|
|
429
|
-
Check the configuration files for any inconsistencies between development and production environments.
|
|
430
|
-
```
|
|
427
|
+
#### `analyze_environment_config`
|
|
431
428
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
**Description:** Load documentation guides from Rails, Turbo, Stimulus, Kamal, or Custom. Use this to get guide content for context in conversations.
|
|
435
|
-
|
|
436
|
-
**Parameters:**
|
|
437
|
-
|
|
438
|
-
- `guides`: (String, required) The guides library to search: 'rails', 'turbo', 'stimulus', 'kamal', or 'custom'
|
|
439
|
-
- `guide`: (String, optional) Specific guide name to load. If not provided, returns available guides list.
|
|
440
|
-
|
|
441
|
-
#### Examples
|
|
429
|
+
Analyze environment configurations for inconsistencies and security issues.
|
|
442
430
|
|
|
443
431
|
```
|
|
444
|
-
|
|
432
|
+
execute_tool(tool_name: "analyze_environment_config")
|
|
445
433
|
```
|
|
446
434
|
|
|
447
|
-
|
|
448
|
-
Show me the available Turbo guides and then load the one about Turbo Frames.
|
|
449
|
-
```
|
|
435
|
+
#### `load_guide`
|
|
450
436
|
|
|
451
|
-
|
|
452
|
-
I need help with Stimulus. Can you load the hello_stimulus guide?
|
|
453
|
-
```
|
|
437
|
+
Load documentation guides from Rails, Turbo, Stimulus, Kamal, or Custom.
|
|
454
438
|
|
|
455
439
|
```
|
|
456
|
-
|
|
440
|
+
execute_tool(tool_name: "load_guide", params: { guides: "rails" })
|
|
441
|
+
execute_tool(tool_name: "load_guide", params: { guides: "rails", guide: "getting_started" })
|
|
442
|
+
execute_tool(tool_name: "load_guide", params: { guides: "turbo" })
|
|
443
|
+
execute_tool(tool_name: "load_guide", params: { guides: "stimulus" })
|
|
457
444
|
```
|
|
458
445
|
|
|
459
446
|
## Resources and Documentation
|
|
@@ -470,7 +457,15 @@ The Rails MCP Server provides access to comprehensive documentation through both
|
|
|
470
457
|
|
|
471
458
|
### Getting Started with Resources
|
|
472
459
|
|
|
473
|
-
|
|
460
|
+
The easiest way to manage resources is using the configuration tool:
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
rails-mcp-config
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Then select "Download guides" or "Import custom guides" from the menu.
|
|
467
|
+
|
|
468
|
+
Alternatively, you can use the legacy command-line tools:
|
|
474
469
|
|
|
475
470
|
```bash
|
|
476
471
|
# Download Rails guides
|
|
@@ -497,7 +492,7 @@ The easiest way to test and debug the Rails MCP Server is by using the MCP Inspe
|
|
|
497
492
|
To use MCP Inspector with Rails MCP Server:
|
|
498
493
|
|
|
499
494
|
```bash
|
|
500
|
-
# Install and run MCP Inspector
|
|
495
|
+
# Install and run MCP Inspector
|
|
501
496
|
npm -g install @modelcontextprotocol/inspector
|
|
502
497
|
|
|
503
498
|
npx @modelcontextprotocol/inspector /path/to/rails-mcp-server
|
|
@@ -511,13 +506,20 @@ This will:
|
|
|
511
506
|
|
|
512
507
|
In the MCP Inspector UI, you can:
|
|
513
508
|
|
|
514
|
-
- See all available tools
|
|
509
|
+
- See all available tools (you should see 4 registered tools)
|
|
515
510
|
- Execute tool calls interactively
|
|
516
511
|
- View request and response details
|
|
517
512
|
- Debug issues in real-time
|
|
518
513
|
|
|
519
514
|
The Inspector UI provides an intuitive interface to interact with your MCP server, making it easy to test and debug your Rails MCP Server implementation.
|
|
520
515
|
|
|
516
|
+
### Testing Workflow
|
|
517
|
+
|
|
518
|
+
1. **Switch to a project:** `switch_project` with your project name
|
|
519
|
+
2. **Discover tools:** `search_tools` to see available analyzers
|
|
520
|
+
3. **Test analyzers:** `execute_tool` to invoke specific analyzers
|
|
521
|
+
4. **Test Ruby execution:** `execute_ruby` with code like `puts read_file('Gemfile')`
|
|
522
|
+
|
|
521
523
|
## Integration with LLM Clients
|
|
522
524
|
|
|
523
525
|
This server is designed to be integrated with LLM clients that support the Model Context Protocol, such as Claude Desktop or other MCP-compatible applications.
|