Terminal-first SSH access for MCP clients, AI agents, and remote automation.
Turn remote machines into agent-friendly, interactive terminal workflows — not just one-shot command execution.
Most SSH tooling for AI workflows is built around run command → get output → done.
That falls apart when the real task is interactive:
- installers ask questions
- shells keep state
- debugging needs multiple steps
- deployments need uploads plus terminal control
- agents need to observe, react, and continue
TermSSH MCP is built for that gap.
Instead of pretending everything is a single command, it gives MCP clients a real operator-style workflow:
open a shell → write input → read output → keep context → upload files → continue working
|
Interactive terminal sessions are the core model, not an afterthought. |
Designed for MCP clients, coding agents, and automation loops. |
Reuse active sessions so multi-step tasks feel natural and reliable. |
|
Move scripts, configs, payloads, and generated artifacts over SFTP. |
Works against Linux and Windows SSH targets. |
Focused MCP tools for terminal control and remote file delivery. |
- Interactive SSH terminal sessions
- Incremental terminal read / write flow
- Managed terminal session reuse by default
- Optional forced multi-session creation
- Local file upload through SFTP
- Direct text and base64 content upload
- Terminal resize support
- Linux and Windows SSH target support
- MCP-native interface for AI tooling
Upload a local file from the MCP host machine to the remote SSH server using SFTP.
Parameters
localPath— local source file pathremotePath— destination path on the remote hostcreateDirectories— create missing parent directories if neededoverwrite— replace an existing remote file if presentmode— optional POSIX mode such as0644
Upload direct text or base64 content to the remote server.
Parameters
content— raw text or base64 payloadencoding—utf8orbase64remotePath— destination path on the remote hostcreateDirectories— create missing parent directories if neededoverwrite— replace an existing remote file if presentmode— optional POSIX mode such as0644
Start an interactive remote terminal session.
Parameters
cwd— optional working directory after shell startupshell— optional shell binaryplatformHint—auto,linux, orwindowselevated— attemptsuelevation when configuredcols— terminal widthrows— terminal heightenv— optional environment variablesmultiSession— settrueto force a new managed session instead of reusing an existing one
Write input into an active terminal session.
Parameters
sessionId— target session idinput— text to sendappendNewline— append a newline automatically if needed
Read buffered output from a terminal session.
Parameters
sessionId— target session idsinceSequence— only return output newer than a given sequence numbermaxChars— limit the size of returned outputwaitForMs— optional short polling delay
Resize an active terminal session.
Parameters
sessionId— target session idcols— new widthrows— new height
Close a terminal session locally.
Parameters
sessionId— target session id
flowchart LR
A[terminal-start] --> B[terminal-write]
B --> C[terminal-read]
C --> D{Need file?}
D -- Yes --> E[upload-file / upload-content]
D -- No --> F{Continue session?}
E --> F
F -- Yes --> B
F -- No --> G[terminal-close]
This works especially well for:
- interactive package installs
- remote setup and provisioning
- deployments with artifact upload
- debugging services across multiple steps
- stateful shell workflows where context matters
git clone https://github.com/rayss868/termssh-mcp.git
cd termssh-mcp
npm install
npm run buildnpm install -g termssh-mcpTermSSH MCP supports two configuration modes:
- Direct CLI flags — good for quick tests or a single server
- Vault file — recommended for real usage, especially when you want multiple VPS accounts and one active target
host— hostname or IP address of the remote machineuser— SSH username
port— SSH port, default22password— SSH passwordkey— path to a private SSH key filesudoPassword— optional password for sudo-oriented workflowssuPassword— optional password forsu-based elevationtimeout— SSH ready timeout in milliseconds, default60000maxChars— command-length validation limit, default1000; usenoneor0for unlimited mode
Vault mode lets you store multiple SSH accounts in one JSON file and choose the target account per MCP tool call.
vault— path to a vault JSON file
If --vault is provided, startup resolves accounts from the vault. If no vault is provided, TermSSH MCP falls back to direct CLI config.
- MCP tools now expose an
accountparameter in the built tool schema - when vault mode is enabled,
accountshould be set to one of the keys underaccounts - if
accountis omitted, runtime now fails with a clear error instead of silently choosing an account - this was verified against live SSH MCP runtime: no
account→ reject, validaccount→ connect successfully
File: termssh-mcp-vault.json
{
"activeAccount": "production",
"accounts": {
"production": {
"host": "1.2.3.4",
"port": 22,
"user": "root",
"key": "C:\\keys\\id_ed25519"
},
"staging": {
"host": "5.6.7.8",
"port": 22,
"user": "ubuntu",
"password": "example-password"
}
}
}- In vault mode,
keymust point to a private key file path toSshConfigFromVault()reads that file and passes the key contents tossh2- This fixes the private-key parsing issue that happens if a file path is sent directly as
privateKey
{
"mcpServers": {
"termssh-mcp": {
"command": "node",
"args": [
"build/index.js",
"--vault=./termssh-mcp-vault.json",
"--timeout=30000",
"--maxChars=none"
]
}
}
}{
"account": "production",
"cwd": "/var/www/app",
"platformHint": "linux",
"multiSession": true
}If you call a vault-backed tool without account, runtime rejects the call and tells you to choose one of the configured account names.
{
"mcpServers": {
"termssh-mcp": {
"command": "npx",
"args": [
"-y",
"termssh-mcp",
"--",
"--host=1.2.3.4",
"--port=22",
"--user=root",
"--password=pass",
"--timeout=30000",
"--maxChars=none"
]
}
}
}{
"mcpServers": {
"termssh-mcp": {
"command": "npx",
"args": [
"-y",
"termssh-mcp",
"--",
"--host=example.com",
"--user=root",
"--key=/path/to/private/key",
"--timeout=30000"
]
}
}
}{
"mcpServers": {
"ssh-mcp": {
"command": "node",
"args": [
"D:/All_project/own/AI_Coder/MCP_Tools/ssh-mcp/build/index.js",
"--vault=D:/All_project/own/AI_Coder/MCP_Tools/ssh-mcp/termssh-mcp-vault.json",
"--timeout=1200000",
"--maxChars=50000"
]
}
}
}Register the server in Claude Code with direct credentials:
claude mcp add --transport stdio termssh-mcp -- npx -y termssh-mcp -- --host=YOUR_HOST --user=YOUR_USER --password=YOUR_PASSWORDRegister the server in Claude Code with a vault file:
claude mcp add --transport stdio termssh-mcp -- node build/index.js --vault=./termssh-mcp-vault.json --timeout=120000 --maxChars=noneWith SSH key authentication:
claude mcp add --transport stdio termssh-mcp -- npx -y termssh-mcp -- --host=example.com --user=root --key=/path/to/private/keyWith extended timeout:
claude mcp add --transport stdio termssh-mcp -- npx -y termssh-mcp -- --host=192.168.1.100 --user=admin --password=your_password --timeout=120000 --maxChars=noneThe vault flow has been verified against a live SSH connection:
termssh-mcp-vault.jsonloaded successfullyresolveSshConfigFromSources()resolved the active account correctly- interactive SSH session startup via
terminal-startsucceeded after fixing key-file loading
This means the recommended production path is now:
MCP config →
--vault=...→ active account selection → interactive terminal session
|
|
|
Build the project:
npm run buildRun tests:
npm testUse the MCP Inspector:
npm run inspectsrc/index.ts— MCP server entrypoint and tool registrationsrc/ssh-connection-manager.ts— SSH connection and terminal lifecycle handlingsrc/upload.ts— upload helpers and interactive session metadata helperssrc/core.ts— shared validation and SSH utility primitivestest/upload-and-terminal.test.ts— upload/session unit coveragetest/maxChars.test.ts— command validation coveragetest/smoke.ssh.test.ts— smoke tests for current exported behavior
- richer session metadata inspection
- better remote session observability
- optional session persistence features
- more examples for Claude Code and MCP tools
- deployment-oriented workflow templates
TermSSH MCP gives remote access to systems over SSH.
Use it only on infrastructure you own or are explicitly authorized to manage.
Released under the MIT License.
Contributions are welcome.
See CONTRIBUTING.md for contribution guidance and CODE_OF_CONDUCT.md for expected behavior.
