Skip to main content
Glama

SSH MCP

A cross-platform MCP (Model Context Protocol) server that lets Claude Code — or any MCP client — read, write, edit, search, run commands, transfer files, and use git on a remote Linux server over SSH. The server runs on your local machine; nothing is installed on the remote.

It uses a pure-Python SSH transport (Paramiko), so it runs natively on Windows, macOS, and Linux — no WSL, no native ssh client, no SSH ControlMaster. Authentication uses your SSH key / agent / ~/.ssh/config; credentials never pass through the MCP channel.


Why

Sometimes the remote box is great for the code but can't run the agent — e.g. the network blocks the model's API, or you don't want to install/authenticate an agent on a shared server. SSH MCP flips it: the agent runs locally (with internet + your credentials) and reaches into the remote host over plain SSH.

┌──────────────┐    MCP (stdio)    ┌──────────────┐   SSH / SFTP    ┌───────────────┐
│  Claude Code  │ ◄───────────────► │  ssh-mcp      │ ◄─────────────► │ Remote server  │
│   (local)     │   tool calls      │  (Paramiko)   │   exec + files  │ (Linux / bash) │
└──────────────┘                   └──────────────┘                 └───────────────┘

Related MCP server: mcp-ssh

Features

  • 22 MCP tools — files, line-edits, commands, background jobs, search, git, and binary-safe file transfer.

  • Binary-safe upload/download over SFTP — .db, images, archives, etc., streamed (large files don't load into memory).

  • Zero remote install — uses standard tools already on the remote.

  • Flexible auth — keys, ssh-agent, ~/.ssh/config, ProxyCommand.

  • Atomic writes, output truncation, binary-file detection, background jobs.


Requirements

  • Python 3.10+

  • An SSH key / agent / ~/.ssh/config entry that can reach the remote host

  • uv (recommended) or pip

  • Claude Code (optional, to use it as an MCP server)


Install

git clone <your-repo-url> ssh-mcp
cd ssh-mcp
uv tool install .          # puts the `ssh-mcp` command on your PATH

Or with pip:

python -m venv .venv && . .venv/bin/activate     # Windows: .\.venv\Scripts\activate
pip install -e .

Configure

Create ~/.config/ssh-mcp/config.yaml from the example and edit it:

mkdir -p ~/.config/ssh-mcp
cp config.example.yaml ~/.config/ssh-mcp/config.yaml
# Windows (PowerShell)
mkdir "$env:USERPROFILE\.config\ssh-mcp" -Force
copy config.example.yaml "$env:USERPROFILE\.config\ssh-mcp\config.yaml"

Minimal config:

default_host: myserver
hosts:
  myserver:
    ssh_host: server.example.com   # hostname/IP or a ~/.ssh/config alias
    user: jdoe
    key_path: "~/.ssh/id_ed25519"  # omit to use agent / default keys / ssh_config
    default_cwd: "~/project"

Register with Claude Code

claude mcp add --scope user ssh-mcp -- ssh-mcp

Then run claude and ask: "List the files in ~/project on the remote server."


Tools

Commands: ssh_run · ssh_run_background · ssh_job_status Connection: ssh_check_connection Files: ssh_read_file · ssh_write_file · ssh_patch_file · ssh_append_file · ssh_insert_lines · ssh_replace_lines · ssh_list_dir · ssh_file_info · ssh_mkdir · ssh_move · ssh_delete Transfer (binary-safe, SFTP): ssh_upload · ssh_download Search: ssh_grep · ssh_find_files Git: ssh_git_status · ssh_git_diff · ssh_git_log

Text vs binary: ssh_write_file is for text (UTF-8). For binary files (.db, images, archives) use ssh_upload / ssh_download, which use SFTP and preserve bytes exactly.


Configuration reference

Key

Default

Meaning

ssh_host

— (required)

hostname/IP or ~/.ssh/config alias

user

ssh_config / system

SSH username

port

22

SSH port

key_path

—

private key file (else agent / default keys / ssh_config)

password

—

password auth (discouraged)

use_ssh_config

true

read ~/.ssh/config for this host

strict_host_key_checking

false

reject unknown host keys

proxy_command

—

ProxyCommand for bastion / IAP

connect_timeout

20

connect timeout (s)

preamble

—

shell sourced before each command

default_cwd

~

working directory

command_timeout / file_timeout

30 / 60

timeouts (s)

max_file_size

10485760

text read/write cap (binary transfer is unbounded)

max_output_lines

5000

command output truncation

Config path: ~/.config/ssh-mcp/config.yaml (override with SSH_MCP_CONFIG or ssh-mcp --config <path>).


Development

uv sync --extra dev
uv run pytest -q

License

AGPL-3.0 — see LICENSE and NOTICE. This project is a modified version of a third-party AGPL-3.0 work and remains under the same license.

Available Tools

22 tools
ssh_append_fileA

Append text to the end of a file on the remote server.

Efficient for adding content to large files — no read round-trip needed. The file is created if it does not exist.

Args: path: Path to the file on the remote. content: Text content to append. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), content (required), host.

ssh_check_connectionA

Check whether the SSH connection to the remote host is alive.

Returns connection status and diagnostics. If it can't connect, the message explains what to check (host reachability, key / agent / ~/.ssh/config setup).

Args: host: SSH host alias from config. Uses default if omitted.

Inputs: host.

ssh_deleteA

Delete a file or directory on the remote server.

Args: path: Path to delete. recursive: If true, delete directories recursively (rm -r). host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), recursive, host.

ssh_downloadA

Download a file from the remote server to the local machine (binary-safe).

Transfers over SFTP (the SSH file-transfer protocol), so it streams and preserves any file type exactly, including binary (.db, images, archives). To send a file the other way, use ssh_upload.

Args: remote_path: Path to the file on the remote server. local_dir: Local directory to save to. Defaults to ~/Downloads. host: SSH host alias from config. Uses default if omitted.

Inputs: remote_path (required), local_dir, host.

ssh_file_infoB

Get detailed information about a file or directory on the remote server.

Args: path: Path to inspect. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), host.

ssh_find_filesA

Find files by name pattern on the remote server.

Args: path: Directory to search in. pattern: Filename glob pattern (e.g., ".py", "test_"). file_type: Type filter: "f" for files, "d" for directories, "" for both. max_results: Maximum entries to return. max_depth: Maximum directory depth to search. host: SSH host alias from config. Uses default if omitted.

Inputs: path, pattern, file_type, max_results, +2 more.

ssh_git_diffA

Show git diff on the remote server.

Args: cwd: Path to the git repository. Defaults to host's default_cwd. ref: Git ref to diff against (e.g., "HEAD~1", "main", a commit hash). Empty for working tree diff. path: Limit diff to a specific file or directory. staged: If true, show staged changes (--cached). host: SSH host alias from config. Uses default if omitted.

Inputs: cwd, ref, path, staged, +1 more.

ssh_git_logB

Show git log on the remote server.

Args: cwd: Path to the git repository. Defaults to host's default_cwd. count: Number of commits to show. path: Limit log to a specific file or directory. oneline: If true, show compact one-line format. host: SSH host alias from config. Uses default if omitted.

Inputs: cwd, count, path, oneline, +1 more.

ssh_git_statusA

Get git status of a repository on the remote server.

Returns the current branch, modified files, staged files, and untracked files.

Args: cwd: Path to the git repository. Defaults to host's default_cwd. host: SSH host alias from config. Uses default if omitted.

Inputs: cwd, host.

ssh_grepA

Search for a pattern in files on the remote server using grep.

Returns matching lines with file paths and line numbers.

Args: pattern: Regular expression pattern to search for. path: Directory or file to search in. glob: Filter files by glob pattern (e.g., ".py", ".cpp"). max_results: Maximum number of matching lines to return. context_lines: Number of context lines to show before and after each match. case_insensitive: If true, ignore case when matching. host: SSH host alias from config. Uses default if omitted.

Inputs: pattern (required), path, glob, max_results, +3 more.

ssh_insert_linesA

Insert text after a specific line number in a file on the remote server.

Operates directly via sed on the remote — no full-file transfer needed. Only the new content is sent over the wire.

Args: path: Path to the file on the remote. after_line: Line number to insert after (1-based). Use 0 to insert at the beginning. content: Text content to insert. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), after_line (required), content (required), host.

ssh_job_statusA

Check the status of a background job and retrieve its output.

Args: job_id: The job ID returned by ssh_run_background. tail_lines: Number of lines to show from the end of stdout/stderr. host: SSH host alias from config. Uses default if omitted.

Inputs: job_id (required), tail_lines, host.

ssh_list_dirA

List directory contents on the remote server.

Args: path: Directory path to list. Defaults to current working directory. pattern: Glob pattern to filter entries (e.g., "*.py", "Makefile"). recursive: If true, list recursively. max_entries: Maximum entries to return (prevents overwhelming output). host: SSH host alias from config. Uses default if omitted.

Inputs: path, pattern, recursive, max_entries, +1 more.

ssh_mkdirA

Create a directory on the remote server.

Args: path: Directory path to create. parents: If true, create parent directories as needed (mkdir -p). host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), parents, host.

ssh_moveC

Move or rename a file/directory on the remote server.

Args: source: Current path. dest: New path. host: SSH host alias from config. Uses default if omitted.

Inputs: source (required), dest (required), host.

ssh_patch_fileA

Replace a string in a file on the remote server.

Reads the file, performs the replacement locally, and writes it back. The old string must appear exactly once (to avoid ambiguous edits).

Args: path: Path to the file on the remote. old: The exact text to find and replace. Must be unique in the file. new: The replacement text. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), old (required), new (required), host.

ssh_read_fileA

Read lines from a file on the remote server.

Efficiently reads only the requested range using sed, so large files are safe to read partially. Returns line-numbered content similar to cat -n output.

Args: path: Absolute or relative path to the file on the remote. offset: Line number to start reading from (0-based). limit: Maximum number of lines to return. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), offset, limit, host.

ssh_replace_linesA

Replace a range of lines in a file on the remote server.

Operates directly via sed on the remote — no full-file transfer needed. If content is empty, the lines are deleted. Both start_line and end_line are 1-based and inclusive.

Args: path: Path to the file on the remote. start_line: First line to replace (1-based, inclusive). end_line: Last line to replace (1-based, inclusive). content: Replacement text. Empty string deletes the line range. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), start_line (required), end_line (required), content, +1 more.

ssh_runA

Execute a shell command on the remote server.

The command runs in a bash login shell with the configured environment preamble (e.g., sourced setup scripts) already applied.

Args: command: Shell command to run (e.g., "make test", "python script.py"). cwd: Working directory on the remote. Defaults to the host's configured default_cwd. timeout: Timeout in seconds. Defaults to host config (usually 30s). host: SSH host alias from config. Uses default if omitted.

Inputs: command (required), cwd, timeout, host.

ssh_run_backgroundA

Start a long-running command in the background on the remote server.

Use this for commands that take more than 30 seconds (e.g., builds, test suites). The command runs detached via nohup. Use ssh_job_status to check progress and retrieve output.

Args: command: Shell command to run in the background. cwd: Working directory on the remote. Defaults to host's default_cwd. job_id: Optional human-readable job ID. Auto-generated if omitted. host: SSH host alias from config. Uses default if omitted.

Inputs: command (required), cwd, job_id, host.

ssh_uploadA

Upload a local file to the remote server (binary-safe, via SFTP/scp).

Use this for any file type — including binary files such as SQLite .db databases, images, or archives — that ssh_write_file (text/UTF-8) cannot carry safely. The file is streamed over SFTP, so large files transfer without loading into memory.

Args: local_path: Path to the file on THIS machine (the one running the server). remote_path: Destination path on the remote server. create_dirs: If true, create the remote parent directory first. host: SSH host alias from config. Uses default if omitted.

Inputs: local_path (required), remote_path (required), create_dirs, host.

ssh_write_fileA

Write content to a file on the remote server.

Uses atomic write (temp file + mv) to prevent partial writes. Overwrites the file if it exists, creates it if it doesn't.

Args: path: Absolute or relative path on the remote. content: Text content to write. create_dirs: If true, create parent directories if they don't exist. host: SSH host alias from config. Uses default if omitted.

Inputs: path (required), content (required), create_dirs, host.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 22 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose. File modification tools (write, append, insert, replace, patch) are well-defined and non-overlapping. Git and command execution tools are similarly distinct.

    Naming Consistency5/5

    All tools follow a consistent 'ssh_<verb>_<object>' pattern with snake_case. Git tools use 'ssh_git_<verb>', which fits the pattern. No mixing of styles.

    Tool Count4/5

    22 tools is slightly above the typical 3-15 range but still reasonable for a comprehensive SSH server. Each tool serves a distinct need without being excessive.

    Completeness4/5

    Core file operations, search, command execution, and git integration are covered. Minor gaps like file copy and permission changes exist, but the surface is largely complete for remote server management.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers