ClaudeCodeMod

All shelves / MCP servers

Rails

maquina-app/rails-mcp-server · 551 stars · Ruby · MIT

MCP server A Ruby gem 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.

Install

The repo has no one-line install. Follow its README.

Open the repo

Files

README.md

Rails MCP Server

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.

What is MCP?

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.

This Rails MCP Server implements the MCP specification to give AI models access to Rails projects for code analysis, exploration, and assistance.

Features

  • Manage multiple Rails projects
  • Browse project files and structures
  • View Rails routes with filtering options
  • Inspect model information and relationships (with Prism static analysis)
  • Get database schema information
  • Analyze controller-view relationships
  • Analyze environment configurations
  • Access comprehensive Rails, Turbo, Stimulus, and Kamal documentation
  • Context-efficient architecture with progressive tool discovery
  • Seamless integration with LLM clients

Installation

Install the gem:

gem install rails-mcp-server

After installation, the following executables will be available in your PATH:

  • rails-mcp-server - The MCP server itself
  • rails-mcp-config - Interactive configuration tool (recommended)
  • rails-mcp-setup-claude - Legacy Claude Desktop setup script
  • rails-mcp-server-download-resources - Legacy resource download script

Configuration

Using the Configuration Tool (Recommended)

The easiest way to configure the Rails MCP Server is using the interactive configuration tool:

rails-mcp-config

This provides a user-friendly TUI (Terminal User Interface) for:

  • Managing Projects: Add, edit, remove, and validate Rails projects
  • Downloading Guides: Download Rails, Turbo, Stimulus, and Kamal documentation
  • Importing Custom Guides: Add your own markdown documentation
  • Claude Desktop Integration: Automatically configure Claude Desktop

The tool uses Gum for an enhanced experience if installed, but works with a basic terminal fallback.

# Install Gum for best experience (optional)
brew install gum        # macOS
sudo apt install gum    # Debian/Ubuntu
yay -S gum              # Arch Linux

Manual Configuration

The Rails MCP Server follows the XDG Base Directory Specification for configuration files:

  • On macOS: $XDG_CONFIG_HOME/rails-mcp or ~/.config/rails-mcp if XDG_CONFIG_HOME is not set
  • On Windows: %APPDATA%\rails-mcp

The server will automatically create these directories and an empty projects.yml file the first time it runs.

To configure your projects manually:

  1. Edit the projects.yml file in your config directory to include your Rails projects:
store: "~/projects/store"
blog: "~/projects/rails-blog"
ecommerce: "/full/path/to/ecommerce-app"

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.

Usage

Starting the server

The Rails MCP Server can run in two modes:

  1. STDIO mode (default): Communicates over standard input/output for direct integration with clients like Claude Desktop.
  2. HTTP mode: Runs as an HTTP server with JSON-RPC and Server-Sent Events (SSE) endpoints.
# Start in default STDIO mode
rails-mcp-server

# Start in HTTP mode on the default port (6029)
rails-mcp-server --mode http

# Start in HTTP mode on a custom port
rails-mcp-server --mode http -p 8080

# Start in HTTP mode binding to all interfaces (for local network access)
rails-mcp-server --mode http --bind-all

When running in HTTP mode, the server provides two endpoints:

  • JSON-RPC endpoint: http://localhost:<port>/mcp/messages
  • SSE endpoint: http://localhost:<port>/mcp/sse

Network Access (HTTP Mode)

By default, the HTTP server only binds to localhost for security. If you need to access the server from other machines on your local network (e.g., for testing with multiple devices), you can use the --bind-all flag:

# Allow access from any machine on your local network
rails-mcp-server --mode http --bind-all

# With a custom port
rails-mcp-server --mode http --bind-all -p 8080

When using --bind-all:

  • The server binds to 0.0.0.0 instead of localhost
  • Access is allowed from local network IP ranges (192.168.x.x, 10.x.x.x)
  • The server accepts connections from .local domain names (e.g., my-computer.local)
  • Security features remain active to prevent unauthorized access

Security Note: Only use --bind-all on trusted networks. The server includes built-in security features to validate origins and IP addresses, but exposing any service to your network increases the attack surface.

Logging Options

The server logs to a file in the ./log directory by default. You can customize logging with these options:

# Set the log level (debug, info, error)
rails-mcp-server --log-level debug

Claude Desktop Integration

The Rails MCP Server can be used with Claude Desktop. There are multiple options to set this up:

Option 1: Use the configuration tool (recommended)

Run the interactive configuration tool and select "Claude Desktop integration":

rails-mcp-config

The tool will:

  • Detect your current Claude Desktop configuration
  • Let you choose between STDIO or HTTP mode
  • Automatically find the correct Ruby and server paths
  • Create a backup before making changes
  • Update the Claude Desktop configuration

Option 2: Use the setup script (legacy)

Run the setup script which will automatically configure Claude Desktop:

rails-mcp-setup-claude

The script will:

  • Create the appropriate config directory for your platform
  • Create an empty projects.yml file if it doesn't exist
  • Update the Claude Desktop configuration

After running the script, restart Claude Desktop to apply the changes.

Option 3: Direct Configuration

  1. Create the appropriate config directory for your platform:
  • macOS: $XDG_CONFIG_HOME/rails-mcp or ~/.config/rails-mcp if XDG_CONFIG_HOME is not set
  • Windows: %APPDATA%\rails-mcp
  1. Create a projects.yml file in that directory with your Rails projects.
  1. Find or create the Claude Desktop configuration file:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  1. Add or update the MCP server configuration:
{
  "mcpServers": {
    "railsMcpServer": {
      "command": "ruby",
      "args": ["/full/path/to/rails-mcp-server/exe/rails-mcp-server"] 
    }
  }
}
  1. Restart Claude Desktop to apply the changes.

Ruby Version Manager Users

Two different Rubies are involved, and the server handles them differently.

#### 1. The Ruby that runs the MCP server

Your MCP client (e.g. Claude Desktop) launches the server using your system's default Ruby, bypassing version-manager initialization. The server must run on the Ruby where its gem is installed, or startup fails. Point the client's command at that Ruby's absolute path — for a version manager, its shim works:

{
  "mcpServers": {
    "railsMcpServer": {
      "command": "/home/your_user/.rbenv/shims/ruby",
      "args": ["/full/path/to/rails-mcp-server/exe/rails-mcp-server"] 
    }
  }
}

Replace /home/your_user/.rbenv/shims/ruby with your actual Ruby path (an rbenv/mise/asdf shim, or your rvm/chruby Ruby).

Tip: The rails-mcp-config tool detects this Ruby automatically (via RbConfig.ruby) and writes the correct absolute path when configuring Claude Desktop.

#### 2. The Ruby used to introspect each Rails project

Tools that boot your app — get_schema, get_routes, and the introspection half of analyze_models / analyze_controller_views — run bin/rails inside the project directory. The server selects the project's Ruby automatically and is agnostic to your version manager: it prepends the active manager's shims (mise, asdf, rbenv) to the subprocess PATH and sources rvm when present, then uses a non-login shell so macOS path_helper cannot substitute the system Ruby. The version is taken from the project's .ruby-version / .tool-versions / .mise.toml, so different projects can use different Rubies with no extra configuration.

No manual PATH workaround is needed. Previously these tools could fall back to the system Ruby on mise/asdf machines, where the app's Bundler then failed to boot.

Using an MCP Proxy (Advanced)

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:

Facts

Kind
MCP server
Repo
maquina-app/rails-mcp-server
Group
Uncategorized
Stars
551
License
MIT
Language
Ruby
Last push
2026-09-28
Forks
36

More on this shelf

  1. 1Everythingmodelcontextprotocol/serversThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.85.8k
  2. 2Fetchmodelcontextprotocol/serversA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.85.8k
  3. 3Gitmodelcontextprotocol/serversA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.85.8k
  4. 4Memorymodelcontextprotocol/serversA basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats.85.8k
  5. 5Sequential Thinkingmodelcontextprotocol/serversAn MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.85.8k
  6. 6Timemodelcontextprotocol/serversA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.85.8k