Rails Console MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Rails Console MCP Servershow me the User model schema and associations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Rails Console MCP Server
A generic Model Context Protocol (MCP) server that provides AI models (Claude Desktop, Cursor, Codex, etc.) with read-only access to any Rails application's models, database schema, and data.
Features
π Works with ANY Rails app - Configure via
config.jsonπ‘οΈ Read-only by default - Blocks DDL/DML operations
π 8 powerful tools for model introspection and querying
β‘ Token efficient - Returns structured JSON, not verbose text
π Hot reload - Reload Rails code without restarting
π Environment-aware - Production requires explicit opt-in
Related MCP server: mcp-business-data-server
Quick Start
1. Install Dependencies
cd /home/himanshu/projects/rails-console-mcp
npm install
npm run build2. Configure
Copy the example config and edit for your Rails app:
cp config.example.json config.json
# Edit config.json with your Rails app path{
"railsAppPath": "/home/himanshu/projects/Transcripto",
"environment": "development",
"readOnly": true,
"maxRows": 100,
"queryTimeoutSeconds": 30
}3. Configure Your AI Tool
Claude Desktop (~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"rails-console": {
"command": "node",
"args": ["/home/himanshu/projects/rails-console-mcp/dist/index.js"]
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"rails-console": {
"command": "node",
"args": ["/home/himanshu/projects/rails-console-mcp/dist/index.js"]
}
}
}VS Code (.vscode/mcp.json):
{
"servers": {
"rails-console": {
"type": "stdio",
"command": "node",
"args": ["/home/himanshu/projects/rails-console-mcp/dist/index.js"]
}
}
}4. Restart Your AI Tool
Restart Claude Desktop / Cursor / VS Code to load the MCP server.
Available Tools
Tool | Description |
| List all models with summary metadata (table name, column/association counts) |
| Full model definition: columns, associations, validations, scopes, enums, callbacks |
| Raw database table schema (columns, indexes, FKs, PKs) |
| Safe read-only SELECT queries with automatic LIMIT |
| Reload Rails code (development only) |
| Row counts for models with optional WHERE clause |
| Find models by name/table pattern (regex) |
| Graph of model relationships (nodes/edges) |
Architecture
βββββββββββββββββββββββ stdio (JSON-RPC) ββββββββββββββββββββββββ
β AI Tool β ββββββββββββββββββββββββΊ β Node.js MCP Server β
β (Claude, Cursor) β β @modelcontextprotocolβ
βββββββββββββββββββββββ ββββββββββββ¬ββββββββββββ
β
spawns Ruby sidecar
β
βΌ
ββββββββββββββββββββββββ
β Ruby Sidecar β
β (loads Rails env) β
β - ActiveRecord β
β - All model metadataβ
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Rails App β
β (any path) β
β config.railsAppPath β
ββββββββββββββββββββββββThe Ruby sidecar loads the full Rails environment (config/environment.rb) giving access to:
All ActiveRecord models with associations, scopes, validations, callbacks, enums
Database schema via
ActiveRecord::Base.connectionSafe query execution through ActiveRecord
Configuration Reference
Option | Type | Default | Description |
| string | required | Absolute path to Rails app root |
| string |
| Rails env to load |
| boolean |
| Block DDL/DML operations |
| number |
| Max rows per query |
| number |
| Query timeout |
| string[] |
| Allowed Rails envs |
| string |
| Ruby executable path |
| number |
| Sidecar startup timeout |
| string |
| Log level |
Security
Read-only by default - Only SELECT queries allowed
Production protection - Requires explicit
allowedEnvironmentsconfigQuery validation - Blocks DDL/DML keywords
Parameterized queries - Use
paramsarray for safe interpolationRow limits - Automatic LIMIT enforcement
Development
# Watch mode for development
npm run dev
# Run tests
npm test
# Type check
npx tsc --noEmitExample Usage
Once configured, ask your AI tool:
"List all models in my Rails app" "Show me the schema for the Transcription model including associations" "How many transcriptions were created this week?" "Show me the association graph for User, Transcription, and Speaker" "Run a query to find all transcriptions with status 'completed'"
Requirements
Node.js 18+
Ruby 3.0+ (matching your Rails app)
Rails 6.0+ (tested with Rails 8)
Bundler installed in target Rails app
License
MIT
This server cannot be deployed
Maintenance
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.
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Find, vet, and run MCP tools through a secure audited gateway with prompt-injection risk scoring
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
- 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
- AlicenseNot gradedqualityAmaintenanceExposes every generated CRUD service to LLM clients such as Claude, ChatGPT, or Cursor through discoverable MCP tools for create, update, and list actions plus read-only resources, so models can query and manipulate data without raw HTTP calls. It runs alongside the same codebase's REST endpoints, letting clients and AI share one data layer.MIT
- AlicenseAqualityAmaintenanceEnables AI agents to inspect database schemas and run strictly read-only SQL queries with guardrails against destructive statements, multi-statement chaining, and unbounded scans. Supports SQLite natively and PostgreSQL optionally.4MIT