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 帮你省下了一次修正循环,请在 GitHub 上给它加星!

为什么 • 功能 • 快速开始 • 用法 • 工具 • 配置 • 文档

安装演示

rails-ai-context 是一个 Ruby gem,它把你的 Rails 应用变成 AI 编码助手的真实信息来源。助手不再根据训练数据猜测你的 schema、关联、路由和约定,而是直接询问你的应用:通过 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。

  • 发明一个代码库中不存在的方法。

你发现它、修复它、重新提示,然后旁边的东西又坏了。token 很便宜;真正浪费你一下午的是修正循环。这个 gem 从源头消除了猜测。

你让 AI 做...

没有它

有它

给 users 表添加 subscription_tier 列

写迁移,重复了一个已存在的列

读取实时 schema,看到 subscription_status,在迁移前询问

在控制器中调用 user.posts

猜测;运行时 NoMethodError

从模型解析出真实的关联

为新模型写测试

用 FactoryBot 搭建

检测到你的 fixture 套件并匹配它

修复一个失败的 create 动作

漏掉继承的 authenticate_user!

在动作源码中内联获取父控制器的过滤器

构建一个仪表盘页面

凭记忆发明 Tailwind 类

获取你真实的按钮/卡片/警告模式

追踪 publishable? 在哪里使用

按顺序读取 6 个文件,仍然漏掉调用者

一次调用:定义 + 源码 + 所有调用者 + 测试

追踪演示

Related MCP server: Synapse

功能

  • 45 个只读工具,涵盖 schema、模型、控制器、路由、视图、Stimulus、Turbo、jobs、services、mailers、i18n、gems、配置、测试、安全、性能等。每个答案都来自你的应用。

  • Prism AST 解析用于模型内省。每个结果都带有 [VERIFIED] 或 [INFERRED],让助手知道什么是真实信息,什么需要运行时检查。

  • 三种接入方式:通过 stdio 的 MCP、通过 HTTP 挂载在 Rails 应用内的 MCP,或任何终端中的纯 CLI。

  • 生成的上下文文件,适用于 Claude Code、Cursor、GitHub Copilot、OpenCode 和 Codex CLI,并带有每个工具在项目打开时自动检测的 MCP 配置。

  • 实时资源:rails:// 和 rails-ai-context:// URI,每次读取时都会重新内省。

  • 反幻觉规则,随每个生成的上下文文件提供,默认开启。

  • 静态层:当应用无法启动时,工具从 config/routes.rb、db/schema.rb、迁移和源文件中回答,并明确说明。

  • 适用于真实应用形态:packwerk packs、仓库内引擎、多数据库 schema 转储、Mongoid、仅 API 应用。

  • 自定义工具:在内置工具旁边注册你自己的 MCP::Tool 类,并使用捆绑的 TestHelper 测试它们。

快速开始

要求

  • Ruby 3.1 或更高

  • Rails 7.0 或更高

  • 可选:brakeman 用于 security_scan,listen 用于 watch,ripgrep 用于更快的 search_code

在 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 通道的已连接客户端都会在连接生命周期内占用一个服务器线程。开发时没问题;如果有多个客户端共享应用,请提高 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

运行一个工具

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 用于指定另一个目录,--environment ENV 用于设置 RAILS_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 一次调用即可返回定义、源码、按类型分组的全部调用方以及测试。这相当于替代了 4 到 5 次文件读取。

  • get_controllers 返回动作源码,包含继承的过滤器、强参数和渲染映射。

  • get_model_details 从 AST 返回关联、校验、作用域、枚举和宏,每一项都标记为 [VERIFIED] 或 [INFERRED]。

  • query 以超时、行数限制和列脱敏方式运行只读 SQL。read_logs 在敏感数据离开进程之前对其进行脱敏。

全部 45 个工具的参数见工具参考;实际示例见配方。

实时资源

MCP 客户端还可以将结构化数据作为资源读取。模板会在每次请求时重新内省:

URI

返回内容

rails://models/{name}

单个模型的关联、校验和模式

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

动作、继承的过滤器、强参数

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

动作源码及适用的过滤器

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

视图模板内容(已阻止路径遍历)

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

单个控制器的实时路由映射

另有 9 个静态资源:rails://schema、routes、conventions、gems、controllers、config、tests、migrations、engines。

反幻觉规则

每个生成的上下文文件(CLAUDE.md、.cursor/rules/、.github/instructions/、AGENTS.md)都附带六条规则,助手在编写代码前会先阅读这些规则:

  1. 先验证再编写。绝不引用本轮工具调用未确认的列、关联、路由、辅助方法、方法、类、局部模板或 gem。

  2. 用 [ASSUMPTION] 标记每一个假设。“我需要先检查 X”就是一个好的回答。

  3. 训练数据描述的是普通的 Rails。这个应用并不普通。当某件事感觉明显是标准做法时,仍然要查询。

  4. 每次编辑前检查继承链:继承的过滤器、concerns、includes、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 等)会显示在 Secondary databases 部分下。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 安全层和文件阻止

兼容性

支持的版本、运行层级、应用形态矩阵

故障排查

常见问题与修复

常见问题

常见问题

由一位拥有 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