Skip to main content
Glama
SSH MCP Server
by termau

SSH MCP Server

A Model Context Protocol (MCP) server for executing commands and managing files on remote servers via SSH.

Optionally auto-discovers BinaryLane VPS servers so they're available immediately.

Features

  • Execute shell commands on remote servers

  • Read files and list directories remotely

  • Upload and download files via SFTP

  • Persistent connections saved to config file across restarts

  • BinaryLane auto-discovery of active servers

  • Per-connection SSH key configuration

  • Multiple connection sources with clear priority

Related MCP server: MCP SSH Server

Installation

npm install
npm run build

Configuration

Claude Desktop / Claude Code

Add to your Claude configuration:

{
  "mcpServers": {
    "ssh": {
      "command": "node",
      "args": ["/path/to/ssh-mcp/dist/index.js"],
      "env": {
        "BINARYLANE_API_TOKEN": "your-token-here"
      }
    }
  }
}

The BINARYLANE_API_TOKEN is optional — only needed for auto-discovery of BinaryLane servers.

Config File

On first run, a config file is created at ~/.config/ssh-mcp/connections.json:

{
  "defaultPrivateKeyPath": "~/.ssh/id_ed25519",
  "binarylane": {
    "enabled": true,
    "apiToken": "your-token-here",
    "defaultUsername": "root",
    "defaultPrivateKeyPath": "~/.ssh/id_ed25519"
  },
  "connections": [
    {
      "name": "my-server",
      "host": "10.0.0.5",
      "port": 22,
      "username": "deploy",
      "privateKeyPath": "~/.ssh/deploy_key"
    }
  ]
}

The BinaryLane API token can be set here or as an environment variable.

Environment Variable (Legacy)

Still supported for backward compatibility:

export SSH_CONNECTIONS='[
  {"name": "web1", "host": "192.168.1.10", "port": 22, "username": "root", "privateKeyPath": "~/.ssh/id_rsa"}
]'

Connection Options

Option

Required

Default

Description

name

Yes

-

Unique identifier for the connection

host

Yes

-

Server hostname or IP address

port

No

22

SSH port

username

Yes

-

SSH username

privateKeyPath

No

-

Path to SSH private key (supports ~ expansion)

password

No

-

SSH password (if not using key auth)

If neither privateKeyPath nor password is provided, the server will try default SSH key locations (~/.ssh/id_ed25519, ~/.ssh/id_rsa).

Connection Priority

When multiple sources define the same connection name:

  1. Config file (highest) — manual connections from ~/.config/ssh-mcp/connections.json

  2. Environment variable — SSH_CONNECTIONS

  3. BinaryLane auto-discovery (lowest) — active servers from the API

Available Tools

Connection Management

  • list_connections — List all available SSH connections with source info

  • test_connection — Test connectivity with latency reporting

  • add_connection — Add a connection (persisted to config file)

  • remove_connection — Remove a manual connection from config

  • refresh_connections — Re-discover BinaryLane servers and reload all connections

  • get_config — Show current configuration (tokens redacted)

Command Execution

  • run_command — Execute a shell command with configurable timeout

File Operations

  • read_remote_file — Read file contents via SFTP

  • list_remote_directory — List directory contents with metadata

  • upload_file — Upload a local file to remote server

  • download_file — Download a remote file to local machine

Example Usage

# List all connections (shows source: config, env, or binarylane)
list_connections

# Test connection
test_connection connection="web1"

# Run a command
run_command connection="web1" command="uptime"

# Add a new persistent connection
add_connection name="staging" host="10.0.0.5" username="deploy" privateKeyPath="~/.ssh/deploy_key"

# Refresh after creating new BinaryLane servers
refresh_connections

Security Notes

  • SSH keys are read from your local filesystem and never transmitted or stored by the MCP

  • Passwords in config are only held in memory during operation

  • The config file should be protected with appropriate filesystem permissions

  • Commands are executed with the privileges of the SSH user

  • Consider using dedicated SSH keys with limited permissions for automation

Development

npm run dev    # Watch mode
npm run build  # Compile TypeScript
npm start      # Run compiled server

Project Structure

ssh-mcp/
├── src/
│   ├── index.ts        # Server entry point
│   ├── ssh-client.ts   # SSH connection manager
│   ├── config.ts       # Persistent config file management
│   ├── binarylane.ts   # BinaryLane auto-discovery
│   ├── tools.ts        # MCP tool definitions
│   └── handlers.ts     # Tool handler implementations
├── dist/               # Compiled JavaScript
├── package.json
└── tsconfig.json

License

MIT

Available Tools

11 tools
add_connectionA

Add or update a manual SSH connection. Persisted to config file across restarts.

Parameters:

  • name: Unique name for this connection (required)

  • host: Server hostname or IP address (required)

  • port: SSH port (default: 22)

  • username: SSH username (required)

  • privateKeyPath: Path to SSH private key (supports ~ expansion)

  • password: SSH password (if not using key auth)

Example: add_connection("staging", "10.0.0.5", 22, "deploy", "~/.ssh/deploy_key")

Inputs: host (required), name (required), username (required), port, +2 more.

download_fileA

Download a file from a remote server via SFTP.

Parameters:

  • connection: Name of the connection (from list_connections)

  • remote_path: Path to the file on the remote server

  • local_path: Destination path on the local machine

Example usage: download_file("web1", "/var/log/nginx/error.log", "/tmp/error.log")

Inputs: connection (required), local_path (required), remote_path (required).

get_configA
Read-only

Show the current SSH MCP configuration.

Returns the config file contents with sensitive values (tokens, passwords) redacted. Shows BinaryLane auto-discovery settings and all manual connections.

Inputs: no named parameters.

list_connectionsA
Read-only

List all configured SSH connections.

Returns the name, host, port, and username for each connection. Connections are configured via the SSH_CONNECTIONS environment variable.

Example usage: Before running commands, list connections to see what's available.

Inputs: no named parameters.

list_remote_directoryB
Read-only

List contents of a directory on a remote server.

Parameters:

  • connection: Name of the connection (from list_connections)

  • path: Absolute path to the directory on the remote server

Example usage: list_remote_directory("web1", "/var/log")

Returns a list of files/directories with name, type, size, and modification time.

Inputs: path (required), connection (required).

read_remote_fileA
Read-only

Read the contents of a file on a remote server.

Parameters:

  • connection: Name of the connection (from list_connections)

  • path: Absolute path to the file on the remote server

Example usage: read_remote_file("web1", "/etc/nginx/nginx.conf")

Returns the file contents as text.

Inputs: path (required), connection (required).

refresh_connectionsA
Read-only

Re-discover BinaryLane servers and reload all connections.

Refreshes the connection list by:

  1. Re-reading the config file

  2. Re-discovering BinaryLane servers (if enabled)

  3. Re-reading SSH_CONNECTIONS env var

  4. Merging all sources (config > env > auto-discovered)

Use after creating/deleting BinaryLane servers to update the connection list.

Inputs: no named parameters.

remove_connectionA
Destructive

Remove a manual SSH connection from the config file.

Only removes connections added via add_connection (source: config). Auto-discovered BinaryLane connections cannot be removed this way.

Parameters:

  • name: Name of the connection to remove

Inputs: name (required).

run_commandA
Destructive

Execute a command on a remote server via SSH.

Runs a shell command and returns stdout, stderr, and exit code.

Parameters:

  • connection: Name of the connection (from list_connections)

  • command: The shell command to execute

  • timeout: Command timeout in milliseconds (default: 30000)

Example usage: run_command("web1", "uptime") Example usage: run_command("db1", "systemctl status mysql", 60000)

Returns:

  • stdout: Command standard output

  • stderr: Command standard error

  • code: Exit code (0 = success)

Inputs: command (required), connection (required), timeout.

test_connectionA
Read-only

Test connectivity to an SSH server.

Attempts to establish an SSH connection and reports success/failure with latency.

Parameters:

  • connection: Name of the connection to test (from list_connections)

Example usage: Verify a server is reachable before running commands.

Inputs: connection (required).

upload_fileB
Destructive

Upload a local file to a remote server via SFTP.

Parameters:

  • connection: Name of the connection (from list_connections)

  • local_path: Path to the local file

  • remote_path: Destination path on the remote server

Example usage: upload_file("web1", "/tmp/config.txt", "/etc/myapp/config.txt")

Inputs: connection (required), local_path (required), remote_path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: connection listing/testing/management, command execution, configuration inspection, and remote file operations. The only mild overlap is among list_connections, get_config, and refresh_connections, but their descriptions clearly separate listing, config inspection, and re-discovery.

    Naming Consistency5/5

    All tool names use a consistent snake_case verb_noun pattern, such as list_connections, run_command, read_remote_file, and upload_file. There are no mixed conventions or vague standalone verbs.

    Tool Count5/5

    Eleven tools is well within a reasonable range for an SSH management server and each tool maps to a distinct operational need. The set is neither bloated nor too thin for the domain.

    Completeness4/5

    The surface covers connection management, command execution, and core file operations including read, list, upload, and download. Minor gaps exist for direct remote file deletion, directory creation, or renaming, though run_command can serve as a workaround.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      Enables SSH operations including connecting to remote servers, executing commands, and transferring files between local and remote systems. Supports multiple SSH connections with both password and private key authentication methods.
      18
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables seamless SSH operations including secure connections, file transfers, interactive shell sessions, and Docker container management on remote servers. Supports both password and SSH key authentication with credential management and connection pooling.
      18
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables secure SSH connections to multiple remote servers with support for command execution, file transfers (SFTP), directory listing, and both password and key-based authentication.
      7
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables remote server management through SSH and SFTP, supporting command execution, file transfers, and interactive shell sessions. It allows for multiple concurrent connections using either password or SSH key authentication.
      11
      27 npm
      5
      MIT