$git clone https://github.com/maquina-app/rails-mcp-serverA Ruby implementation of a Model Context Protocol (MCP) server for Rails projects. This server allows LLMs (Large Language Models) to interact with Rails projects through the Model Context Protocol, providing capabilities for code analysis, exploration, and development assistance
| 1 | # Rails MCP Server |
| 2 | |
| 3 | A Ruby implementation of a Model Context Protocol (MCP) server for Rails projects. This server allows LLMs (Large Language Models) to interact with Rails projects through the Model Context Protocol, providing capabilities for code analysis, exploration, and development assistance. |
| 4 | |
| 5 | ## What is MCP? |
| 6 | |
| 7 | The Model Context Protocol (MCP) is a standardized way for AI models to interact with their environment. It defines a structured method for models to request and use tools, access resources, and maintain context during interactions. |
| 8 | |
| 9 | This Rails MCP Server implements the MCP specification to give AI models access to Rails projects for code analysis, exploration, and assistance. |
| 10 | |
| 11 | ## Features |
| 12 | |
| 13 | - Manage multiple Rails projects |
| 14 | - Browse project files and structures |
| 15 | - View Rails routes with filtering options |
| 16 | - Inspect model information and relationships (with Prism static analysis) |
| 17 | - Get database schema information |
| 18 | - Analyze controller-view relationships |
| 19 | - Analyze environment configurations |
| 20 | - Execute sandboxed Ruby code for custom queries |
| 21 | - Access comprehensive Rails, Turbo, Stimulus, and Kamal documentation |
| 22 | - Context-efficient architecture with progressive tool discovery |
| 23 | - Seamless integration with LLM clients |
| 24 | |
| 25 | ## Installation |
| 26 | |
| 27 | Install the gem: |
| 28 | |
| 29 | ```bash |
| 30 | gem install rails-mcp-server |
| 31 | ``` |
| 32 | |
| 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 |
| 39 | |
| 40 | ## Configuration |
| 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 | |
| 68 | The Rails MCP Server follows the XDG Base Directory Specification for configuration files: |
| 69 | |
| 70 | - On macOS: `$XDG_CONFIG_HOME/rails-mcp` or `~/.config/rails-mcp` if XDG_CONFIG_HOME is not set |
| 71 | - On Windows: `%APPDATA%\rails-mcp` |
| 72 | |
| 73 | The server will automatically create these directories and an empty `projects.yml` file the first time it runs. |
| 74 | |
| 75 | To configure your projects manually: |
| 76 | |
| 77 | 1. Edit the `projects.yml` file in your config directory to include your Rails projects: |
| 78 | |
| 79 | ```yaml |
| 80 | store: "~/projects/store" |
| 81 | blog: "~/projects/rails-blog" |
| 82 | ecommerce: "/full/path/to/ecommerce-app" |
| 83 | ``` |
| 84 | |
| 85 | Each key in the YAML file is a project name (which will be used with the `switch_project` tool), and each value is the path to the project directory. |
| 86 | |
| 87 | ## Usage |
| 88 | |
| 89 | ### Starting the server |
| 90 | |
| 91 | The Rails MCP Server can run in two modes: |
| 92 | |
| 93 | 1. **STDIO mode (default)**: Communicates over standard input/output for direct integration with clients like Claude Desktop. |
| 94 | 2. **HTTP mode**: Runs as an HTTP server with JSON-RPC and Server-Sent Events (SSE) endpoints. |
| 95 | |
| 96 | ```bash |
| 97 | # Start in default STDIO mode |
| 98 | rails-mcp-server |
| 99 | |
| 100 | # Start in HTTP mode on the default port (6029) |
| 101 | rails-mcp-server --mode http |
| 102 | |
| 103 | # Start in HTTP mode on a custom port |
| 104 | rails-mcp-server --mode http -p 8080 |
| 105 | |
| 106 | # Start in HTTP mode binding to all interfaces (for local network access) |
| 107 | rails-mcp-server --mode http --bind-all |
| 108 | ``` |
| 109 | |
| 110 | When running in HTTP mode, the server provides two endpoints: |
| 111 | |
| 112 | - JSON-RPC endpoint: `http://localhost:<por |