
MCP SSH Gateway
io.github.d00musPublished by GitHub account d00musv7.0.0Updated Nov 10, 2026
SSH terminals for AI agents: stateful shells, exit codes the moment a command ends, router CLIs.
Overview
Gives an AI assistant SSH terminals on remote hosts: stateful shells, exit codes when a command ends, and paged output.
- What you can do
- List configured SSH servers and their open sessions
- Run commands in a new or existing stateful shell, returning status, exit code and output
- Read further output, tail the end, or scroll back through a session buffer
- Answer prompts with stdin, or stop a command with Ctrl+C or Ctrl+D
- List, read, write and edit remote files over SFTP or through the shell
- Optionally add a server to the config when started with the add-server flag
- When to use it
- Useful when an assistant should inspect or operate Linux hosts you control over SSH — checking disk usage, running builds, reading logs, editing remote files — and you want reliable command completion and exit codes instead of guessing from silence.
- Requirements
- Runs locally over stdio; needs Python 3.11+ (or uv) and SSH access to hosts you control. Servers come from a JSON config file or an inline JSON string, or from your existing SSH config with the import flag. Password or key-passphrase logins can reference environment variables such as ROUTER_PASSWORD in the config; optional settings include SSH_SERVERS_CONFIG, SSH_READ_ONLY, SSH_COMMAND_BLACKLIST and SSH_MCP_CACHE_DIR.
Installation
In SourceWeft
- Open MCP SSH Gateway in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
MCP SSH Gateway
SSH terminals for AI agents that know when a command is done.
Six tools, real shells that keep their state, the exit code the moment a command ends, and answers a small model can act on. One direct dependency (paramiko), no daemon, nothing in the cloud.
[CI] [Python 3.11+] [PyPI] [License: MIT]
English · Русский
Why this one
- It knows when a command is done. The shell itself reports the end and the exit code, so
echo hireturns in milliseconds, a failing command saysexit_code: 2, and a three-minute build answersrunningafter 10 seconds and is collected withread. No sleeps, no guessing from silence. - Terminals with state. A session is one real shell:
cd, variables and virtualenvs stay between calls.runwithout asession_idopens a new shell, so nothing is shared by accident. - Made for small models. Six tools, about 1.6k tokens of descriptions in total. Every stop says what to do next (
hint), pagers are off, a progress bar is one line, a wrong argument gets an answer that names the right call, and long output comes in pages (has_more,tail,offset). - Questions do not hang.
Continue? [y/N], a password prompt or an unclosed quote returnswaiting_input. The agent answers withsignalor presses Ctrl+C, and the shell keeps its state. - Routers too. A Keenetic router CLI (
show interface,--More--handled) or its Linux shell, through the same tools. - Tested against real
sshd. Containers with bash, BusyBox ash, zsh, dash, fish and tcsh logins and a host without SFTP run in CI on every push.
Quick start
You need uv (or Python 3.11+ and pip) and SSH access to a host you control.
Already have ~/.ssh/config? Add this to your MCP client, and every host in that file becomes a server (key or agent login):
This is the format of Cursor (~/.cursor/mcp.json) and Claude Desktop (claude_desktop_config.json); other clients are below. Restart the client and ask: "List my SSH servers and show the disk usage on web."
Want a password login, a router or a read-only host? Write a servers.json:
and point the gateway at it with "args": ["mcp-ssh-gateway", "--servers-config", "/absolute/path/to/servers.json"]. Use an absolute path (clients do not start in your folder; on Windows escape backslashes in JSON) and give the gateway the variables it refers to in the client's "env" block. servers.json.example also shows a read-only production host. Without uv: pip install mcp-ssh-gateway and "command": "mcp-ssh-gateway".
Other clients
Claude Code
VS Code (.vscode/mcp.json: the top key is servers)
Codex (~/.codex/config.toml, or codex mcp add ssh -- uvx mcp-ssh-gateway --import-ssh-config)
The gateway is also listed in the official MCP Registry as io.github.d00mus/mcp-ssh-gateway, for the clients and directories that read it.
What the agent sees
Answers as a client receives them, captured from the test suite's Debian container (the host address and the disk figures are replaced with example values):
A mistake gets an answer that names the right call. This is what a model that invents a cwd argument for run reads back:
Tools
Sessions are named server/N. A shell has state (folder, variables), so there is no default one: run without session_id always opens a new shell and returns its id, and that id continues the same shell. Close the shells you are done with.
What it works with
The gateway itself runs wherever Python 3.11+ runs (Linux, macOS, Windows).
Security
The agent has the reach of the SSH account you give it. What follows narrows the damage from mistakes; it does not replace a restricted account.
- Guardrails are mistake guards.
read_onlyandcommand_blacklist(literal words, case-insensitive) look at the command text. Shell tricks,base64orpython -cget around them. For a real boundary use a restricted SSH account: a read-only shell,ForceCommand, separate credentials per trust level. - Local files are off.
local_path(upload, download) works only after you start the gateway with--project-root <folder>, and then only inside that folder. - Host keys: a new host is trusted on first contact and its key is kept in
known_hostsin the cache directory; a changed key is refused.verify_host: falseturns the check off. - Secrets: put
${NAME}references inservers.jsoninstead of the values. Logs mask password-like values (--log-output offwrites no logs). - No listening port: the gateway talks MCP over stdio only.
server_adddoes not exist unless you start it with--allow-add-server, and it only appends.
The full policy and how to report a problem: SECURITY.md.
Configuration
servers.json fields: host, user, port (22), key_path (~ and ${NAME} work), password and key_passphrase (only ${NAME} references are replaced, the rest is used as written), verify_host (true), description, extra_path (added to PATH), read_only, command_blacklist, max_sessions (8), shell (a POSIX shell to exec after login, for fish or tcsh accounts). The file is re-read while the gateway runs; unchanged servers keep their sessions.
Command line (none is required except a source of servers):
Logs: one JSON-lines file per session and one per command under the cache directory; old files are pruned by age and size.
How it works
The gateway opens an interactive shell with a PTY and switches it to a quiet, machine-readable mode with one setup line: no echo, and a prompt that prints a marker containing the exit code. When the marker appears the command is over and the agent has its exit code. This also covers syntax errors, background jobs and Ctrl+C. An unclosed quote or heredoc is recognised by a second marker.
Routers whose login is a vendor CLI (Keenetic NDM) have no such shell. There the gateway learns the prompt from the login banner, removes the echo of the typed command, presses space at --More-- and treats a stable prompt as the end of the command. run(shell=false) uses the CLI, run(shell=true) enters the Linux shell behind it; a session keeps one mode.
Output goes into one line-based buffer per session with a single unread position. run and read advance it; tail jumps to the end; offset only looks. Lines longer than 1024 characters are split so that pages stay predictable.
Limits
- A shell runs one command at a time. For two things at once open two shells (or let your client call
runin parallel). - A shell started inside a session (
sudo -s,su,bash) hides where commands end, so the gateway tells the agent to leave it. Usesudo <command>for root. - No jump hosts yet (#2), no other router CLIs yet (#1).
- The gateway has no approvals, policy engine or audit trail. If you need those, see below.
Other SSH servers for MCP
They make different trade-offs (as of September 2026; read their READMEs before choosing):
- tufantunc/ssh-mcp: security first. Command classification, role and host policy, human approval, audit log,
ProxyJump, SSH CA and streaming SFTP; 14 tools. Choose it for production fleets that need approvals and an audit trail. - classfang/ssh-mcp-server: 4 tools on Node (
npx) with a command whitelist, SOCKS and HTTP proxies, a bastion mode and MFA. Choose it for the smallest Node setup that needs proxies or MFA. - bvisible/mcp-ssh-manager: 37 tools, a DevOps toolbox with backups, databases and monitoring. Choose it if you want those workflows ready-made.
This gateway chooses the other end: few tools, stateful shells, and an answer for every situation an agent gets stuck in.
Docker
The cache volume keeps known_hosts and the logs between runs.
Development
Integration tests start real sshd containers and drive the gateway through the same JSON-RPC entry point a client uses. They skip themselves when Docker is missing (MCP_SSH_IT=0 skips on purpose). See CONTRIBUTING.md and the changelog. MIT-licensed.
Source: README.md at commit 35b3f5c
Tools
0Version history
2- v7.0.0LatestSep 29, 2026
- v6.0.1Sep 28, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts