38 MCP tools that give AI agents live access to your Rails schema, models, routes & conventions.
All commands available from the terminal.
| Context | Command prefix | Example |
|---|---|---|
| In-Gemfile (Rake) | rails ai: |
rails 'ai:tool[schema]' table=users |
| Standalone (Thor) | rails-ai-context |
rails-ai-context tool schema --table users |
Both provide the same 38 tools and functionality.
serveStart the MCP server.
rails ai:serve # stdio (default)
rails-ai-context serve # stdio (default)
rails-ai-context serve --transport http --port 6029 # HTTP transport
| Option | Default | Description |
|---|---|---|
--transport |
stdio |
stdio or http |
--port |
6029 |
HTTP listen port |
toolRun any of the 38 MCP tools from the terminal.
# Rake syntax
rails 'ai:tool[schema]' table=users detail=full
rails 'ai:tool[search_code]' pattern="can_cook?" match_type=trace
rails 'ai:tool[model_details]' model=User
# Thor syntax
rails-ai-context tool schema --table users --detail full
rails-ai-context tool search_code --pattern "can_cook?" --match-type trace
rails-ai-context tool model_details --model User
| Option | Description |
|---|---|
--list |
List all available tools |
--json |
Output as JSON |
All of these resolve to the same tool:
rails 'ai:tool[schema]'
rails 'ai:tool[get_schema]'
rails 'ai:tool[rails_get_schema]'
Resolution order: exact match → rails_ prefix → rails_get_ prefix → get_ prefix.
contextGenerate static context files.
rails ai:context # All configured formats
rails ai:context:claude # Claude only
rails ai:context:cursor # Cursor only
rails ai:context:copilot # Copilot only
rails ai:context:opencode # OpenCode only
rails ai:context:json # JSON export
rails-ai-context context # All
rails-ai-context context --format claude # Specific format
| Option | Default | Description |
|---|---|---|
--format |
all configured | claude, cursor, copilot, opencode, codex, json, all |
doctorRun 23 diagnostic checks and report AI readiness score.
rails ai:doctor
rails-ai-context doctor
Checks include: schema existence, pending migrations, model files, routes, MCP config validity, introspector health, ripgrep availability, Prism gem, Brakeman gem, listen gem, gitignore security, auto_mount security, schema size, view count, and more.
watchWatch for file changes and auto-regenerate context files.
rails ai:watch
rails-ai-context watch
Requires the listen gem. Watches app/, config/, db/, lib/tasks/.
init (standalone only)Interactive setup for standalone mode.
rails-ai-context init
Asks which AI tools to configure and whether to use MCP or CLI mode. Creates .rails-ai-context.yml and MCP config files.
versionrails-ai-context version
inspectPrint introspection summary as JSON.
rails-ai-context inspect
| Task | Description |
|---|---|
rails ai:context |
Generate context for all configured formats |
rails ai:context:claude |
Generate Claude context |
rails ai:context:cursor |
Generate Cursor context |
rails ai:context:copilot |
Generate Copilot context |
rails ai:context:opencode |
Generate OpenCode context |
rails ai:context:json |
Generate JSON export |
rails ai:serve |
Start MCP server (stdio) |
rails ai:tool |
List tools or run a tool |
rails ai:doctor |
Run diagnostics |
rails ai:watch |
Watch mode |
rails ai:setup |
Interactive setup (alternative to generator) |
rails 'ai:tool[tool_name]' key=value key2=value2
table=usersexplain=true or explain=falsedetail=fullpattern="has_many :posts"rails-ai-context tool tool_name --key value --key2 value2
--table users or --table=users--explain (true) or --no-explain (false)--detail full--pattern "has_many :posts"Add --json for machine-readable output:
rails-ai-context tool schema --table users --json
rails 'ai:tool[schema]' table=users
rails 'ai:tool[search_code]' pattern="process_payment" match_type=trace
rails 'ai:tool[analyze_feature]' feature=billing
rails ai:doctor
rails ai:context