Skip to main content
Glama

rails-ai-context

AIコーディングアシスタントにRailsアプリの真実を提供する

Gem Version Downloads CI MCP Registry Ruby Rails License

Claude Code Cursor GitHub Copilot OpenCode Codex CLI Any terminal

:star: このgemが修正ループを1回でも減らしてくれたら、GitHubでスターを付けてください!

なぜ • 機能 • はじめに • 使い方 • ツール • 設定 • ドキュメント

Install demo

rails-ai-context は、RailsアプリをAIコーディングアシスタントにとっての真実の情報源にするRuby gemです。スキーマ、アソシエーション、ルート、規約を学習データから推測させる代わりに、アシスタントがアプリに直接問い合わせます。MCP 経由またはCLIから実行できる45の読み取り専用ツールに加え、Claude Code、Cursor、GitHub Copilot、OpenCode、Codex CLI用の生成コンテキストファイルも提供します。

[!TIP] 必要なければGemfileに追加する必要はありません。gem install rails-ai-context を実行し、任意のRailsアプリ内で rails-ai-context init を実行するだけです。起動できないアプリでも動作します。--no-boot を指定すると、すべてのツールがソースファイルから回答します。

なぜ

あなたはアシスタントが次のようなことをするのを見たことがあるでしょう:

  • すでに存在するカラムのマイグレーションを書く。

  • アソシエーションが user.articles なのに user.posts を呼ぶ。

  • fixtureベースのテストスイートでFactoryBotを使ったテストを雛形生成する。

  • 親コントローラーから継承した before_action を見落とし、認証が失敗する理由がわからない。

  • すでに入っているgemを追加したり、入っていないgemのAPIを呼んだりする。

  • コードベースに存在しないメソッドをでっち上げる。

あなたはそれを見つけて修正し、再プロンプトし、するとその隣で別の何かが壊れます。トークンは安いですが、修正ループに午後を費やすことになります。このgemは推測を根本から排除します。

AIに依頼すること...

このgemなし

このgemあり

usersに subscription_tier カラムを追加する

マイグレーションを書き、既存のカラムを重複させる

ライブスキーマを読み、subscription_status を確認し、マイグレーション前に質問する

コントローラーで user.posts を呼ぶ

推測する。実行時に NoMethodError

モデルから実際のアソシエーションを解決する

新しいモデルのテストを書く

FactoryBotで雛形生成する

fixtureベースのテストスイートを検出し、それに合わせる

失敗するcreateアクションを修正する

継承された authenticate_user! を見落とす

アクションのソースとともに親コントローラーのフィルターをインラインで取得する

ダッシュボードページを構築する

記憶からTailwindクラスをでっち上げる

実際のボタン/カード/アラートパターンを取得する

publishable? がどこで使われているか追跡する

6つのファイルを順番に読み、それでも呼び出し元を見逃す

1回の呼び出しで:定義 + ソース + すべての呼び出し元 + テスト

Trace demo

Related MCP server: Synapse

機能

  • 45の読み取り専用ツール:スキーマ、モデル、コントローラー、ルート、ビュー、Stimulus、Turbo、ジョブ、サービス、メーラー、i18n、gem、設定、テスト、セキュリティ、パフォーマンスなど。すべての回答はアプリから取得されます。

  • Prism ASTパースによるモデル内省。各結果には [VERIFIED] または [INFERRED] が付与され、アシスタントは何が真実で何が実行時チェックを必要とするかを把握できます。

  • 3つの接続方法:stdio上のMCP、Railsアプリ内にHTTPでマウントするMCP、または任意のターミナルでのプレーンなCLI。

  • 生成コンテキストファイル:Claude Code、Cursor、GitHub Copilot、OpenCode、Codex CLI用。各ツールがプロジェクトを開いたときに自動検出するMCP設定も含まれます。

  • ライブリソース:rails:// および rails-ai-context:// URI。読み取りのたびに最新の状態を内省します。

  • 幻覚防止ルール:すべての生成コンテキストファイルに同梱され、デフォルトで有効です。

  • 静的モード:アプリが起動できない場合、ツールは config/routes.rb、db/schema.rb、マイグレーション、ソースファイルから回答し、その旨を明示します。

  • 実際のアプリ構成に対応:packwerkパック、リポジトリ内エンジン、マルチデータベーススキーマダンプ、Mongoid、API専用アプリ。

  • カスタムツール:組み込みツールの隣に独自の MCP::Tool クラスを登録し、同梱の TestHelper でテストできます。

はじめに

要件

  • Ruby 3.1以降

  • Rails 7.0以降

  • 任意:security_scan 用の brakeman、watch 用の listen、高速な search_code 用の ripgrep

Gemfileにインストール

bundle add rails-ai-context --group development
rails generate rails_ai_context:install

ジェネレーターは使用しているAIツールとMCPまたはCLIモードのどちらかを尋ね、コンテキストファイル、各ツールのMCP設定、config/initializers/rails_ai_context.rb を書き込みます。再実行しても安全です。既存のものは保持し、不足しているものを追加します。

スタンドアロンでインストール

gem install rails-ai-context
cd your-rails-app
rails-ai-context init
rails-ai-context serve

Gemfileの変更は不要です。設定は .rails-ai-context.yml に置きます。rbenv、rvm、asdf、mise、chruby、システムRubyで動作します。スタンドアロン を参照してください。

動作確認

rails ai:doctor                                  # in-Gemfile: readiness score + diagnostics
rails-ai-context doctor                          # standalone

rails 'ai:tool[schema]' table=users
rails 'ai:tool[model_details]' model=User
rails 'ai:tool[search_code]' pattern=publishable? match_type=trace

その後、AIツールでプロジェクトを開きます。書き込まれたMCP設定は開いたときに自動検出され、アシスタントは推測する代わりに rails_get_model_details を呼び出し始めます。

[!NOTE] 上記のCLIコマンドはあなたが実行するためのものです。MCPが接続されている場合、アシスタントは同じツールを自分で呼び出すため、あなたが入力する必要はありません。

使い方

stdio上のMCP

デフォルトです。各AIツールは独自の設定ファイル(.mcp.json、.cursor/mcp.json、.vscode/mcp.json、opencode.json、.codex/config.toml)を持ち、次の場所を指します:

rails ai:serve             # in-Gemfile
rails-ai-context serve     # standalone

HTTP上のMCP

サーバーをアプリ内にマウントします。ルーティング、認証、ミドルウェアを継承し、別プロセスは不要です。

# config/routes.rb
mount RailsAiContext::Engine, at: "/mcp"

クライアントを http://localhost:3000/mcp に向けます。スタンドアロンのHTTPプロセスもあります:rails-ai-context serve --transport http --port 6029。

[!WARNING] SSEチャンネルを開く接続クライアントごとに、接続中は1つのサーバースレッドが保持されます。開発には問題ありません。複数のクライアントがアプリを共有する場合は、Pumaのスレッド数を増やすか、スタンドアロンのHTTPプロセスを使用してください。

CLI

同じ45ツールを、サーバーなしで、任意のターミナルで使用できます。

rails 'ai:tool[search_code]' pattern="publishable?" match_type=trace
rails-ai-context tool schema --table users --detail full

ツール名は柔軟に解決されます:schema、get_schema、rails_get_schema はすべて機能します。ほとんどのツールは detail=summary|standard|full を受け付けます。

コマンド

Gemfile内

スタンドアロン

機能

rails ai:serve

rails-ai-context serve

MCPサーバーを起動(stdio)

rails ai:serve_http

rails-ai-context serve --transport http

MCPサーバーを起動(HTTP)

rails 'ai:tool[NAME]'

rails-ai-context tool NAME

1つのツールを実行

rails ai:tool

rails-ai-context tool --list

ツールを一覧表示

rails ai:context

rails-ai-context context

コンテキストファイルを生成

rails ai:doctor

rails-ai-context doctor

診断と準備完了スコア

rails ai:watch

rails-ai-context watch

ファイル変更時に再生成

rails 'ai:preset[NAME]'

rails-ai-context preset NAME

マルチツールプリセットを実行(architecture、debugging、migration)

アプリ読み取りコマンドで共有されるフラグ:別のディレクトリを対象にする --app-path PATH、RAILS_ENV を設定する --environment ENV、起動試行をスキップしてソースから回答する --no-boot。完全なリストは CLIリファレンス にあります。

ツール

すべてのツールは読み取り専用で、アプリから回答します。

カテゴリ

ツール

検索とトレース

search_code, get_edit_context

理解

analyze_feature, get_context, onboard

スキーマとモデル

get_schema, get_model_details, get_callbacks, get_concern

コントローラとルート

get_controllers, get_routes

ビューとフロントエンド

get_view, get_stimulus, get_partial_interface, get_turbo_map, get_frontend_stack

テストと品質

get_test_info, generate_test, validate, security_scan, performance_check

アプリ設定とサービス

get_api, get_conventions, get_config, get_gems, get_env, get_helper_methods, get_service_pattern, get_job_pattern, get_component_catalog, get_i18n, get_mailers, get_engines, get_autoload, get_active_support, get_env_config

データとデバッグ

dependency_graph, migration_advisor, search_docs, query, read_logs, diagnose, review_changes, runtime_info, session_context

初日に知っておくと便利なもの:

  • search_code を match_type=trace で使うと、定義、ソース、タイプ別にグループ化されたすべての呼び出し元、そしてテストが1回の呼び出しで返ります。これは4〜5回のファイル読み取りに相当します。

  • get_controllers は、継承されたフィルタ、strong params、レンダーマップを含むアクションソースを返します。

  • get_model_details は、ASTからアソシエーション、バリデーション、スコープ、enum、マクロを返し、それぞれに [VERIFIED] または [INFERRED] のタグが付きます。

  • query は、タイムアウト、行数制限、カラムのリダクション付きで読み取り専用SQLを実行します。read_logs は、プロセスからデータが出る前に機密データをリダクションします。

全45ツールのパラメータは ツールリファレンス に、実践例は レシピ にあります。

ライブリソース

MCPクライアントはリソースとして構造化データも読み取れます。テンプレートはリクエストごとに最新の状態をイントロスペクトします:

URI

戻り値

rails://models/{name}

1つのモデルのアソシエーション、バリデーション、スキーマ

rails-ai-context://controllers/{name}

アクション、継承されたフィルタ、strong params

rails-ai-context://controllers/{name}/{action}

適用されるフィルタ付きのアクションソース

rails-ai-context://views/{path}

ビューテンプレートの内容(パストラバーサルはブロックされます)

rails-ai-context://routes/{controller}

1つのコントローラのライブルートマップ

さらに9つの静的リソース: rails://schema, routes, conventions, gems, controllers, config, tests, migrations, engines。

幻覚防止ルール

生成されるすべてのコンテキストファイル(CLAUDE.md、.cursor/rules/、.github/instructions/、AGENTS.md)には、アシスタントがコードを書く前に読む6つのルールが同梱されています:

  1. 書く前に検証する。このターン内のツール呼び出しで確認されていないカラム、アソシエーション、ルート、ヘルパー、メソッド、クラス、パーシャル、gemを参照しないこと。

  2. すべての仮定に [ASSUMPTION] を付ける。「まずXを確認する必要があります」は良い回答です。

  3. トレーニングデータは平均的なRailsを記述しています。このアプリは平均的ではありません。何かが明らかに標準的だと感じても、とにかくクエリしてください。

  4. 編集の前に毎回継承チェーンを確認する: 継承されたフィルタ、concern、include、STIの親。

  5. 空のツール出力は情報です。「呼び出し元が0件」は調査を意味し、続行を意味しません。

  6. 古いコンテキストは嘘をつきます。書き込み後は再クエリしてください。

デフォルトでオンです。独自のルールを好む場合は config.anti_hallucination_rules = false でオフにできます。

アプリが起動できない場合

rails-ai-context はライブリフレクションのために完全なブートを試みます。ブートが失敗した場合(ENV変数の欠落、到達不能なサービス、壊れたイニシャライザ)、アプリ読み取りコマンドは停止する代わりに静的ティアにフォールバックします: ルートは config/routes.rb から、スキーマは db/schema.rb、db/structure.sql またはマイグレーションから、モデルとコントローラはソースファイルから。すべてのレスポンスには劣化の内容を示すバナーが付き、静的データには [STATIC] のタグが付き、ブートされたアプリが必要なセクションは理由とともに [UNAVAILABLE] を報告します。

--no-boot は試行を完全にスキップします。これは高速で、ブート時の副作用の影響を受けません。doctor はブート可能なアプリを必要とします。ブートの診断がその役目です。

コードは従来のレイアウト、packwerkパック(packs/*/app/*)、リポジトリ内エンジン(engines/*/app/*)、および .rails-ai-context.yml の任意の extra_app_paths にあります。マルチデータベースのスキーマダンプ(db/queue_schema.rb など)は「セカンダリデータベース」セクションに表示されます。Mongoidアプリは、空のテーブルの代わりに [UNAVAILABLE] スキーマシグナルと静的モデルデータを取得し、API専用アプリは、ビューとフロントエンドツールから黙って空白ではなく「該当なし」を取得します。詳細は 互換性 にあります。

設定

# config/initializers/rails_ai_context.rb
if defined?(RailsAiContext)
  RailsAiContext.configure do |config|
    config.ai_tools  = %i[claude cursor]   # which AI tools to generate for
    config.tool_mode = :mcp                # :mcp (default) or :cli
    config.preset    = :full               # :full (40 introspectors) or :standard (17)
  end
end

スタンドアロンインストールは .rails-ai-context.yml で同じキーを使用します。デフォルト付きのすべてのオプションは 設定 にあります。

カスタムツール

組み込みツールの隣に独自のツールを登録します:

# app/mcp_tools/rails_get_business_metrics.rb
class RailsGetBusinessMetrics < MCP::Tool
  tool_name "rails_get_business_metrics"
  description "Key business metrics for this app"

  def call(period: "week")
    MCP::Tool::Response.new([{ type: "text", text: "Users this #{period}: #{User.recent.count}" }])
  end
end

# config/initializers/rails_ai_context.rb
config.custom_tools = ["RailsGetBusinessMetrics"]

同梱のヘルパー(RSpecまたはMinitest)でテストします:

include RailsAiContext::TestHelper

response = execute_tool("business_metrics", period: "month")
assert_tool_response_includes(response, "Users")

カスタムツール を参照してください。

可観測性

すべてのMCP呼び出しは ActiveSupport::Notifications イベントを発火します:

ActiveSupport::Notifications.subscribe("rails_ai_context.tools.call") do |event|
  ms = (event.payload[:duration].to_f * 1000).round
  Rails.logger.info "[MCP] #{event.payload[:tool_name]} #{ms}ms"
end

仕組み

graph TD
    A["Your Rails app\nmodels + schema + routes + controllers + views + jobs"] -->|"40 introspectors"| B
    B["rails-ai-context\nPrism AST · cached · confidence-tagged\nstatic tier when the app can't boot"]
    B --> C["MCP server\nstdio / HTTP\n45 tools · 5 templates · 9 resources"]
    B --> D["CLI\nrake / Thor\nsame 45 tools"]
    B --> E["Context files\nCLAUDE.md · .cursor/rules/ · .github/instructions/ · AGENTS.md"]

    style A fill:#4a9eff,stroke:#2d7ad4,color:#fff
    style B fill:#2d2d2d,stroke:#555,color:#fff
    style C fill:#0984e3,stroke:#0770c2,color:#fff
    style D fill:#00cec9,stroke:#00b5b0,color:#fff
    style E fill:#a29bfe,stroke:#8c83f0,color:#fff

内部、イントロスペクターリスト、ASTエンジンは アーキテクチャ と イントロスペクター にあります。

ドキュメント

クイックスタート

5分でセットアップ

ガイド

すべてのコマンド、パラメータ、オプション

ツールリファレンス

すべてのパラメータ付きの全45ツール

レシピ

エンドツーエンドの実践ワークフロー

AIツールセットアップ

Claude Code、Cursor、Copilot、OpenCode、Codex CLI、HTTPトランスポート

CLIリファレンス

コマンド、フラグ、引数の構文

スタンドアロン

Gemfileエントリなしで使用

設定

デフォルト付きのすべてのオプション

カスタムツール

独自のツールの構築とテスト

アーキテクチャ

システム設計と内部構造

イントロスペクター

全40のイントロスペクターとASTエンジン

セキュリティ

SQLセーフティレイヤーとファイルブロッキング

互換性

サポートバージョン、動作ティア、アプリ形状マトリックス

トラブルシューティング

一般的な問題と修正

FAQ

よくある質問

本番環境で10年以上の経験を持つRails開発者によって構築されました。時間の節約になったなら、プロジェクトへのスポンサー をご検討ください。

Available Tools

35 tools
rails_analyze_featureA
Read-onlyIdempotent

Full-stack feature analysis: models, controllers, routes, services, jobs, views, Stimulus controllers, tests, related models, callbacks, concerns, and environment dependencies. Use when: exploring an unfamiliar feature, onboarding to a codebase area, or tracing a feature across layers. Pass feature:"authentication" or feature:"User" for broad cross-cutting discovery.

Inputs: feature (required).

rails_dependency_graphA
Read-onlyIdempotent

Generates a dependency graph showing how models connect through their associations. Output as Mermaid diagram syntax or plain text. Use when: understanding feature architecture, tracing data flow, planning refactors. Key params: model (center graph on model), depth (1-3), format (mermaid/text).

Inputs: depth, model, format, show_sti, +1 more.

rails_diagnoseA
Read-only

One-call error diagnosis: parses the error, classifies it, gathers controller/model/schema context, shows recent git changes, pulls relevant logs, and suggests a fix. Use when: you hit an error and need to understand why. Key params: error (required - paste the error message), file, line, action (controller#action).

Inputs: error (required), file, line, action.

rails_generate_testA
Read-onlyIdempotent

Generate test scaffolding that matches your project's actual test patterns - framework, factories, assertion style. Use when: adding tests for a model, controller, or service. Generates copy-paste-ready test files. Key params: model (e.g. 'User'), controller (e.g. 'PostsController'), file (e.g. 'app/services/foo.rb').

Inputs: file, type, model, controller.

rails_get_callbacksA
Read-onlyIdempotent

Get ActiveRecord model callbacks grouped by type, in Rails event order: before/after/around for validation, save, create, update, destroy. Use when: understanding side effects, debugging callback chains, or checking what happens on save/create/destroy. Specify model:"User" for one model's callbacks. detail:"full" includes callback method source code. The list is what the model, its base classes and its concerns declare, and within one type the order is the order Rails runs them, a before_ or around_ callback with prepend: true first, and after_commit in the order the app's setting gives.

Inputs: model, detail.

rails_get_component_catalogA
Read-onlyIdempotent

Returns ViewComponent and Phlex component catalog: props, slots, previews, which views render each component. Use when: building views with components, understanding component API, finding reusable components. Key params: component (filter by name), detail level.

Inputs: limit, detail, offset, component.

rails_get_concernA
Read-onlyIdempotent

Get ActiveSupport::Concern details: public methods, included modules, and which models/controllers include it. Use when: understanding shared behavior, checking concern interfaces, or finding where a concern is used. Specify name:"Searchable" for full detail, or omit for a list of all concerns. Filter with type:"model" or type:"controller".

Inputs: name, type, detail.

rails_get_configA
Read-onlyIdempotent

Get the app's configuration, one section per call. section: app (default: database, auth, assets, cache, session, queue, Action Cable, middleware, initializers), gems (notable gems by category), frontend (JS framework, build tool, TypeScript, package manager), api (serializers, GraphQL, versioning, CORS, rate limiting, pagination), engines (mounted engines and Rack apps), conventions (architecture and patterns), autoload (Zeitwerk paths, inflections), active_support (concerns, notifications, on_load hooks), env (names of environment variables and credentials keys), env_config (config/environments/*.rb per environment), i18n (locales, locale files, coverage).

Inputs: limit, detail, locale, offset, +3 more.

rails_get_contextA
Read-onlyIdempotent

Get cross-layer context in a single call - combines schema, model, controller, routes, views, stimulus, and tests. Use when: you need full context for implementing a feature or modifying an action. Specify controller:"PostsController" action:"create" to get everything for that action in one call.

Inputs: model, action, feature, include, +1 more.

rails_get_controllersA
Read-onlyIdempotent

Get controller details: actions, before_action filters, strong params, and parent class. Use when: adding/modifying controller actions, checking what filters apply, or reading action source code. Filter with controller:"PostsController", drill into action:"create" for source code with line numbers.

Inputs: limit, action, detail, offset, +1 more.

rails_get_edit_contextA
Read-onlyIdempotent

Get targeted code context for surgical edits: returns matching lines with surrounding code and line numbers. Use when: you need to edit a specific method or section without reading the entire file. Requires file:"app/models/user.rb" and near:"def activate" (or line:42) to locate the code region.

Inputs: file (required), line, near, context_lines.

rails_get_helper_methodsA
Read-onlyIdempotent

Get Rails helper modules: method signatures, the view helpers controllers declare with helper_method, framework helpers in use, and which views call each helper. Use when: finding available view helpers, checking what helper methods exist, or understanding shared view logic. Specify helper:"ApplicationHelper" for full detail, or omit to list all helpers with method counts.

Inputs: limit, detail, helper, offset.

rails_get_job_patternA
Read-onlyIdempotent

Analyze background jobs in app/jobs/, app/workers/ and app/sidekiq/: queues, retries, perform signatures, guards, and what they call. Use when: understanding job infrastructure, adding a new job, or tracing async workflows. Specify job:"SendWelcomeEmail" for full detail, or omit to list all jobs with queue names and retry config.

Inputs: job, detail.

rails_get_mailersA
Read-onlyIdempotent

Get ActionMailer mailers: every mailer class with its delivery actions, delivery method, own defaults, layout and callbacks, template formats per action and preview class, the queue deliver_later uses, interceptors and observers, and the Action Mailbox mailboxes with the routing that sends inbound mail to each. Use when: adding an email, checking which mailer sends what, or finding the action to preview/test. Filter with mailer:"UserMailer". Omit for all mailers.

Inputs: limit, mailer, offset.

rails_get_model_detailsA
Read-onlyIdempotent

Get ActiveRecord model details: associations, validations, scopes, enums, callbacks, concerns. Use when: understanding model relationships, adding validations, checking existing scopes/callbacks. Specify model:"User" for full detail, or omit for a list. detail:"full" shows association lists.

Inputs: limit, model, detail, offset.

rails_get_partial_interfaceA
Read-onlyIdempotent

Analyze a partial's interface: local variables it expects, where it's rendered from, and what methods are called on each local. Use when: rendering a partial, understanding what locals to pass, or refactoring partial dependencies. Specify partial:"shared/status_badge" to see its full interface. Supports both underscore-prefixed and non-prefixed names.

Inputs: partial (required), detail.

rails_get_routesA
Read-onlyIdempotent

Get routing table: HTTP verbs, paths, controller#action, route names. Use when: building links/redirects, checking available endpoints, verifying route helpers exist. Filter with controller:"users", use detail:"summary" for counts or detail:"full" for route names.

Inputs: limit, detail, offset, app_only, +1 more.

rails_get_schemaA
Read-onlyIdempotent

Get database schema: tables, columns, types, indexes, foreign keys. Use when: writing migrations, checking column types/constraints, understanding table relationships. Filter to one table with table:"users", control detail with detail:"summary"|"standard"|"full".

Inputs: limit, table, detail, format, +1 more.

rails_get_service_patternA
Read-onlyIdempotent

Analyze service objects in app/services/, app/interactions/ and app/interactors/: patterns, interfaces, dependencies, and side effects. Use when: understanding how services are structured, adding a new service, or tracing what a service does. Specify service:"CreateOrder" for full detail, or omit to detect the common pattern and list all services.

Inputs: detail, service.

rails_get_stimulusA
Read-onlyIdempotent

Get Stimulus controllers: targets, values, actions, outlets, classes. Use when: wiring up data-controller attributes in views, adding targets/values, or checking existing Stimulus behavior. Filter with controller:"filter-form" for one controller's full API, or list all with detail:"summary".

Inputs: limit, detail, offset, controller.

rails_get_test_infoA
Read-onlyIdempotent

Get test infrastructure and existing test files: framework, factories, fixtures, CI config, coverage setup. Use when: writing new tests, checking what factories/fixtures exist, or finding the test file for a model/controller. Use model:"User" or controller:"Posts" to see existing tests. detail:"full" lists factory and fixture names.

Inputs: model, detail, controller.

rails_get_turbo_mapA
Read-onlyIdempotent

Map Turbo Streams and Frames across the app: model broadcasts, channel subscriptions, frame tags, and DOM target mismatches. Use when: debugging Turbo Stream delivery, adding real-time updates, or understanding broadcast→subscription wiring. Filter with stream:"notifications" for a specific stream, or controller:"messages" for one controller's Turbo usage.

Inputs: detail, stream, controller.

rails_get_viewA
Read-onlyIdempotent

Get view templates, partials, and their Stimulus/partial references. Use when: editing ERB views, checking which partials a page renders, or finding Stimulus controller usage. Filter with controller:"posts" for all views, or path:"posts/index.html.erb" for one file's content.

Inputs: path, detail, controller.

rails_migration_advisorA
Read-onlyIdempotent

Generates migration code for schema changes. Given an action (add_column, remove_column, rename_column, add_index, add_association, change_type), generates the migration, flags irreversible operations, and shows affected models. Use when: adding fields, changing schema, planning database changes. Key params: action, table, column, type, new_name (for rename_column).

Inputs: table (required), action (required), type, column, +2 more.

rails_onboardA
Read-onlyIdempotent

Get a narrative walkthrough of the Rails application - stack, data model, authentication, key flows, background jobs, frontend, testing, getting started instructions, and the app's custom rake tasks, generators and Railties. Use when: first encountering a project, onboarding a new developer, or orienting an AI agent. Key params: detail (summary/standard/full).

Inputs: detail.

rails_performance_checkA
Read-onlyIdempotent

Static analysis for Rails performance anti-patterns: N+1 query risks, missing counter_cache, Model.all in controllers, missing foreign key indexes, eager loading candidates. Use when: reviewing code for performance, before deploying, or investigating slow pages. Key params: model (filter by model), category (filter by issue type), detail level.

Inputs: model, detail, category.

rails_queryA
Read-only

Execute read-only SQL queries against the database. Use when: checking data patterns, verifying migrations, debugging data issues. Safety: SQL validation + database-level READ ONLY + statement timeout + row limit. Development/test only by default. Key params: sql (SELECT only), limit (default 100), format (table/csv).

Inputs: sql (required), limit, format, explain, +1 more.

rails_read_logsA
Read-only

Read recent log entries with level filtering and sensitive data redaction. Use when: debugging errors, checking recent activity, investigating failed requests. Key params: lines (default 50), level (ERROR/WARN/INFO/DEBUG/FATAL/all), file, search. Search matches the redacted line, so a filtered value cannot be searched for.

Inputs: file, level, lines, search.

rails_review_changesA
Read-only

PR/commit review context: shows changed files with relevant schema/model/route context per file, detects warnings (missing indexes, removed validations, changed associations, new routes without tests). Use when: reviewing changes before merging, understanding what a commit changed and its impact. Key params: ref (default 'HEAD' for uncommitted, or 'main', 'HEAD~3', commit SHA).

Inputs: ref, files.

rails_runtime_infoA
Read-only

Live runtime state: database connection pool, table sizes, pending migrations, cache stats, job queues. Use when: debugging performance, checking database health, verifying deployment state, or understanding infrastructure. Key params: detail (summary/standard/full), section (database/cache/jobs/connections).

Inputs: detail, section, database.

rails_search_codeA
Read-onlyIdempotent

Search the Rails codebase with smart modes. Use match_type:"trace" to see where a method is defined, who calls it, and what it calls - in one call. Use match_type:"definition" for definitions only, "call" for call sites only, "class" for class/module definitions. Requires pattern:"method_name". Narrow with path:"app/models" and file_type:"rb".

Inputs: pattern (required), path, limit, offset, +6 more.

rails_search_docsA
Read-onlyIdempotent

Search a bundled index of the Rails guides and the Turbo, Stimulus and Hotwire Native handbooks. Use when: you need to reference Rails conventions, API details, or best practices. Pass query:"active record callbacks" to find matching topics. Filter with source:"guides", "turbo", "stimulus" or "hotwire". Set fetch:true to retrieve full content from GitHub (cached 24h).

Inputs: query (required), fetch, limit, source.

rails_security_scanA
Read-onlyIdempotent

Run Brakeman static security analysis on Rails app. Use when: after editing controllers/models/views, reviewing code for vulnerabilities, or before deploying. Filter with files:["app/controllers/users_controller.rb"], set confidence:"high" to reduce noise.

Inputs: files, checks, detail, confidence.

rails_session_contextB
Read-only

Track what you've already queried to avoid redundant calls. Use action:"status" to see what tools you've called, action:"summary" for a compressed recap, action:"reset" to clear session, or mark:"tool:param" to record a query. Helps maintain focus during long development sessions.

Inputs: mark, action.

rails_validateA
Read-onlyIdempotent

Validate syntax and semantics of Ruby, ERB, and JavaScript files in a single call. Use when: after editing files, before committing, to catch syntax errors and Rails-specific issues. Pass files:["app/models/user.rb"], use level:"rails" for semantic checks (missing partials, route helpers, column refs in validates/permit/callbacks).

Inputs: files (required), level.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 35 tools

    Disambiguation3/5

    Most tools map to a distinct Rails artifact (schema, routes, callbacks, mailers, jobs, stimulus, turbo), but several boundaries blur: rails_analyze_feature and rails_get_context both promise 'full-stack context in one call' across the same layers, and rails_get_context vs rails_get_edit_context differ only by a word while doing very different things. rails_onboard also overlaps with rails_get_config, and rails_get_model_details subsumes rails_get_callbacks. Descriptions are detailed enough that an agent can usually recover, but misselection is a real risk.

    Naming Consistency4/5

    All names use a uniform rails_ prefix and snake_case verb_noun form, which is highly readable. The only inconsistency is the verb layer: a large get_* family coexists with bare verbs (analyze_feature, search_code, review_changes, query, validate, onboard), so the 'get' prefix is applied unevenly. Predictable overall, minor deviation.

    Tool Count3/5

    35 tools is heavy, sitting above the comfortable 3-15 band, and a few are redundant (analyze_feature vs get_context, session_context as a meta-bookkeeping utility). However, the server targets an entire Rails application surface, so most tools do correspond to a genuine distinct artifact type. Borderline over-scoped rather than gratuitous.

    Completeness4/5

    Coverage is unusually broad: schema, models, controllers, routes, views, partials, helpers, services, jobs, mailers, Stimulus, Turbo, components, tests, migrations, config, logs, security and performance, plus read-only SQL and docs search. Minor gaps remain around authorization policies (Pundit/CanCan), ActiveStorage/ActionText attachments, and API/GraphQL schema introspection. No dead ends for the core read-and-understand workflow.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides structural code intelligence via 26 MCP tools, enabling AI assistants to query code symbols, dependencies, and call graphs accurately without file-pasting.
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI coding agents to efficiently explore codebases by providing structural outlines, module digests, symbol bodies, and AST-aware grep via MCP.
      4
      13 npm
      1
      MIT