rails-mcp-server 1.4.1 → 1.5.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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/README.md +82 -4
  4. data/docs/{AGENT.md → AGENT.md} +84 -5
  5. data/docs/COPILOT_AGENT.md +261 -0
  6. data/docs/RESOURCES.md +2 -2
  7. data/exe/rails-mcp-config +19 -1
  8. data/exe/rails-mcp-server +5 -0
  9. data/lib/rails-mcp-server/analyzers/analyze_controller_views.rb +12 -5
  10. data/lib/rails-mcp-server/analyzers/analyze_environment_config.rb +1 -1
  11. data/lib/rails-mcp-server/analyzers/analyze_models.rb +17 -8
  12. data/lib/rails-mcp-server/analyzers/base_analyzer.rb +16 -6
  13. data/lib/rails-mcp-server/analyzers/get_file.rb +16 -4
  14. data/lib/rails-mcp-server/analyzers/get_routes.rb +3 -2
  15. data/lib/rails-mcp-server/analyzers/get_schema.rb +101 -43
  16. data/lib/rails-mcp-server/analyzers/list_files.rb +56 -14
  17. data/lib/rails-mcp-server/analyzers/load_guide.rb +25 -7
  18. data/lib/rails-mcp-server/config.rb +87 -2
  19. data/lib/rails-mcp-server/helpers/resource_base.rb +48 -9
  20. data/lib/rails-mcp-server/helpers/resource_downloader.rb +2 -2
  21. data/lib/rails-mcp-server/resources/guide_content_formatter.rb +1 -1
  22. data/lib/rails-mcp-server/resources/guide_error_handler.rb +2 -2
  23. data/lib/rails-mcp-server/resources/guide_loader_template.rb +1 -1
  24. data/lib/rails-mcp-server/resources/guide_manifest_operations.rb +1 -1
  25. data/lib/rails-mcp-server/tools/execute_tool.rb +9 -3
  26. data/lib/rails-mcp-server/tools/get_model.rb +18 -13
  27. data/lib/rails-mcp-server/tools/search_tools.rb +4 -4
  28. data/lib/rails-mcp-server/tools/switch_project.rb +10 -1
  29. data/lib/rails-mcp-server/utilities/path_validator.rb +100 -0
  30. data/lib/rails-mcp-server/utilities/run_process.rb +25 -15
  31. data/lib/rails-mcp-server/version.rb +1 -1
  32. data/lib/rails_mcp_server.rb +1 -0
  33. metadata +33 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65769f824f1dbb5bfe856a40f0a46aed59d4591b3e2d23c486b6f6a08687075c
4
- data.tar.gz: 596d5a5bd1d22559a0d4d9ea1369b1c375546ce790a3c71edc378c053c75b433
3
+ metadata.gz: 26aa11dc067437b85e216c16112efaba559848364c024682704672ec48c63cab
4
+ data.tar.gz: 59b0ea4590b1528ddc0eeaa94e6a876c8446a239033966ccaff5b474eda7f252
5
5
  SHA512:
6
- metadata.gz: 4c51f927f27949ec313ce1762911676f338553513189f030fc610847ced95d0b1f31d8badcfafe6d89d077e15fde6b6ec2d4e9a4417afd2aaeccd3275b46c170
7
- data.tar.gz: 5d290f823f45a04ef7a4e0fed4a2ec2820e6be1c086af40441dc33cba7423ac2698e58b300febe2f8cd7accbdf49e7f5663dbd38f2e4a8162d6c30b326849cc2
6
+ metadata.gz: eb371f905fba252428f9c2557b4cd74991c81da2f22a089f1fa54ce1ff20db53bec3177264a20dc9955f0b19790a1015b5d36f7d69c1f6556ee55faa1908606f
7
+ data.tar.gz: b78991e7abf1c45b15e342be60dd1f533dc7e68d1129c356940bf9088df4d2e4f66607d05e3b82b50cd83dc902eb33340723538e89aab351c0ebc80c43246deb
data/CHANGELOG.md CHANGED
@@ -5,6 +5,60 @@ 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.5.0] - 2025-12-19
9
+
10
+ ### Added
11
+
12
+ - **GitHub Copilot Agent Support**: Full compatibility with GitHub Copilot coding agent
13
+ - New `--single-project` flag to use current directory as the only project
14
+ - New `RAILS_MCP_PROJECT_PATH` environment variable for explicit project path configuration
15
+ - Auto-detection of Rails applications from Gemfile (`gem "rails"`)
16
+ - Auto-detection of Rails engines from gemspec files (dependencies on `rails`, `railties`, `actionpack`, `activerecord`, etc.)
17
+ - Auto-switch to single project when only one project is configured in `projects.yml`
18
+ - **Documentation**: New `docs/COPILOT_AGENT.md` with comprehensive setup guide for GitHub Copilot Agent
19
+
20
+ ### Changed
21
+
22
+ - **Project Detection Priority**: Projects are now detected in this order:
23
+ 1. `RAILS_MCP_PROJECT_PATH` environment variable (highest priority)
24
+ 2. Auto-detection of Rails application from Gemfile in current directory
25
+ 3. Auto-detection of Rails engine from gemspec in current directory
26
+ 4. `projects.yml` configuration file (existing behavior)
27
+ - **Error Messages**: Improved error message when no projects found to suggest running from a Rails directory
28
+ - **load_guide Parameter Rename**: Renamed `guides` parameter to `library` for clarity
29
+ - Old: `execute_tool("load_guide", { guides: "rails", guide: "active_record" })`
30
+ - New: `execute_tool("load_guide", { library: "rails", guide: "active_record" })`
31
+ - The `library` parameter specifies the guide source: 'rails', 'turbo', 'stimulus', 'kamal', or 'custom'
32
+
33
+ ### Fixed
34
+
35
+ - **execute_tool params schema**: Added `.hash` type to `params` argument so it appears in the JSON schema sent to MCP clients. Previously, tools requiring parameters (like `load_guide` with `library`) could not receive them because the `params` field was missing from the schema.
36
+ - **Test suite stability**: Fixed ConfigTest teardown to restore a fresh Config instance instead of setting it to nil, which was causing subsequent tests to fail with `NoMethodError: undefined method 'current_project=' for nil`
37
+ - **Rails 8.1.1 compatibility**: Fixed `analyze_controller_views` callback introspection that failed with "undefined method 'options'" error. Now uses `respond_to?(:options)` to maintain backward compatibility with both Rails 8.1+ and earlier versions.
38
+ - **load_guide input validation**: Added validation to prevent path traversal and special characters in guide names. Guide names must now use only letters, numbers, underscores, hyphens, or forward slashes.
39
+ - **Improved error messages**: Better error messages for unknown tools, missing models, and missing tables with helpful tips (e.g., use CamelCase for models, snake_case plural for tables)
40
+
41
+ ### Security
42
+
43
+ - **Input validation hardening** (PR #25): Comprehensive security audit addressing CodeQL findings
44
+ - New `PathValidator` module centralizing all input sanitization
45
+ - Path traversal prevention: validates paths stay within project root
46
+ - Sensitive file protection: blocks access to `master.key`, `credentials.yml.enc`, `.env` files, `database.yml`
47
+ - Shell injection prevention: uses `IO.popen` with array arguments instead of shell interpolation
48
+ - SQL/code injection prevention in `get_schema`: strict alphanumeric validation for table names
49
+ - ReDoS fixes: replaced vulnerable regex patterns with linear-time string operations
50
+ - Safe YAML loading: replaced `YAML.load_file` with `YAML.safe_load_file` to prevent arbitrary object deserialization
51
+ - **CI Security Infrastructure**:
52
+ - Dependabot for automated dependency updates
53
+ - CodeQL static analysis for vulnerability detection
54
+ - OpenSSF Scorecard for security best practices tracking
55
+ - SECURITY.md vulnerability disclosure policy
56
+
57
+ ### Technical
58
+
59
+ - **Rails runner improvements**: Better handling of log pollution in JSON output, rbenv version selection from project's `.ruby-version`
60
+ - **Test coverage**: 27 new tests for PathValidator security validations
61
+
8
62
  ## [1.4.1] - 2025-12-11
9
63
 
10
64
  ### Fixed
data/README.md CHANGED
@@ -263,6 +263,79 @@ This setup allows STDIO-only clients to communicate with the Rails MCP Server th
263
263
 
264
264
  **Tip**: The `rails-mcp-config` tool can configure HTTP mode with mcp-remote automatically.
265
265
 
266
+ ## GitHub Copilot Agent Integration
267
+
268
+ Rails MCP Server works with GitHub Copilot coding agent out of the box. The server auto-detects Rails projects when started from a Rails directory or when configured with environment variables.
269
+
270
+ ### Quick Setup
271
+
272
+ 1. **Configure MCP** - Create `.github/copilot/mcp.json` in your repository:
273
+
274
+ ```json
275
+ {
276
+ "mcpServers": {
277
+ "rails": {
278
+ "type": "local",
279
+ "command": "rails-mcp-server",
280
+ "args": ["--single-project"],
281
+ "tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
282
+ }
283
+ }
284
+ }
285
+ ```
286
+
287
+ 2. **Setup Steps** - Create `.github/workflows/copilot-setup-steps.yml`:
288
+
289
+ ```yaml
290
+ name: "Copilot Setup Steps"
291
+
292
+ on: workflow_dispatch
293
+
294
+ jobs:
295
+ copilot-setup-steps:
296
+ runs-on: ubuntu-latest
297
+ permissions:
298
+ contents: read
299
+ steps:
300
+ - name: Checkout
301
+ uses: actions/checkout@v4
302
+
303
+ - name: Set up Ruby
304
+ uses: ruby/setup-ruby@v1
305
+ with:
306
+ ruby-version: '3.3'
307
+ bundler-cache: true
308
+
309
+ - name: Install Rails MCP Server
310
+ run: gem install rails-mcp-server
311
+ ```
312
+
313
+ ### Alternative: Environment Variable
314
+
315
+ You can also use the `RAILS_MCP_PROJECT_PATH` environment variable:
316
+
317
+ ```json
318
+ {
319
+ "mcpServers": {
320
+ "rails": {
321
+ "type": "local",
322
+ "command": "rails-mcp-server",
323
+ "env": {
324
+ "RAILS_MCP_PROJECT_PATH": "."
325
+ },
326
+ "tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
327
+ }
328
+ }
329
+ }
330
+ ```
331
+
332
+ ### Limitations
333
+
334
+ - GitHub Copilot Agent only supports MCP **tools**, not resources or prompts
335
+ - The `load_guide` analyzer works via `execute_tool`, but requires guides to be downloaded during setup
336
+
337
+ For detailed instructions, see [docs/COPILOT_AGENT.md](docs/COPILOT_AGENT.md).
338
+
266
339
  ## How the Server Works
267
340
 
268
341
  The Rails MCP Server implements the Model Context Protocol using either:
@@ -437,10 +510,11 @@ execute_tool(tool_name: "analyze_environment_config")
437
510
  Load documentation guides from Rails, Turbo, Stimulus, Kamal, or Custom.
438
511
 
439
512
  ```
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" })
513
+ execute_tool(tool_name: "load_guide", params: { library: "rails" })
514
+ execute_tool(tool_name: "load_guide", params: { library: "rails", guide: "getting_started" })
515
+ execute_tool(tool_name: "load_guide", params: { library: "turbo" })
516
+ execute_tool(tool_name: "load_guide", params: { library: "stimulus" })
517
+ execute_tool(tool_name: "load_guide", params: { library: "custom", guide: "tailwind" })
444
518
  ```
445
519
 
446
520
  ## Resources and Documentation
@@ -530,6 +604,10 @@ To use with an MCP client:
530
604
  2. Connect your MCP-compatible client to the server
531
605
  3. The client will be able to use the available tools to interact with your Rails projects
532
606
 
607
+ ## Security
608
+
609
+ For security concerns, please see [SECURITY.md](SECURITY.md).
610
+
533
611
  ## License
534
612
 
535
613
  This Rails MCP server is released under the MIT License, a permissive open-source license that allows for free use, modification, distribution, and private use.
@@ -2,6 +2,32 @@
2
2
 
3
3
  This guide helps AI agents (Claude, GPT, etc.) use the Rails MCP Server effectively. It covers tool selection, common patterns, and troubleshooting.
4
4
 
5
+ ## Architecture Overview
6
+
7
+ Rails MCP Server uses a **progressive tool discovery** pattern to minimize context usage:
8
+
9
+ ```
10
+ MCP Client (Claude, etc.)
11
+
12
+
13
+ ┌─────────────────────────────────────────────┐
14
+ │ 4 MCP-Registered Tools │
15
+ │ ┌─────────────┐ ┌─────────────────────┐ │
16
+ │ │switch_project│ │search_tools │ │
17
+ │ └─────────────┘ └─────────────────────┘ │
18
+ │ ┌─────────────┐ ┌─────────────────────┐ │
19
+ │ │execute_tool │──▶│ 9 Internal Analyzers│ │
20
+ │ └─────────────┘ └─────────────────────┘ │
21
+ │ ┌─────────────┐ │
22
+ │ │execute_ruby │ │
23
+ │ └─────────────┘ │
24
+ └─────────────────────────────────────────────┘
25
+ ```
26
+
27
+ **Key concept:** Only 4 tools are registered with MCP. The 9 internal analyzers (`analyze_models`, `get_routes`, etc.) are discovered via `search_tools` and invoked via `execute_tool`.
28
+
29
+ ---
30
+
5
31
  ## Quick Start
6
32
 
7
33
  **Always start with these two steps:**
@@ -160,11 +186,11 @@ railsMcpServer:execute_tool tool_name: "analyze_controller_views" params: { cont
160
186
  ### Loading Framework Guides
161
187
 
162
188
  ```
163
- railsMcpServer:execute_tool tool_name: "load_guide" params: { guides: "rails", guide: "getting_started" }
164
- railsMcpServer:execute_tool tool_name: "load_guide" params: { guides: "rails", guide: "active_record_basics" }
165
- railsMcpServer:execute_tool tool_name: "load_guide" params: { guides: "turbo" }
166
- railsMcpServer:execute_tool tool_name: "load_guide" params: { guides: "stimulus" }
167
- railsMcpServer:execute_tool tool_name: "load_guide" params: { guides: "kamal" }
189
+ railsMcpServer:execute_tool tool_name: "load_guide" params: { library: "rails", guide: "getting_started" }
190
+ railsMcpServer:execute_tool tool_name: "load_guide" params: { library: "rails", guide: "active_record_basics" }
191
+ railsMcpServer:execute_tool tool_name: "load_guide" params: { library: "turbo" }
192
+ railsMcpServer:execute_tool tool_name: "load_guide" params: { library: "stimulus" }
193
+ railsMcpServer:execute_tool tool_name: "load_guide" params: { library: "kamal" }
168
194
  ```
169
195
 
170
196
  ---
@@ -217,6 +243,27 @@ railsMcpServer:execute_ruby code: "puts read_file('Gemfile')"
217
243
 
218
244
  ---
219
245
 
246
+ ## Analyzer Parameter Quick Reference
247
+
248
+ | Analyzer | Required | Optional |
249
+ |----------|----------|----------|
250
+ | `project_info` | - | `max_depth`, `include_files`, `detail_level` |
251
+ | `list_files` | - | `directory`, `pattern` |
252
+ | `get_file` | `path` | - |
253
+ | `get_routes` | - | `controller`, `verb`, `path_contains`, `named_only`, `detail_level` |
254
+ | `analyze_models` | - | `model_name`, `model_names`, `detail_level`, `analysis_type` |
255
+ | `get_schema` | - | `table_name`, `table_names`, `detail_level` |
256
+ | `analyze_controller_views` | - | `controller_name`, `detail_level`, `analysis_type` |
257
+ | `analyze_environment_config` | - | (none) |
258
+ | `load_guide` | `library` | `guide` |
259
+
260
+ **Common parameter values:**
261
+ - `detail_level`: `"names"`, `"summary"`, `"full"`
262
+ - `analysis_type`: `"introspection"`, `"static"`, `"full"`
263
+ - `library` (for load_guide): `"rails"`, `"turbo"`, `"stimulus"`, `"kamal"`, `"custom"`
264
+
265
+ ---
266
+
220
267
  ## Rails MCP vs Claude Built-in Tools
221
268
 
222
269
  | Task | Use This | NOT This |
@@ -260,6 +307,34 @@ railsMcpServer:execute_ruby code: "puts Dir.glob('app/views/transactions/**/*').
260
307
 
261
308
  ---
262
309
 
310
+ ## Decision Tree: Which Tool Should I Use?
311
+
312
+ ```
313
+ What do you need to do?
314
+
315
+ ├─► Read/analyze code?
316
+ │ ├─► Single file? ──────────► execute_ruby with read_file()
317
+ │ ├─► Model info? ───────────► analyze_models (params: model_name)
318
+ │ ├─► Controller info? ──────► analyze_controller_views (params: controller_name)
319
+ │ └─► Multiple files? ───────► execute_ruby with Dir.glob()
320
+
321
+ ├─► Database info?
322
+ │ ├─► Table structure? ──────► get_schema (params: table_name)
323
+ │ └─► List all tables? ──────► get_schema (params: detail_level: "tables")
324
+
325
+ ├─► Routing info?
326
+ │ ├─► All routes? ───────────► get_routes
327
+ │ └─► Filtered routes? ──────► get_routes (params: controller, verb, path_contains)
328
+
329
+ ├─► Project overview? ─────────► project_info
330
+
331
+ ├─► Documentation? ────────────► load_guide (params: library, guide)
332
+
333
+ └─► Custom Ruby code? ─────────► execute_ruby
334
+ ```
335
+
336
+ ---
337
+
263
338
  ## Common Pitfalls
264
339
 
265
340
  ### ❌ Don't
@@ -268,6 +343,8 @@ railsMcpServer:execute_ruby code: "puts Dir.glob('app/views/transactions/**/*').
268
343
  - Forget `puts` in `execute_ruby` calls
269
344
  - Use absolute paths (always use paths relative to project root)
270
345
  - Skip `switch_project` before using other tools
346
+ - Use `users` (plural) for model names - use `User` (singular CamelCase)
347
+ - Use `User` for table names - use `users` (plural snake_case)
271
348
 
272
349
  ### ✅ Do
273
350
 
@@ -276,6 +353,8 @@ railsMcpServer:execute_ruby code: "puts Dir.glob('app/views/transactions/**/*').
276
353
  - Use `puts` to output results in `execute_ruby`
277
354
  - Fall back to `execute_ruby` when specialized tools fail
278
355
  - Use `search_tools` when unsure what's available
356
+ - Use CamelCase singular for models: `User`, `BlogPost`, `OrderItem`
357
+ - Use snake_case plural for tables: `users`, `blog_posts`, `order_items`
279
358
 
280
359
  ---
281
360
 
@@ -0,0 +1,261 @@
1
+ # GitHub Copilot Agent Integration
2
+
3
+ This guide covers how to configure Rails MCP Server for use with GitHub Copilot coding agent in your Rails projects.
4
+
5
+ ## Overview
6
+
7
+ GitHub Copilot coding agent runs MCP servers in ephemeral GitHub Actions environments. Rails MCP Server supports this through:
8
+
9
+ - **Auto-detection**: Automatically detects Rails projects in the current directory
10
+ - **`--single-project` flag**: Explicitly uses current directory as the project
11
+ - **`RAILS_MCP_PROJECT_PATH` env var**: Specifies project path directly
12
+
13
+ ## Prerequisites
14
+
15
+ - A Rails application repository on GitHub
16
+ - GitHub Copilot with coding agent enabled
17
+ - Ruby 3.1+ (recommended: 3.3)
18
+
19
+ ## Configuration
20
+
21
+ ### Step 1: MCP Configuration
22
+
23
+ Create `.github/copilot/mcp.json` in your repository:
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "rails": {
29
+ "type": "local",
30
+ "command": "rails-mcp-server",
31
+ "args": ["--single-project"],
32
+ "tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ### Step 2: Setup Steps Workflow
39
+
40
+ Create `.github/workflows/copilot-setup-steps.yml`:
41
+
42
+ ```yaml
43
+ name: "Copilot Setup Steps"
44
+
45
+ on:
46
+ workflow_dispatch:
47
+ push:
48
+ paths:
49
+ - .github/workflows/copilot-setup-steps.yml
50
+ pull_request:
51
+ paths:
52
+ - .github/workflows/copilot-setup-steps.yml
53
+
54
+ jobs:
55
+ copilot-setup-steps:
56
+ runs-on: ubuntu-latest
57
+ permissions:
58
+ contents: read
59
+ steps:
60
+ - name: Checkout
61
+ uses: actions/checkout@v4
62
+
63
+ - name: Set up Ruby
64
+ uses: ruby/setup-ruby@v1
65
+ with:
66
+ ruby-version: '3.3'
67
+ bundler-cache: true
68
+
69
+ - name: Install Rails MCP Server
70
+ run: gem install rails-mcp-server
71
+
72
+ - name: Install project dependencies
73
+ run: bundle install
74
+ ```
75
+
76
+ ## Configuration Options
77
+
78
+ ### Option A: `--single-project` flag (Recommended)
79
+
80
+ The simplest approach. Sets the current directory as the project:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "rails": {
86
+ "type": "local",
87
+ "command": "rails-mcp-server",
88
+ "args": ["--single-project"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### Option B: Environment Variable
95
+
96
+ Use `RAILS_MCP_PROJECT_PATH` for explicit path control:
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "rails": {
102
+ "type": "local",
103
+ "command": "rails-mcp-server",
104
+ "env": {
105
+ "RAILS_MCP_PROJECT_PATH": "."
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ ### Option C: Auto-Detection
113
+
114
+ If the server starts from a directory containing a `Gemfile` with Rails, it auto-detects:
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "rails": {
120
+ "type": "local",
121
+ "command": "rails-mcp-server"
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## Available Tools
128
+
129
+ GitHub Copilot Agent only supports MCP **tools**. The following are available:
130
+
131
+ | Tool | Description |
132
+ |------|-------------|
133
+ | `switch_project` | Change active project (optional in single-project mode) |
134
+ | `search_tools` | Discover available analyzers |
135
+ | `execute_tool` | Invoke internal analyzers |
136
+ | `execute_ruby` | Run sandboxed Ruby code |
137
+
138
+ ### Internal Analyzers (via `execute_tool`)
139
+
140
+ - `project_info` - Project structure and Rails version
141
+ - `list_files` - List files matching patterns
142
+ - `get_file` - Read file contents
143
+ - `get_routes` - Rails routes with filtering
144
+ - `get_schema` - Database schema information
145
+ - `analyze_models` - Model associations and validations
146
+ - `analyze_controller_views` - Controller-view relationships
147
+ - `analyze_environment_config` - Environment configuration analysis
148
+ - `load_guide` - Load framework documentation
149
+
150
+ ## Limitations
151
+
152
+ ### MCP Resources Not Supported
153
+
154
+ GitHub Copilot Agent only supports tools. MCP resources and prompts are not available. This means:
155
+
156
+ - Direct resource URIs (e.g., `rails://guides/getting_started`) won't work
157
+ - Use `execute_tool("load_guide", { library: "rails", guide: "getting_started" })` instead
158
+
159
+ ### Documentation Guides
160
+
161
+ The `load_guide` analyzer requires guides to be downloaded. To include guides:
162
+
163
+ 1. Download during setup steps:
164
+
165
+ ```yaml
166
+ - name: Download Rails guides
167
+ run: rails-mcp-server-download-resources rails
168
+ ```
169
+
170
+ 2. Or bundle guides in your repository under `.rails-mcp/resources/`
171
+
172
+ ### Network Restrictions
173
+
174
+ GitHub Copilot Agent runs in a sandboxed environment with firewall restrictions. The MCP server has read-only access to the repository.
175
+
176
+ ## Troubleshooting
177
+
178
+ ### Server Fails to Start
179
+
180
+ 1. Verify Ruby is installed in setup steps
181
+ 2. Check that `rails-mcp-server` gem is installed
182
+ 3. Ensure the workflow runs before Copilot agent starts
183
+
184
+ ### Project Not Detected
185
+
186
+ 1. Verify `Gemfile` exists in repository root
187
+ 2. Verify `Gemfile` contains `gem "rails"` or `gem 'rails'`
188
+ 3. Try explicit `--single-project` flag
189
+
190
+ ### Tools Not Working
191
+
192
+ 1. Verify project dependencies are installed (`bundle install`)
193
+ 2. Check that the project has valid Rails structure
194
+ 3. Use `search_tools` to verify available analyzers
195
+
196
+ ## Example Workflow
197
+
198
+ Here's a complete example for a typical Rails project:
199
+
200
+ **.github/copilot/mcp.json**:
201
+ ```json
202
+ {
203
+ "mcpServers": {
204
+ "rails": {
205
+ "type": "local",
206
+ "command": "rails-mcp-server",
207
+ "args": ["--single-project"],
208
+ "tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ **.github/workflows/copilot-setup-steps.yml**:
215
+ ```yaml
216
+ name: "Copilot Setup Steps"
217
+
218
+ on: workflow_dispatch
219
+
220
+ jobs:
221
+ copilot-setup-steps:
222
+ runs-on: ubuntu-latest
223
+ permissions:
224
+ contents: read
225
+ steps:
226
+ - name: Checkout
227
+ uses: actions/checkout@v4
228
+
229
+ - name: Set up Ruby
230
+ uses: ruby/setup-ruby@v1
231
+ with:
232
+ ruby-version: '3.3'
233
+ bundler-cache: true
234
+
235
+ - name: Install Rails MCP Server
236
+ run: gem install rails-mcp-server
237
+
238
+ - name: Install dependencies
239
+ run: bundle install
240
+
241
+ - name: Setup database
242
+ run: bin/rails db:schema:load
243
+ env:
244
+ RAILS_ENV: test
245
+ ```
246
+
247
+ ## Priority Order
248
+
249
+ The server uses this priority for project detection:
250
+
251
+ 1. `RAILS_MCP_PROJECT_PATH` environment variable (highest)
252
+ 2. Auto-detection from `Gemfile` in current directory
253
+ 3. `projects.yml` configuration file (lowest)
254
+
255
+ In GitHub Copilot Agent environments, options 1 or 2 will typically be used since `projects.yml` doesn't exist.
256
+
257
+ ## Related Documentation
258
+
259
+ - [AI Agent Guide](AGENT.md) - Comprehensive guide for AI agents
260
+ - [Resources Guide](RESOURCES.md) - Documentation and guides management
261
+ - [README](../README.md) - General server documentation
data/docs/RESOURCES.md CHANGED
@@ -163,7 +163,7 @@ The `load_guide` tool is the primary way to access resources programmatically wi
163
163
  ### Basic Syntax
164
164
 
165
165
  ```
166
- load_guide guides: "category" guide: "guide_name"
166
+ execute_tool("load_guide", { library: "category", guide: "guide_name" })
167
167
  ```
168
168
 
169
169
  ### Loading Specific Guides
@@ -295,7 +295,7 @@ Error: Source not readable: /path/to/file
295
295
  ```
296
296
  Guide 'invalid_guide' not found in Rails guides.
297
297
  ```
298
- **Solution**: Use `load_guide guides: "rails"` to see available guides
298
+ **Solution**: Use `execute_tool("load_guide", { library: "rails" })` to see available guides
299
299
 
300
300
  ### Verbose Troubleshooting
301
301
 
data/exe/rails-mcp-config CHANGED
@@ -20,26 +20,44 @@ module RailsMcpConfig
20
20
 
21
21
  # Catppuccin Mocha palette
22
22
  def self.green(text) = rgb(166, 227, 161, text) # #a6e3a1
23
+
23
24
  def self.red(text) = rgb(243, 139, 168, text) # #f38ba8
25
+
24
26
  def self.yellow(text) = rgb(249, 226, 175, text) # #f9e2af
27
+
25
28
  def self.blue(text) = rgb(137, 180, 250, text) # #89b4fa
29
+
26
30
  def self.mauve(text) = rgb(203, 166, 247, text) # #cba6f7
31
+
27
32
  def self.teal(text) = rgb(148, 226, 213, text) # #94e2d5
33
+
28
34
  def self.peach(text) = rgb(250, 179, 135, text) # #fab387
35
+
29
36
  def self.pink(text) = rgb(245, 194, 231, text) # #f5c2e7
37
+
30
38
  def self.sky(text) = rgb(137, 220, 235, text) # #89dceb
39
+
31
40
  def self.lavender(text) = rgb(180, 190, 254, text) # #b4befe
41
+
32
42
  def self.text(text) = rgb(205, 214, 244, text) # #cdd6f4
43
+
33
44
  def self.subtext(text) = rgb(166, 173, 200, text) # #a6adc8
45
+
34
46
  def self.overlay(text) = rgb(108, 112, 134, text) # #6c7086
35
47
 
36
48
  # Semantic aliases
37
49
  def self.success(text) = green(text)
50
+
38
51
  def self.error(text) = red(text)
52
+
39
53
  def self.warning(text) = yellow(text)
54
+
40
55
  def self.info(text) = sky(text)
56
+
41
57
  def self.accent(text) = mauve(text)
58
+
42
59
  def self.bold(text) = "\e[1m#{text}\e[0m"
60
+
43
61
  def self.dim(text) = overlay(text)
44
62
 
45
63
  # Gum hex colors (without #)
@@ -933,7 +951,7 @@ module RailsMcpConfig
933
951
  manifest_path = File.join(config_dir, "resources", "custom", "manifest.yaml")
934
952
  if File.exist?(manifest_path)
935
953
  begin
936
- manifest = YAML.load_file(manifest_path)
954
+ manifest = YAML.safe_load_file(manifest_path, permitted_classes: [Symbol, Time])
937
955
  if manifest && manifest["files"]
938
956
  selected.each do |name|
939
957
  manifest["files"].delete("#{name}.md")
data/exe/rails-mcp-server CHANGED
@@ -29,6 +29,7 @@ if ARGV[0] == "--help" || ARGV[0] == "-h"
29
29
  puts " --mode MODE Server mode: http or stdio (default: stdio)"
30
30
  puts " -p, --port PORT Port to listen on (default: 6029)"
31
31
  puts " --bind-all Bind to 0.0.0.0 instead of localhost (HTTP mode only)"
32
+ puts " --single-project Use current directory as the only project (skip projects.yml)"
32
33
  puts " version Display version information"
33
34
  puts " --help, -h Display this help message"
34
35
  puts ""
@@ -36,6 +37,7 @@ if ARGV[0] == "--help" || ARGV[0] == "-h"
36
37
  puts " #{File.basename($0)} --log-level debug -p 6060"
37
38
  puts " #{File.basename($0)} --mode http --bind-all"
38
39
  puts " #{File.basename($0)} --mode stdio"
40
+ puts " #{File.basename($0)} --single-project"
39
41
  exit 0
40
42
  end
41
43
 
@@ -64,6 +66,9 @@ while i < ARGV.length
64
66
  when "--bind-all"
65
67
  bind_all = true
66
68
  i += 1
69
+ when "--single-project"
70
+ ENV["RAILS_MCP_PROJECT_PATH"] = Dir.pwd
71
+ i += 1
67
72
  else
68
73
  i += 1
69
74
  end