diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3ecffe5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile +# Use the official Node.js image with Alpine for a smaller image size +FROM node:20-alpine AS builder + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json to install dependencies +COPY package.json package-lock.json ./ + +# Install the dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN npm run build + +# Use a separate image for the runtime to keep the image lightweight +FROM node:20-alpine + +# Set the working directory +WORKDIR /app + +# Copy the build output and package.json to the runtime image +COPY --from=builder /app/build ./build +COPY --from=builder /app/package.json ./ + +# Install only production dependencies +RUN npm install --only=production + +# Set environment variables (ensure these are set as needed in a secure manner) +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 + +# Command to run the application +CMD ["node", "build/index.js"] diff --git a/README.md b/README.md index 490025e..4150bc4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # MCP Server: SSH Rails Runner +[![smithery badge](https://smithery.ai/badge/@tadasant/mcp-server-ssh-rails-runner)](https://smithery.ai/server/@tadasant/mcp-server-ssh-rails-runner) + An MCP server that enables secure remote execution of Rails console commands via SSH. This server provides tools for both read-only operations and carefully managed mutations in a deployed Rails environment. This works great with Cursor. You can use Cursor Composer to pull in your Rails model files as context and then use the `execute_read_only`, `dry_run_mutate`, and `execute_mutate` tools to make changes to the database. No need to trudge through complicated Admin UI's to get your data wrangling and analysis done. @@ -18,6 +20,15 @@ This works great with Cursor. You can use Cursor Composer to pull in your Rails ## Installation +### Installing via Smithery + +To install MCP Server: SSH Rails Runner for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@tadasant/mcp-server-ssh-rails-runner): + +```bash +npx -y @smithery/cli install @tadasant/mcp-server-ssh-rails-runner --client claude +``` + +### Manual Installation ```bash npm install npm run build diff --git a/smithery.yaml b/smithery.yaml new file mode 100644 index 0000000..42647c9 --- /dev/null +++ b/smithery.yaml @@ -0,0 +1,33 @@ +# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml + +startCommand: + type: stdio + configSchema: + # JSON Schema defining the configuration options for the MCP. + type: object + required: + - sshHost + - sshUser + - sshPrivateKeyPath + - railsWorkingDir + properties: + sshHost: + type: string + description: The remote host to connect to via SSH. + sshUser: + type: string + description: The SSH username. + sshPrivateKeyPath: + type: string + description: The path to the SSH private key. + railsWorkingDir: + type: string + description: The working directory of the Rails application on the remote host. + projectNameAsContext: + type: string + default: "" + description: The project name used as context. + commandFunction: + # A function that produces the CLI command to start the MCP on stdio. + |- + config => ({ command: 'node', args: ['build/index.js'], env: { SSH_HOST: config.sshHost, SSH_USER: config.sshUser, SSH_PRIVATE_KEY_PATH: config.sshPrivateKeyPath, RAILS_WORKING_DIR: config.railsWorkingDir, PROJECT_NAME_AS_CONTEXT: config.projectNameAsContext || '' } })