Rails Console MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Rails Console MCP
An MCP server that starts a real bin/rails c process and keeps it warm for the lifetime of the MCP connection. Calls share the same console session, so Ruby variables and objects remain available across steps:
# First tool call
a = User.last
# Later tool call, in the same Rails console
a.statusThe MCP server and package are JavaScript. It uses node-pty to run the Rails app's existing console; it does not ship or require a Ruby sidecar file. The target Rails application still needs its normal Ruby, Bundler, and gems installed.
Requirements
Node.js 18 or newer
macOS or Linux
A Rails app with
bin/rails crunnable from its rootThe app's Ruby/Bundler toolchain available to the MCP process
Related MCP server: rails-ai-context
Install from npm and connect Claude Code
With Node.js 18 or newer and npm installed, register the published package as a Claude Code MCP server. Replace the app path with the absolute path to your Rails app:
claude mcp add -s user rails-console \
-e RAILS_CONSOLE_MCP_CWD=/absolute/path/to/rails/app \
-- npx -y rails-console-mcpnpx downloads and runs the package from npm; a separate global install is not required. If you prefer a global install, run npm install -g rails-console-mcp, then use -- rails-console-mcp in the Claude command above.
Check that Claude Code can start the server:
claude mcp listIn Claude Code, use rails_eval with 1 + 1 to boot the console. The first call may take a few minutes; later calls reuse the warm process. If Claude Code cannot find the correct Ruby installation, pass its Ruby/Bundler paths with another -e PATH=... option when adding the server, or set RAILS_CONSOLE_MCP_COMMAND to an app-specific launch command. If claude mcp list shows duplicate rails-console entries in different scopes, remove the stale one with claude mcp remove rails-console -s project or -s user as appropriate.
Install from npm and connect Codex
Register the npm package as a global Codex MCP server, replacing the app path with the absolute path to your Rails app:
codex mcp add rails-console \
--env RAILS_CONSOLE_MCP_CWD=/absolute/path/to/rails/app \
-- npx -y rails-console-mcpnpx downloads and runs the package from npm; a separate global install is not required. If you prefer a global install, run npm install -g rails-console-mcp, then use -- rails-console-mcp in the Codex command above. Check the registration with codex mcp get rails-console or codex mcp list. Start a new Codex session and call rails_status to verify the MCP tool is available; call rails_eval with 1 + 1 to boot the Rails console. Codex may ask you to approve MCP tool calls, depending on your approval settings.
If Codex cannot find the correct Ruby installation, add its Ruby/Bundler paths with another --env PATH=... option or set RAILS_CONSOLE_MCP_COMMAND with --env to an app-specific launch command.
Install from npm and connect Cursor
For project-specific setup, create .cursor/mcp.json in your Rails app and replace the example path with the app's absolute path:
{
"mcpServers": {
"rails-console": {
"command": "npx",
"args": ["-y", "rails-console-mcp"],
"env": {
"RAILS_CONSOLE_MCP_CWD": "/absolute/path/to/rails/app"
}
}
}
}Cursor downloads and runs the package from npm through npx; a separate global install is not required. If you prefer a global install, set "command": "rails-console-mcp" and "args": [] after running npm install -g rails-console-mcp. Restart or reload the project in Cursor, then open Settings → Tools & MCP and check that rails-console is enabled. Ask Cursor to call rails_status to verify it can use the tool, then call rails_eval with 1 + 1 to boot Rails. For more details, see Cursor's MCP documentation.
If Cursor cannot find the correct Ruby installation, add a PATH entry under env with the Ruby/Bundler paths, or set RAILS_CONSOLE_MCP_COMMAND there to an app-specific launch command.
Automated npm publishing
Every push to main runs the tests, increments the patch version from the latest npm release, publishes it, and commits the new version in package.json and package-lock.json back to main. Before the first publish, configure npm trusted publishing for the himanshukale36/rails-console-mcp repository and the ci.yml workflow, with direct npm publish allowed. See npm's trusted publishing setup.
Tools
rails_eval: evaluate Ruby in the persistent Rails console. Capturesputsoutput and the last expression's inspected value. Supports multiline code and heredocs.rails_tables: list database tables with optional regex filtering.rails_schema: inspect a table's columns, indexes, primary key, and foreign keys.rails_models: find model classes and their associations.rails_model_details: inspect one model's associations, detectable named scopes, and directly defined class and instance methods, including visibility, parameters, and source locations. Rails does not provide a stable public API to enumerate scopes, so dynamic scopes may not be listed.rails_status: inspect console state and startup configuration.rails_reload: reload app code in the warm console.rails_restart: restart the underlying Rails console.
rails_eval runs arbitrary Ruby with the Rails app's permissions. Database writes and other side effects are possible. Use a development or test app you trust; do not point this tool at production.
Configuration
Environment variable | Default | Purpose |
|
| Rails app root |
|
| Console launch command |
|
| Rails environment |
| none | Pass |
The process starts on the first rails_eval call rather than during MCP startup. This lets the server connect promptly while the Rails app boots only when needed.
If Rails fails to boot (for example, because gems are missing), rails_eval now reports the detected cause and the relevant bundle install --gemfile ... command. rails_status retains the last boot error so it can be inspected after a failed startup.
Development
npm install
npm testRun an end-to-end smoke check against a Rails app with:
RAILS_CONSOLE_MCP_CWD=/absolute/path/to/rails/app npm run smokeTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
MCP gateway: one connection for your AI apps, with tool policies, PII redaction and audit logs.
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI tools to understand a database, inspect schema, and run safe SELECT queries with SQL guardrails, plus optional codebase reading.MIT
- AlicenseAqualityBmaintenanceLets AI coding agents ask a Rails app about itself: 35 read-only tools answer from the schema, models, routes, controllers, views, jobs and conventions, over MCP or the command line, even when the app cannot boot.635186MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to perform read-only introspection of Symfony applications, exposing routes, controllers, services, entities, database schema, migrations, logs, and more via MCP tools.560 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients such as Claude, ChatGPT and Cursor to answer business questions about sales, customers, orders and spreadsheets in natural language by reading live Postgres/SQLite databases and Google Sheets without exporting files or gaining write access. Guardrails include AST-based read-only SQL validation, read-only database roles, row/byte caps with pagination, PII masking, bearer-token auth for remote HTTP use, and a full JSONL audit log of every tool call.MIT