mcp -ssh-rails-runner
MCP server that facilitates an SSH connection to a deployed Rails app so you can run Rails REPL commands
claude mcp add --transport stdio tadasant-mcp-server-ssh-rails-runner npx mcp-server-ssh-rails-runner \ --env SSH_HOST="your.remote.host" \ --env SSH_USER="your_ssh_user" \ --env RAILS_WORKING_DIR="/path/to/rails/app/root" \ --env SSH_PRIVATE_KEY_PATH="your_SSH_PRIVATE_KEY_PATH" \ --env PROJECT_NAME_AS_CONTEXT="Name that shows up in tool descriptions to help the LLM describe what kind of Rails project we're working with." \ --env CODE_SNIPPET_FILE_DIRECTORY="/path/to/store/code/snippets/locally"
How to use
This MCP server enables secure remote execution of Rails console commands over SSH. It supports a read-only workflow and controlled mutations. You can prepare code snippets that will be reviewed before execution, execute read-only operations to inspect data, or perform approved mutations with a explicit user confirmation. The server integrates with tools for loading Rails model context (e.g., via Cursor Composer), then uses prepare_code_snippet to save your Ruby code, followed by execute_code_snippet_read_only for safe evaluation or execute_code_snippet_mutate for actual mutations after review. The workflow is designed to minimize risk by separating preparation, review, and execution while still enabling powerful remote Rails operations.
How to install
Prerequisites:
- Node.js and npm installed on your machine
- Access to the remote Rails environment via SSH (SSH_HOST, SSH_USER, SSH_PRIVATE_KEY_PATH)
Installation steps:
- Install dependencies and build:
npm install
npm run build
- Configure environment variables for your environment (example shown in the README):
# Example environment configuration (values should be replaced with real ones)
export SSH_HOST=your.remote.host
export SSH_USER=your_ssh_user
export SSH_PRIVATE_KEY_PATH=path/to/your/private/key
export RAILS_WORKING_DIR=/path/to/rails/app
export PROJECT_NAME_AS_CONTEXT="Name of Rails project for context in tool descriptions"
export CODE_SNIPPET_FILE_DIRECTORY="/path/to/store/code/snippets/locally"
- Run via npx (as shown in the configuration example) or install the package globally if you prefer:
# Using the MCP server via npx (per README example)
npx mcp-server-ssh-rails-runner
- Verify the MCP server is accessible through your MCP client (e.g., Claude Desktop) using the provided mcpServers configuration.
Additional notes
Tips and considerations:
- SECURITY: Only connect to trusted SSH endpoints. Always review code saved by prepareCodeSnippet before executing any mutation.
- If CODE_SNIPPET_FILE_DIRECTORY is not provided, snippets are stored in a temporary directory (e.g., /tmp/mcp-ssh-rails-runner-code-snippets).
- PROJECT_NAME_AS_CONTEXT is optional but helps describe the Rails project context in tool descriptions.
- Ensure SSH keys have appropriate permissions and that the remote Rails app is accessible from the SSH host.
- The server offers two mutation paths: read-only (safer) and mutate (danger zone). Use read-only for inspections and dry-run mutations before applying changes.
- RAILS_WORKING_DIR must point to the root of the Rails application on the remote host to ensure commands execute in the correct context.
Related MCP Servers
iterm
A Model Context Protocol server that executes commands in the current iTerm session - useful for REPL and CLI assistance
mcp
Octopus Deploy Official MCP Server
furi
CLI & API for MCP management
editor
MCP Server for Phaser Editor
DoorDash
MCP server from JordanDalton/DoorDash-MCP-Server
mcp
MCP сервер для автоматического создания и развертывания приложений в Timeweb Cloud