A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
A Ruby gem implementation of a Model Context Protocol (MCP) server for Rails projects. This server allows LLMs (Large La
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.
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.
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 itselfrails-mcp-config - Interactive configuration tool (recommended)rails-mcp-setup-claude - Legacy Claude Desktop setup scriptrails-mcp-server-download-resources - Legacy resource download scriptThe 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:
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
The Rails MCP Server follows the XDG Base Directory Specification for configuration files:
$XDG_CONFIG_HOME/rails-mcp or ~/.config/rails-mcp if XDG_CONFIG_HOME is not set%APPDATA%\rails-mcpThe server will automatically create these directories and an empty projects.yml file the first time it runs.
To configure your projects manually:
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.
The Rails MCP Server can run in two modes:
# 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:
http://localhost:<port>/mcp/messageshttp://localhost:<port>/mcp/sseBy 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:
0.0.0.0 instead of localhost.local domain names (e.g., my-computer.local)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.
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
The Rails MCP Server can be used with Claude Desktop. There are multiple options to set this up:
Run the interactive configuration tool and select "Claude Desktop integration":
rails-mcp-config
The tool will:
Run the setup script which will automatically configure Claude Desktop:
rails-mcp-setup-claude
The script will:
projects.yml file if it doesn't existAfter running the script, restart Claude Desktop to apply the changes.
Create the appropriate config directory for your platform:
$XDG_CONFIG_HOME/rails-mcp or ~/.config/rails-mcp if XDG_CONFIG_HOME is not set%APPDATA%\rails-mcpCreate a projects.yml file in that directory with your Rails projects.
Find or create the Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonAdd or update the MCP server configuration:
{
"mcpServers": {
"railsMcpServer": {
"command": "ruby",
"args": ["/full/path/to/rails-mcp-server/exe/rails-mcp-server"]
}
}
}
Claude Desktop launches the MCP server using your system's default Ruby environment, bypassing version manager initialization (e.g., rbenv, RVM). The MCP server needs to use the same Ruby version where it was installed, as MCP server startup failures can occur when using an incompatible Ruby version.
If you are using a Ruby version manager such as rbenv, you can use the Ruby shim path to ensure the correct version is used:
{
"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 path for the Ruby shim.
Tip: The rails-mcp-config tool automatically detects your Ruby path and uses the correct shim path when configuring Claude Desktop.
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:
rails-mcp-server --mode http
# Install the Node.js based MCP proxy
npm install -g mcp-remote
# Run the proxy, pointing to your running Rails MCP Server
npx mcp-remote http://localhost:6029/mcp/sse
{
"mcpServers": {
"railsMcpServer": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:6029/mcp/sse"]
}
}
}
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.
Tip: The rails-mcp-config tool can configure HTTP mode with mcp-remote automatically.
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.
.github/copilot/mcp.json in your repository:{
"mcpServers": {
"rails": {
"type": "local",
"command": "rails-mcp-server",
"args": ["--single-project"],
"tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
}
}
}
.github/workflows/copilot-setup-steps.yml:name: "Copilot Setup Steps"
on: workflow_dispatch
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Install Rails MCP Server
run: gem install rails-mcp-server
You can also use the RAILS_MCP_PROJECT_PATH environment variable:
{
"mcpServers": {
"rails": {
"type": "local",
"command": "rails-mcp-server",
"env": {
"RAILS_MCP_PROJECT_PATH": "."
},
"tools": ["switch_project", "search_tools", "execute_tool", "execute_ruby"]
}
}
}
load_guide analyzer works via execute_tool, but requires guides to be downloaded during setupFor detailed instructions, see docs/COPILOT_AGENT.md.
The Rails MCP Server implements the Model Context Protocol using either:
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.
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:
switch_project - Select the active Rails projectsearch_tools - Discover available tools by category or keywordexecute_tool - Invoke internal analyzers with parametersexecute_ruby - Run sandboxed Ruby code for custom queriesThis design reduces initial context from ~2,400 tokens to ~800 tokens while maintaining full functionality.
For AI agents (Claude, GPT, etc.) using this server, see the comprehensive AI Agent Guide which covers:
execute_rubyThe server provides 4 registered tools plus internal analyzers accessible via execute_tool.
switch_projectDescription: Change the active Rails project. Must be called before using other tools.
Parameters:
project_name: (String, required) Name of the project as defined in projects.ymlAfter switching, you'll see a Quick Start guide with common commands.
search_toolsDescription: Discover available tools by category or keyword.
Parameters:
query: (String, optional) Search term (e.g., 'routes', 'model', 'schema')category: (String, optional) Filter by category: models, database, routing, controllers, files, project, guidesdetail_level: (String, optional) Output detail: 'names', 'summary', or 'full' (default: 'summary')execute_toolDescription: Invoke internal analyzers by name.
Parameters:
tool_name: (String, required) Name of the analyzer (e.g., 'get_routes', 'analyze_models')params: (Hash, optional) Parameters for the analyzerexecute_rubyDescription: Execute sandboxed Ruby code in the Rails project context.
Parameters:
code: (String, required) Ruby code to executetimeout: (Integer, optional) Timeout in seconds (default: 30, max: 60)Available helper methods:
read_file(path) - Read a file safelyfile_exists?(path) - Check if a file existslist_files(pattern) - Glob files (e.g., 'app/models/**/*.rb')project_root - Get the project root pathNote: Use puts to see output from your code.
Security: The sandbox prevents file writes, system calls, network access, and reading sensitive files (.env, credentials, etc.).
project_infoRetrieve comprehensive project information including Rails version, directory structure, and organization.
execute_tool(tool_name: "project_info")
list_filesList files matching a pattern in a directory.
execute_tool(tool_name: "list_files", params: { directory: "app/models", pattern: "*.rb" })
get_fileRetrieve the content of a specific file.
execute_tool(tool_name: "get_file", params: { path: "app/models/user.rb" })
get_routesRetrieve Rails routes with optional filtering.
execute_tool(tool_name: "get_routes")
execute_tool(tool_name: "get_routes", params: { controller: "users" })
execute_tool(tool_name: "get_routes", params: { verb: "POST" })
execute_tool(tool_name: "get_routes", params: { path_contains: "api" })
analyze_modelsAnalyze Active Record models with associations, validations, and optional Prism static analysis.
execute_tool(tool_name: "analyze_models")
execute_tool(tool_name: "analyze_models", params: { model_name: "User" })
execute_tool(tool_name: "analyze_models", params: { model_name: "User", analysis_type: "full" })
execute_tool(tool_name: "analyze_models", params: { detail_level: "names" })
Parameters:
model_name: Specific model to analyzemodel_names: Array of models to analyzedetail_level: 'names', 'summary', or 'full'analysis_type: 'introspection', 'static', or 'full' (includes Prism AST analysis)get_schemaRetrieve database schema information.
execute_tool(tool_name: "get_schema")
execute_tool(tool_name: "get_schema", params: { table_name: "users" })
execute_tool(tool_name: "get_schema", params: { detail_level: "tables" })
analyze_controller_viewsAnalyze controller-view relationships with optional Prism static analysis.
execute_tool(tool_name: "analyze_controller_views")
execute_tool(tool_name: "analyze_controller_views", params: { controller_name: "users" })
execute_tool(tool_name: "analyze_controller_views", params: { controller_name: "users", analysis_type: "full" })
analyze_environment_configAnalyze environment configurations for inconsistencies and security issues.
execute_tool(tool_name: "analyze_environment_config")
load_guideLoad documentation guides from Rails, Turbo, Stimulus, Kamal, or Custom.
execute_tool(tool_name: "load_guide", params: { library: "rails" })
execute_tool(tool_name: "load_guide", params: { library: "rails", guide: "getting_started" })
execute_tool(tool_name: "load_guide", params: { library: "turbo" })
execute_tool(tool_name: "load_guide", params: { library: "stimulus" })
execute_tool(tool_name: "load_guide", params: { library: "custom", guide: "tailwind" })
The Rails MCP Server provides access to comprehensive documentation through both the load_guide tool and direct MCP resource access. You can access official guides for Rails, Turbo, Stimulus, and Kamal, as well as import your own custom documentation.
The easiest way to manage resources is using the configuration tool:
rails-mcp-config
Then select "Download guides" or "Import custom guides" from the menu.
Alternatively, you can use the legacy command-line tools:
# Download Rails guides
rails-mcp-server-download-resources rails
# Download Turbo guides
rails-mcp-server-download-resources turbo
# Import custom markdown files
rails-mcp-server-download-resources --file /path/to/your/docs/
load_guide tool in conversationsrails://guides/{guide_name}For complete information about downloading, managing, and using resources, see the Resources Guide.
The easiest way to test and debug the Rails MCP Server is by using the MCP Inspector, a developer tool designed specifically for testing and debugging MCP servers.
To use MCP Inspector with Rails MCP Server:
# Install and run MCP Inspector
npm -g install @modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector /path/to/rails-mcp-server
This will:
In the MCP Inspector UI, you can:
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.
switch_project with your project namesearch_tools to see available analyzersexecute_tool to invoke specific analyzersexecute_ruby with code like puts read_file('Gemfile')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.
To use with an MCP client:
For teams using a governed AI client or control plane for tool access, approvals, audit trails, and cost reporting, see Governed MCP Clients.
For security concerns, please see SECURITY.md.
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.
Copyright (c) 2025 Mario Alberto Chávez Cárdenas
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bug reports and pull requests are welcome on GitHub at https://github.com/maquina-app/rails-mcp-server.
MCP server integration for DaVinci Resolve Studio
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
A Jetbrains IDE IntelliJ plugin aimed to provide coding agents the ability to leverage intelliJ's indexing of the codeba