Skip to main content
Glama
tadasant

MCP Server: SSH Rails Runner

by tadasant

MCP 服务器:SSH Rails Runner

一个 MCP 服务器,支持通过 SSH 安全地远程执行 Rails 控制台命令。该服务器提供用于在已部署的 Rails 环境中执行只读操作和精心管理的变更的工具。

这非常适合 Cursor。您可以使用 Cursor Composer 导入 Rails 模型文件作为上下文,然后使用execute_read_only 、 dry_run_mutate和execute_mutate工具对数据库进行更改。无需费力地浏览复杂的管理界面即可完成数据整理和分析。

例子

例子

Related MCP server: SSH Read-Only MCP Server

特征

  • 通过 SSH 执行远程 Rails 控制台

  • 安全的只读操作

  • 突变的试运行能力

  • 执行已批准的突变

  • 代码片段的资源管理

安装

npm install
npm run build

配置

设置以下环境变量:

SSH_HOST=your.remote.host
SSH_USER=your_ssh_user
SSH_PRIVATE_KEY_PATH=your_SSH_PRIVATE_KEY_PATH
RAILS_WORKING_DIR=/path/to/rails/app

与 Claude Desktop 一起使用

添加到您的 Claude Desktop 配置:

{
  "mcpServers": {
    "ssh-rails-runner": {
      "command": "npx",
      "args": ["mcp-server-ssh-rails-runner"],
      "env": {
        "SSH_HOST": "your.remote.host",
        "SSH_USER": "your_ssh_user",
        "SSH_PRIVATE_KEY_PATH": "your_SSH_PRIVATE_KEY_PATH",
        "RAILS_WORKING_DIR": "/path/to/rails/app/root",
        "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.",
        "CODE_SNIPPET_FILE_DIRECTORY": "/path/to/store/code/snippets/locally"
      }
    }
  }
}

如果未提供CODE_SNIPPET_FILE_DIRECTORY ,代码片段将存储在临时目录中(例如, /tmp/mcp-ssh-rails-runner-code-snippets )。 PROJECT_NAME_AS_CONTEXT是可选的,有助于在工具描述中识别项目上下文。

可用工具

服务器现在使用准备->执行工作流程:

mcp_ssh_rails_runner_prepare_code_snippet

  • 参数: name (字符串,用于文件名)、 type (枚举:“readOnly”|“mutate”)、 code (字符串,Ruby 代码)、 description (字符串,可选)。

  • 功能:将提供的 Ruby 代码保存到名为code_snippet_<name>.json的本地文件中,将其标记为只读或变异,然后打开该文件进行审查。

  • 返回:所创建片段的file:// URI。

mcp_ssh_rails_runner_execute_code_snippet_read_only

  • 参数: uri (字符串,来自prepareCodeSnippet的file:// URI)。

  • 功能:从 URI 读取代码片段,验证其是否标记为readOnly ,对代码执行安全检查,然后执行它。

  • 返回:Rails 命令的输出。

mcp_ssh_rails_runner_execute_code_snippet_mutate

  • 参数: uri (字符串,来自prepareCodeSnippet的file:// URI)。

  • 功能:危险区域!读取代码片段,验证其是否标记为mutate ,并直接执行。此工具没有试运行或其他安全检查。

  • 返回:Rails 命令的输出。

  • 用法:仅在用户查看了准备好的代码(通过prepareCodeSnippet打开的文件)并明确确认他们想要执行变异后才调用此方法。

安全注意事项

  • 仅与您自己的本地计算机(临时)提供对远程环境的访问权限的受信任的 SSH 端点一起使用。

  • **至关重要的是,在使用executeCodeSnippetMutate执行任何修改之前,务必检查prepareCodeSnippet保存的代码。**确认修改的责任在于用户和调用方 AI。

执照

麻省理工学院

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables SSH connections and remote command execution with persistent session management and real-time browser-based terminal monitoring. Supports multiple simultaneous SSH sessions with command history tracking and live WebSocket streaming of terminal output.
    6
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables secure remote SSH command execution with strict read-only enforcement, allowing safe delegation of SSH access to Claude while preventing write operations. Supports connection pooling, command validation, and comprehensive logging for audit trails.
    5
    1
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables remote shell command execution and file operations with restricted/unrestricted modes, background tasks, safe editing, and code search.
    MIT