Get the FREE Ultimate OpenClaw Setup Guide →

mcp -ssh-rails-runner

MCP server that facilitates an SSH connection to a deployed Rails app so you can run Rails REPL commands

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install dependencies and build:
npm install
npm run build
  1. 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"
  1. 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
  1. 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

Sponsor this space

Reach thousands of developers