RJ

raja-jamwal/rails-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

11 stars 6 forks 质量 64 趋势 18MIT

Allows AI assistants to eval and verify rails/ruby code changes at lighting-speed access without the need restart server.

概览

Point your coding agent (Cursor, Claude Code, etc.) at llms.txt and ask it to self-configure rails-mcp in your project. A Ruby gem that provides AI assistants with ruby code execution capabilities within the context of existing running application server. Think of it giving AI assistant lighting-speed access to ruby console without the need to write script, reload or restart. Works with Rails, Sinatra, Hanami, Roda, and any other Rack-based framework. The code is executed in your application's context for debugging and investigation. Used at Apollo.io against a Rails codebase with 20k+ Ruby files. 1. Learn a new codebase or code areas quickly. With your AI client and a running server, you can ask it to research while executing snippets from your actual application code. It effectively acts as an in-loop code-verification block. 2. Perform quick, preliminary investigations of customer escalations using a read-only copy of the production environment.

README

以下为原文 README 节选,完整内容请查看原文。

rails-mcp

Setting this up? Point your coding agent (Cursor, Claude Code, etc.) at llms.txt and ask it to self-configure rails-mcp in your project.

A Ruby gem that provides AI assistants with ruby code execution capabilities within the context of existing running application server. Think of it giving AI assistant lighting-speed access to ruby console without the need to write script, reload or restart.

Works with Rails, Sinatra, Hanami, Roda, and any other Rack-based framework. The code is executed in your application’s context for debugging and investigation.

YouTube Link

Used at

Used at Apollo.io against a Rails codebase with 20k+ Ruby files.

Use cases

  1. Learn a new codebase or code areas quickly. With your AI client and a running server, you can ask it to research while executing snippets from your actual application code. It effectively acts as an in-loop code-verification block.
  2. Perform quick, preliminary investigations of customer escalations using a read-only copy of the production environment. It can execute your application code, locate models, and run relevant class methods or code paths from the codebase to do preliminary root-cause analysis (RCA). Even better if your application uses an event-sourcing framework (i.e., change logs). The AI client, together with the code-execution capabilities via rails-mcp, can deliver fast preliminary RCAs.
  3. Use it for quick data analytics and export reports as CSV.

Installation

Add this line to your application’s Gemfile:

gem "rails-mcp"

Or install locally for development:

bundle install

Usage

Mounting the MCP Server

Rails (config/routes.rb):

require "rails_mcp/mcp/server"

Rails.application.routes.draw do
  mount RailsMcp::MCP::Server.new => "/mcp"
end

Rack (config.ru):

require "rails_mcp"
require "rails_mcp/mcp/server"

map "/mcp" do
  run RailsMcp::MCP::Server.new
end

Sinatra:

require "rails_mcp/mcp/server"

mount RailsMcp::MCP::Server.new, at: "/mcp"

Starting the Server

# Standalone with Rackup
bundle exec rackup -p 9292

# With Rails
bundle exec rails server

Environment-scoped mounting

This gem ships without authentication — the MCP endpoint will accept any request that reaches it. You are responsible for ensuring it is only mounted where appropriate. A typical Rails setup gates it on environment:

Rails.application.routes.draw do
  mount RailsMcp::MCP::Server.new => "/mcp" if Rails.env.development?
end
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "rails-mcp": { "url": "http://localhost:3001/mcp/rpc" } } }