rails-mcp-server 1.0.1 → 1.4.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +312 -0
  3. data/README.md +316 -251
  4. data/config/resources.yml +203 -0
  5. data/docs/AGENT.md +345 -0
  6. data/docs/RESOURCES.md +339 -0
  7. data/exe/rails-mcp-config +1407 -0
  8. data/exe/rails-mcp-server +121 -17
  9. data/exe/rails-mcp-server-download-resources +120 -0
  10. data/exe/rails-mcp-setup-claude +3 -2
  11. data/lib/rails-mcp-server/analyzers/analyze_controller_views.rb +253 -0
  12. data/lib/rails-mcp-server/analyzers/analyze_environment_config.rb +79 -0
  13. data/lib/rails-mcp-server/analyzers/analyze_models.rb +251 -0
  14. data/lib/rails-mcp-server/analyzers/base_analyzer.rb +42 -0
  15. data/lib/rails-mcp-server/analyzers/get_file.rb +40 -0
  16. data/lib/rails-mcp-server/analyzers/get_routes.rb +212 -0
  17. data/lib/rails-mcp-server/analyzers/get_schema.rb +216 -0
  18. data/lib/rails-mcp-server/analyzers/list_files.rb +43 -0
  19. data/lib/rails-mcp-server/analyzers/load_guide.rb +84 -0
  20. data/lib/rails-mcp-server/analyzers/project_info.rb +136 -0
  21. data/lib/rails-mcp-server/config.rb +78 -0
  22. data/lib/rails-mcp-server/helpers/resource_base.rb +143 -0
  23. data/lib/rails-mcp-server/helpers/resource_downloader.rb +104 -0
  24. data/lib/rails-mcp-server/helpers/resource_importer.rb +113 -0
  25. data/lib/rails-mcp-server/resources/base_resource.rb +7 -0
  26. data/lib/rails-mcp-server/resources/custom_guides_resource.rb +54 -0
  27. data/lib/rails-mcp-server/resources/custom_guides_resources.rb +37 -0
  28. data/lib/rails-mcp-server/resources/guide_content_formatter.rb +130 -0
  29. data/lib/rails-mcp-server/resources/guide_error_handler.rb +85 -0
  30. data/lib/rails-mcp-server/resources/guide_file_finder.rb +100 -0
  31. data/lib/rails-mcp-server/resources/guide_framework_contract.rb +65 -0
  32. data/lib/rails-mcp-server/resources/guide_loader_template.rb +122 -0
  33. data/lib/rails-mcp-server/resources/guide_manifest_operations.rb +52 -0
  34. data/lib/rails-mcp-server/resources/kamal_guides_resource.rb +80 -0
  35. data/lib/rails-mcp-server/resources/kamal_guides_resources.rb +110 -0
  36. data/lib/rails-mcp-server/resources/rails_guides_resource.rb +29 -0
  37. data/lib/rails-mcp-server/resources/rails_guides_resources.rb +37 -0
  38. data/lib/rails-mcp-server/resources/stimulus_guides_resource.rb +29 -0
  39. data/lib/rails-mcp-server/resources/stimulus_guides_resources.rb +37 -0
  40. data/lib/rails-mcp-server/resources/turbo_guides_resource.rb +29 -0
  41. data/lib/rails-mcp-server/resources/turbo_guides_resources.rb +37 -0
  42. data/lib/rails-mcp-server/tools/base_tool.rb +11 -0
  43. data/lib/rails-mcp-server/tools/execute_ruby.rb +409 -0
  44. data/lib/rails-mcp-server/tools/execute_tool.rb +115 -0
  45. data/lib/rails-mcp-server/tools/get_model.rb +116 -0
  46. data/lib/rails-mcp-server/tools/search_tools.rb +186 -0
  47. data/lib/rails-mcp-server/tools/switch_project.rb +40 -0
  48. data/lib/rails-mcp-server/utilities/run_process.rb +31 -0
  49. data/lib/rails-mcp-server/version.rb +1 -1
  50. data/lib/rails_mcp_server.rb +56 -1155
  51. metadata +143 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77086c307fcceff18aac3bb1141c13a4b3de689342b65b276950156de22b09f0
4
- data.tar.gz: 7afb0b7e81b51540befce4ef6dacb0aaf731aa3afcbb5135267c1e1311846f79
3
+ metadata.gz: 65769f824f1dbb5bfe856a40f0a46aed59d4591b3e2d23c486b6f6a08687075c
4
+ data.tar.gz: 596d5a5bd1d22559a0d4d9ea1369b1c375546ce790a3c71edc378c053c75b433
5
5
  SHA512:
6
- metadata.gz: '03796522301b8d8d7c3ab258c67a146847d41ae909534148bc2015f7e11fe0156cbec424218de469f85c2f992958b3831b9b4a51da1799f9235b0c39469d5c4c'
7
- data.tar.gz: 9511d7eaa3fdd2a3e05fa42cfd4ab7b102508641ce07831bacb8927311c1b275af4fed19e248754d28db28bcf7c5c82cdcb38e0b4ef9d7335bbee8100372214d
6
+ metadata.gz: 4c51f927f27949ec313ce1762911676f338553513189f030fc610847ced95d0b1f31d8badcfafe6d89d077e15fde6b6ec2d4e9a4417afd2aaeccd3275b46c170
7
+ data.tar.gz: 5d290f823f45a04ef7a4e0fed4a2ec2820e6be1c086af40441dc33cba7423ac2698e58b300febe2f8cd7accbdf49e7f5663dbd38f2e4a8162d6c30b326849cc2
data/CHANGELOG.md ADDED
@@ -0,0 +1,312 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.4.1] - 2025-12-11
9
+
10
+ ### Fixed
11
+
12
+ - **rails-mcp-config rbenv compatibility**: Fixed silent failure when running via rbenv shims
13
+ - The `__FILE__ == $0` guard failed because RubyGems' `load` creates a path mismatch between `__FILE__` (gem path) and `$0` (shim path)
14
+ - Now correctly detects execution via `File.basename($0) == "rails-mcp-config"`
15
+
16
+ ## [1.4.0] - 2025-12-10
17
+
18
+ ### Added
19
+
20
+ - **Context-Efficient Architecture**: Reduced registered MCP tools from 12 to 4, cutting initial context consumption by 67%
21
+ - 4 bootstrap tools: `switch_project`, `search_tools`, `execute_tool`, `execute_ruby`
22
+ - 9 internal analyzers invoked via `execute_tool` meta-dispatcher
23
+ - Tools are now discovered on-demand rather than loaded upfront
24
+ - **Sandboxed Ruby Execution** (`execute_ruby`): Secure code execution in Rails context
25
+ - File/network/system call restrictions
26
+ - Sensitive file protection (.env, credentials, .gitignore'd files)
27
+ - Helper methods: `read_file`, `file_exists?`, `list_files`, `project_root`
28
+ - **Interactive Configuration Tool** (`rails-mcp-config`): New TUI for project management
29
+ - Project management with validation
30
+ - Guide downloading with progress indicators
31
+ - Claude Desktop auto-configuration (STDIO/HTTP modes)
32
+ - Gum-enhanced UI with terminal fallback
33
+ - **Claude Code Integration**: Added CLAUDE.md, .claudeignore, and .claude/ configuration
34
+ - **Agent Documentation**: New docs/AGENT.md comprehensive AI agent guide
35
+
36
+ ### Changed
37
+
38
+ - **Architecture Refactor**: Separation of tools/ (FastMCP) vs analyzers/ (plain Ruby classes)
39
+ - New `lib/rails-mcp-server/analyzers/` directory with `RailsMcpServer::Analyzers` namespace
40
+ - Removed deprecated extensions (resource_templating, server_templating)
41
+ - **Rails Introspection** (replaces regex parsing):
42
+ - `Model.reflect_on_all_associations` for accurate association data
43
+ - `Model.validators` with conditions and options
44
+ - `Controller.action_methods` instead of scanning for `def`
45
+ - `Rails.application.routes.routes` for direct route access
46
+ - `_process_action_callbacks` for before/after actions
47
+ - **Prism Static Analysis**: AST-based code inspection for callbacks, scopes, concerns
48
+ - Method definitions with line numbers
49
+ - Instance variables per controller action
50
+ - New `analysis_type` parameter: introspection | static | full
51
+
52
+ ### Improved
53
+
54
+ - **Output Optimization**: New `detail_level` parameter (names | summary | full)
55
+ - **Route Filtering**: Filter by controller, verb, or path
56
+ - **Batch Operations**: Support for analyzing multiple models and schemas at once
57
+ - **Quick Start Guide**: Shown after `switch_project` for better onboarding
58
+ - **execute_ruby Hints**: Improved feedback for missing puts statements
59
+
60
+ ### Fixed
61
+
62
+ - **get_routes**: Fixed method definition order bug
63
+
64
+ ### Technical
65
+
66
+ - Test suite with 32 tests covering analyzers and tools
67
+ - Test fixtures with sample Rails project structure
68
+
69
+ ## [1.2.3] - 2025-12-10
70
+
71
+ ### Fixed
72
+
73
+ - **Setup Script Compatibility**: Fixed `rails-mcp-setup-claude` failing on readonly filesystems (thanks to @emptyflask)
74
+ - Only runs `chmod` when the file is not already executable
75
+ - Resolves issues on NixOS and similar platforms with readonly filesystems
76
+ - Fixes failures when the current user is not the owner of the executable
77
+
78
+ ## [1.2.2] - 2025-07-21
79
+
80
+ ### Added
81
+
82
+ - **Network Access Support**: New `--bind-all` flag for HTTP mode to allow access from local network
83
+ - Binds to `0.0.0.0` instead of `localhost` when enabled
84
+ - Allows connections from local network IP ranges (192.168.x.x, 10.x.x.x)
85
+ - Accepts connections from `.local` domain names (e.g., `my-computer.local`)
86
+ - Maintains security features with origin validation and IP filtering
87
+
88
+ ### Improved
89
+
90
+ - **Security Configuration**: Enhanced allowed origins and IP configuration when using `--bind-all`
91
+ - Automatically configures appropriate security settings for local network access
92
+ - Preserves localhost-only mode by default for security
93
+ - Clear documentation of security implications
94
+
95
+ ### Changed
96
+
97
+ - HTTP server binding address is now configurable via `--bind-all` flag
98
+ - Updated help text to include new network access option
99
+
100
+ ## [1.2.1] - 2025-06-09
101
+
102
+ ### Fixed
103
+
104
+ - Fix a debug message generating invalid STDIO output.
105
+ - Fix tool name spelling.
106
+
107
+ ## [1.2.0] - 2025-06-03
108
+
109
+ ### Added
110
+
111
+ - **Comprehensive Resources and Documentation System**: Complete access to Rails ecosystem documentation
112
+ - `load_guide` tool for accessing official framework documentation
113
+ - Support for Rails, Turbo, Stimulus, and Kamal documentation
114
+ - Custom markdown file import capabilities
115
+ - Automatic resource downloading via `rails-mcp-server-download-resources` command
116
+ - Resource storage in XDG-compliant directories with manifest tracking
117
+ - **Five Resource Categories**:
118
+ - **Rails Guides**: Official Ruby on Rails 8.0.2 documentation (50+ guides)
119
+ - **Turbo Guides**: Complete Hotwire Turbo framework documentation
120
+ - **Stimulus Guides**: Full Stimulus JavaScript framework documentation
121
+ - **Kamal Guides**: Comprehensive Kamal deployment tool documentation
122
+ - **Custom Guides**: Import and manage your own markdown documentation
123
+ - **Direct Resource Access**: MCP clients can query resources using URI templates
124
+ - `rails://guides/{guide_name}` for Rails documentation
125
+ - `turbo://guides/{guide_name}` for Turbo guides
126
+ - `stimulus://guides/{guide_name}` for Stimulus documentation
127
+ - `kamal://guides/{guide_name}` for Kamal guides
128
+ - `custom://guides/{guide_name}` for custom imports
129
+ - **Advanced Resource Management**:
130
+ - Force download options (`--force`) for updating resources
131
+ - Verbose logging (`--verbose`) for troubleshooting
132
+ - Batch import support for directory structures
133
+ - Filename normalization for custom imports
134
+ - Version tracking and update management
135
+
136
+ ### Improved
137
+
138
+ - **Enhanced Documentation**: All tools now include comprehensive natural language examples
139
+ - **Resource Integration**: Seamless integration with existing MCP tool ecosystem
140
+ - **File Organization**: Better project structure with XDG Base Directory compliance
141
+ - **Error Handling**: Improved validation and error messages across resource operations
142
+
143
+ ### Technical
144
+
145
+ - URI templating support for direct resource access
146
+ - Enhanced manifest management for resource tracking
147
+ - Integration with FastMCP for robust resource handling
148
+ - Simplified guides configuration and management
149
+
150
+ ## [1.1.4] - 2025-05-02
151
+
152
+ ### Fixed
153
+
154
+ - **HTTP Mode Issues**: Resolved Puma server startup failures in HTTP mode
155
+ - **Rails Command Execution**: Fixed issues with executing Rails commands in certain environments
156
+ - **Logger Configuration**: Fixed logger initialization when no config file exists (thanks to @justwiebe)
157
+
158
+ ### Changed
159
+
160
+ - Improved dependency version constraints for better compatibility
161
+ - Enhanced error handling for HTTP server operations
162
+
163
+ ## [1.1.0] - 2025-04-20
164
+
165
+ ### Added
166
+
167
+ - **HTTP Server-Sent Events (SSE) Support**: Real-time communication capabilities
168
+ - HTTP mode with JSON-RPC and SSE endpoints (`--mode http`)
169
+ - Custom port configuration with `-p/--port` option
170
+ - SSE endpoint at `/mcp/sse` for real-time updates
171
+ - JSON-RPC endpoint at `/mcp/messages`
172
+ - **New Analysis Tools**:
173
+ - `analyze_controller_views`: Analyze relationships between controllers, actions, and views
174
+ - `analyze_environment_config`: Compare environment configurations for inconsistencies and security issues
175
+ - **Enhanced Integration**:
176
+ - MCP Inspector compatibility for testing and debugging
177
+ - Improved client compatibility through HTTP endpoints
178
+ - Better support for multiple LLM clients
179
+
180
+ ### Improved
181
+
182
+ - **Code Organization**: Major refactoring using FastMCP gem
183
+ - Transition from mcp-rb to fast-mcp for better protocol support
184
+ - Enhanced modular architecture for better maintainability
185
+ - Improved error handling and validation across all tools
186
+ - **File System Respect**: All tools now respect `.gitignore` files when scanning codebases
187
+ - **Tool Enhancements**: Comprehensive review and improvement of all existing tools
188
+ - Better edge case handling for large projects
189
+ - Performance improvements for file operations
190
+ - Enhanced logging and debugging capabilities
191
+
192
+ ### Technical
193
+
194
+ - **FastMCP Integration**: Complete migration to FastMCP gem for robust MCP protocol implementation
195
+ - **Rack-based Architecture**: HTTP server implementation using Rack
196
+ - **Event-driven Communication**: Real-time event handling for SSE support
197
+ - **Improved Connection Management**: Better handling of client connections and message processing
198
+
199
+ ### Changed
200
+
201
+ - **Internal Architecture**: Complete refactoring to use FastMCP instead of mcp-rb
202
+ - **Command-line Interface**: Enhanced CLI with mode selection and configuration options
203
+ - **Documentation**: Updated with detailed tool descriptions and usage examples
204
+
205
+ ## [1.0.0] - 2025-03-20
206
+
207
+ ### Added
208
+
209
+ - **Initial Release**: Rails MCP Server for AI-assisted Rails development
210
+ - **Core Tools** (8 tools):
211
+ - `switch_project`: Change active Rails project for multi-project support
212
+ - `project_info`: Get comprehensive Rails project information and structure
213
+ - `list_files`: Browse project files with glob pattern matching
214
+ - `get_file`: Retrieve file contents with syntax highlighting
215
+ - `get_routes`: Display all Rails routes (equivalent to `rails routes`)
216
+ - `analyze_models`: Analyze Active Record models, associations, and relationships
217
+ - `get_schema`: Retrieve database schema information and table structures
218
+ - Basic file and project analysis capabilities
219
+ - **Project Management System**:
220
+ - Multi-project support through `projects.yml` configuration
221
+ - XDG Base Directory Specification compliance for configuration
222
+ - Automatic project detection and setup
223
+ - Cross-platform compatibility (macOS, Windows)
224
+ - **Claude Desktop Integration**:
225
+ - STDIO mode communication for direct integration
226
+ - Automatic setup script (`rails-mcp-setup-claude`)
227
+ - Ruby version manager compatibility documentation
228
+ - JSON-RPC 2.0 protocol implementation
229
+ - **Developer Experience**:
230
+ - Comprehensive logging system with configurable levels
231
+ - Debug mode and verbose output options
232
+ - Robust error handling and validation
233
+ - Clear documentation and setup guides
234
+
235
+ ### Features
236
+
237
+ - **Rails-Specific Intelligence**: Deep understanding of Rails application architecture
238
+ - Model relationships and Active Record associations analysis
239
+ - Controller and route mapping
240
+ - Database schema exploration and relationship discovery
241
+ - Rails convention-based file discovery
242
+ - **Smart File System Integration**:
243
+ - Intelligent file discovery with glob pattern support
244
+ - Automatic respect for Rails conventions and `.gitignore`
245
+ - Syntax highlighting for various file types
246
+ - Efficient handling of large codebases
247
+ - **Configuration Management**:
248
+ - Platform-specific configuration directories
249
+ - Project-based organization and switching
250
+ - Automatic initialization and setup
251
+ - Secure and isolated project environments
252
+
253
+ ### Technical Foundation
254
+
255
+ - **Model Context Protocol (MCP)**: Full MCP specification implementation
256
+ - **Communication**: JSON-RPC 2.0 protocol over STDIO
257
+ - **Architecture**: Modular, extensible design for future enhancements
258
+ - **Distribution**: Ruby gem packaging for easy installation and updates
259
+ - **Compatibility**: Cross-platform support with platform-specific optimizations
260
+
261
+ ---
262
+
263
+ ## Version History Summary
264
+
265
+ - **v1.4.0** (2025-12-10): Context-efficient architecture with progressive tool discovery (67% token reduction)
266
+ - **v1.2.3** (2025-12-10): Setup script fix for readonly filesystems (NixOS compatibility)
267
+ - **v1.2.2** (2025-07-21): Network access support with --bind-all flag
268
+ - **v1.2.1** (2025-06-09): Bug fixes for STDIO output and tool naming
269
+ - **v1.2.0** (2025-06-03): Major documentation and resource system addition
270
+ - **v1.1.4** (2025-05-02): Critical bug fixes for HTTP mode and Rails commands
271
+ - **v1.1.0** (2025-04-20): HTTP SSE support and new analysis tools with FastMCP migration
272
+ - **v1.0.0** (2025-03-20): Initial release with core Rails MCP functionality
273
+
274
+ ## Development Guidelines
275
+
276
+ ### Version Numbering
277
+
278
+ This project follows [Semantic Versioning](https://semver.org/):
279
+
280
+ - **MAJOR** version for incompatible API changes
281
+ - **MINOR** version for backwards-compatible functionality additions
282
+ - **PATCH** version for backwards-compatible bug fixes
283
+
284
+ ### Release Process
285
+
286
+ 1. Update version in `lib/rails-mcp-server/version.rb`
287
+ 2. Update this CHANGELOG.md with new features and changes
288
+ 3. Update README.md and documentation if needed
289
+ 4. Create a git tag: `git tag -a v1.2.3 -m "Release version 1.2.3"`
290
+ 5. Push tags: `git push origin --tags`
291
+ 6. Build and publish gem: `gem build rails-mcp-server.gemspec && gem push rails-mcp-server-1.2.3.gem`
292
+
293
+ ### Changelog Categories
294
+
295
+ - **Added** for new features
296
+ - **Changed** for changes in existing functionality
297
+ - **Deprecated** for soon-to-be removed features
298
+ - **Removed** for now removed features
299
+ - **Fixed** for any bug fixes
300
+ - **Security** for vulnerability fixes
301
+ - **Technical** for internal/technical improvements
302
+ - **Improved** for enhancements to existing features
303
+
304
+ ---
305
+
306
+ ## Links
307
+
308
+ - [Repository](https://github.com/maquina-app/rails-mcp-server)
309
+ - [Releases](https://github.com/maquina-app/rails-mcp-server/releases)
310
+ - [Issues](https://github.com/maquina-app/rails-mcp-server/issues)
311
+ - [Documentation](https://github.com/maquina-app/rails-mcp-server#readme)
312
+ - [Resources Guide](docs/RESOURCES.md)