mcp-ssh
MCP server for SSH remote execution, file transfer, and file editing with automatic backup/trash and ~/.ssh/config integration.
README
<p align="center"> <br/> <h1 align="center">π @caikiji/mcp-ssh</h1> <p align="center">MCP server for SSH remote execution, file transfer, file editing<br/>with automatic backup/trash & <code>~/.ssh/config</code> integration</p> <p align="center"> <a href="https://www.npmjs.com/package/@caikiji/mcp-ssh"><img src="https://img.shields.io/npm/v/@caikiji/mcp-ssh?style=flat-square&logo=npm" alt="npm version"/></a> <a href="https://www.npmjs.com/package/@caikiji/mcp-ssh"><img src="https://img.shields.io/npm/dm/@caikiji/mcp-ssh?style=flat-square" alt="npm downloads"/></a> <a href="https://github.com/caikiji/mcp-ssh"><img src="https://img.shields.io/github/stars/caikiji/mcp-ssh?style=flat-square&logo=github" alt="github stars"/></a> <a href="./README.zh-CN.md"><img src="https://img.shields.io/badge/ζζ‘£-δΈζ-blue?style=flat-square" alt="δΈζζζ‘£"/></a> <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square&logo=node.js" alt="node version"/> <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="license"/> </p> <p align="center"> <b><a href="#installation">Installation</a></b> Β· <b><a href="#configuration">Configuration</a></b> Β· <b><a href="#tools">Tools</a></b> Β· <b><a href="#backup--trash">Backup & Trash</a></b> Β· <b><a href="./README.zh-CN.md">δΈζζζ‘£</a></b> </p> <br/> </p>
β¨ Features
- π SSH via env β register multiple servers with password or key auth in a single env var
- π Config integration β use or auto-import
~/.ssh/confighosts ($config) - π» Remote exec β run commands with optional timeout, PTY, and sudo password support
- π File transfer β upload/download via SFTP
- π File editing β read, write, search/replace, line operations with automatic backup
- ποΈ Trash protection β deleted files go to
~/.mcp-ssh/trash/(configurable threshold) - π Debug mode β
SSH_DEBUG=truefor connection/exec/SFTP diagnostics
Installation
npm install -g @caikiji/mcp-ssh
Configuration
SSH_SERVICES
Register servers via environment variable. Separate multiple entries with ;.
SSH_SERVICES="web:root@192.168.1.100:22|/path/to/id_rsa;db:deploy@db.internal|db_password"
Format: [name:]user@host[:port]|credential
| Part | Description |
|---|---|
name |
Optional display name (defaults to host). Duplicates get a numeric suffix. |
port |
Optional, defaults to 22. |
credential |
File path β SSH key, otherwise treated as password. |
Using ~/.ssh/config
Reference any Host from ~/.ssh/config by name (no @ needed):
SSH_SERVICES="production|password;db:db-server|"
- Empty credential (
|at end) β usesIdentityFilefrom config [name:]config_hostβ custom display name
Auto-import all config hosts ($config)
Import every config host that has both User and IdentityFile:
SSH_SERVICES="$config"
# Mixed with regular entries:
SSH_SERVICES="$config;extra:root@other.host|password"
Config changes take effect on the next tool call β no MCP restart required.
Environment variables
| Variable | Default | Description |
|---|---|---|
SSH_TIMEOUT |
15000 |
Connection timeout (ms) |
SSH_LARGE_FILE_MB |
10 |
Files larger than this (MB) skip backup/trash |
SSH_DEBUG |
β | Set to true for debug logging to stderr |
MCP Client config
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": ["-y", "@caikiji/mcp-ssh"],
"env": {
"SSH_SERVICES": "$config;web:root@192.168.1.100|/path/to/key"
}
}
}
}
Tools
Server Management
| Tool | Arguments | Description |
|---|---|---|
list_servers |
β | List all configured servers with address and auth type |
Command Execution
| Tool | Arguments | Description |
|---|---|---|
exec |
server, command, [workdir], [timeout], [pty], [sudo_password] |
Run any shell command. workdir prepends cd <path> &&. timeout limits execution (seconds). pty: true allocates a TTY for apt/tmux/etc. sudo_password runs via sudo -S <cmd> (password sent via stdin, no PTY needed). |
File Transfer
| Tool | Arguments | Description |
|---|---|---|
upload |
server, local_path, remote_path |
Upload a local file via SFTP |
download |
server, remote_path, local_path |
Download a remote file via SFTP |
File Operations
| Tool | Arguments | Description |
|---|---|---|
read |
server, remote_path, [offset], [limit], [mode], [count] |
Read file. mode:text (default), head, tail (via exec, zero transfer). count for head/tail (default 50). offset 1-indexed, for text mode. |
write |
server, remote_path, content, [mode] |
Create/overwrite (mode: "write", default) or append (mode: "append") to a file. Auto-backup before overwrite. |
update |
server, remote_path, search+replace+[replace_all] or line+content+[position] |
Edit existing file: search/replace (all or first), or line operations (replace, insert before/after, delete range). Backup before modification. |
rm |
server, remote_path |
Remove file/dir with trash protection (β€10MB β trash) |
ls |
server, remote_path |
List dir entries or get single file details (name, type, size, mtime, permissions) |
Backup & Trash
~/.mcp-ssh/
βββ backups/<server>/<path>.bak.1-3 β auto-rotated before overwrite
βββ trash/<server>/<path>.<timestamp> β small files (β€10MB) on delete
Check real usage via exec:
exec server, "du -sh ~/.mcp-ssh"
<p align="center"> <a href="./README.zh-CN.md">π δΈζζζ‘£</a> </p>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.