ssh-mcp-dynamic
The ssh-mcp-dynamic server enables secure, key-based SSH command execution on remote hosts, with support for both regular and sudo commands, configurable per-call parameters, and environment-variable-based defaults.
Execute shell commands: Run arbitrary shell commands on remote servers via SSH using the
ssh_exectool.Execute privileged commands: Run commands with
sudoprivileges using thessh_sudo_exectool, which automatically prependssudo.Connect to multiple machines: Host, user, port, and key are all specified per call — not hardcoded — so a single server instance can target many machines.
Key-based authentication: Authenticate using PEM private keys via direct file paths (with
~expansion) or pre-configured named shortcuts (e.g.prod,staging) defined inSSH_MCP_KEYS. No passwords are handled or stored.Configurable defaults: Set default values for SSH key, username (default:
root), port (default:22), and timeout (default:60000ms) via environment variables to reduce repetition.MCP client integration: Designed for use with MCP clients like Claude Desktop and Claude Code, allowing natural language prompts to invoke its tools.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ssh-mcp-dynamicrun 'uptime' on prod-web1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ssh-mcp-dynamic
A minimal Model Context Protocol (MCP) server that lets an MCP client (e.g. Claude Desktop) run shell commands on remote hosts over SSH. The host, private key, user and port are chosen per call, so a single server instance can reach many machines.
It exposes two tools:
Tool | Description |
| Run a shell command on a remote host. |
| Run a shell command with |
Authentication is key-based only (PEM private keys). No passwords are handled or stored.
Requirements
Node.js 18+
SSH access to the target hosts with a private key
Related MCP server: ssh-chat-mcp
Install & build
npm install
npm run buildThis compiles src/index.ts to dist/index.js.
Configuration
Everything host-specific is supplied through environment variables — nothing is hardcoded in the source.
Variable | Default | Purpose |
|
| JSON object mapping key shortcuts to private-key paths. A leading |
| (none) | Shortcut or path used when a call omits |
|
| Default SSH username. |
|
| Default SSH port. |
|
| Default command/connection timeout in milliseconds. |
Example SSH_MCP_KEYS:
{
"prod": "~/keys/prod.pem",
"staging": "~/keys/staging.pem"
}With that set, a call can pass "key": "prod" instead of a full path. You can also pass a full path directly at call time without configuring any shortcut.
Tool parameters
Both tools accept:
host(required) — IP or hostname.command(required) — the shell command.key— a configured shortcut or a path to the PEM file. Required unlessSSH_MCP_DEFAULT_KEYis set.user— SSH username (defaults toSSH_MCP_DEFAULT_USER).port— SSH port (defaults toSSH_MCP_DEFAULT_PORT).timeout— timeout in ms (defaults toSSH_MCP_TIMEOUT_MS).
Use with Claude Code (CLI)
The quickest way — no clone, no manual build. Claude Code runs it on demand via npx straight from GitHub.
Minimal — no environment config at all. You provide the host, command and a full key path on every call:
claude mcp add ssh-mcp -- npx -y github:Calevi-Consulting/ssh-mcp-dynamicWith shortcuts and defaults — preconfigure your keys once so calls can use a short name (e.g. prod) and omit the user/port:
claude mcp add ssh-mcp -s user \
-e SSH_MCP_KEYS='{"prod":"~/keys/prod.pem"}' \
-e SSH_MCP_DEFAULT_KEY=prod \
-e SSH_MCP_DEFAULT_USER=ubuntu \
-- npx -y github:Calevi-Consulting/ssh-mcp-dynamicnpx clones the repo, builds it (via the prepare script) and launches the server. Once published to npm you can drop the github: prefix and use npx -y ssh-mcp-dynamic.
Prefer a local checkout? Build it once and point Claude Code at the compiled file:
git clone https://github.com/Calevi-Consulting/ssh-mcp-dynamic.git
cd ssh-mcp-dynamic && npm install && npm run build
claude mcp add ssh-mcp -s user \
-e SSH_MCP_KEYS='{"prod":"~/keys/prod.pem"}' \
-e SSH_MCP_DEFAULT_KEY=prod \
-- node "$(pwd)/dist/index.js"Scopes (-s): local (default, current project only), user (all your projects), project (saved to a versioned .mcp.json to share with your team).
Verify with claude mcp list, or /mcp inside a session. Remove with claude mcp remove ssh-mcp.
Use with Claude Desktop
Add the server to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ssh-mcp": {
"command": "node",
"args": ["/absolute/path/to/ssh-mcp-dynamic/dist/index.js"],
"env": {
"SSH_MCP_KEYS": "{\"prod\":\"~/keys/prod.pem\",\"staging\":\"~/keys/staging.pem\"}",
"SSH_MCP_DEFAULT_KEY": "prod",
"SSH_MCP_DEFAULT_USER": "ubuntu"
}
}
}
}Restart Claude Desktop after editing the config.
Usage
Once the server is registered, you don't call the tools directly — you ask your MCP client (Claude Code / Claude Desktop) in plain language and it invokes ssh_exec / ssh_sudo_exec for you. Some example prompts:
Using ssh-mcp, run `hostname && uptime` on 10.0.0.5 with the prod key.
Check the free disk space on staging.example.com (df -h) via ssh-mcp.
On 10.0.0.5, tail the last 50 lines of /var/log/syslog with sudo.
Restart nginx on web-01.example.com with sudo, then show `systemctl status nginx`.
Run `docker ps` on 203.0.113.10 as user ubuntu on port 2222 using ~/keys/prod.pem.How those map to a tool call (the client fills this in for you):
// "run hostname on 10.0.0.5 with the prod key"
{
"tool": "ssh_exec",
"host": "10.0.0.5",
"command": "hostname",
"key": "prod" // a configured shortcut, or a full path like ~/keys/prod.pem
}
// "tail syslog with sudo on 10.0.0.5"
{
"tool": "ssh_sudo_exec",
"host": "10.0.0.5",
"command": "tail -n 50 /var/log/syslog" // no 'sudo' prefix — the tool adds it
}Tips:
Mention the host, the command, and which key/user/port when they aren't the configured defaults.
Naming the server ("using ssh-mcp…") helps the client pick the right tool when you have several MCP servers registered.
For privileged commands ask for "with sudo" so the client uses
ssh_sudo_exec— and don't putsudoin the command yourself.
Security notes
This server executes arbitrary shell commands on remote hosts, including with
sudoviassh_sudo_exec. Only connect it to hosts and keys you control, and only run it with an MCP client you trust.Private keys are read from disk at call time. Never commit private keys —
*.pem,*.key, and common key filenames are already in.gitignore.Prefer keys that are passphrase-protected or scoped to specific hosts.
The server communicates over stdio with the local MCP client; it does not open any network listener of its own.
License
Available Tools
2 toolsssh_execC
Execute a shell command on a remote host via SSH.
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Provide a configured key shortcut or a full path to the private key file (supports a leading ~ for the home directory). | |
| host | Yes | IP address or hostname of the remote server | |
| port | No | SSH port (default: 22) | |
| user | No | SSH username (default: root) | root |
| command | Yes | Shell command to execute on the remote server | |
| timeout | No | Timeout in milliseconds (default: 60000) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, and the description does not disclose behavioral traits such as potential side effects, security implications, or idempotency. For a command execution tool, this is a significant gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One concise sentence with no fluff. However, it could be more informative while remaining concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 6 parameters, no output schema, and no annotations, the description is too minimal. It fails to explain return behavior, error handling, or prerequisites, making it incomplete for safe and effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema itself defines all parameters. The description adds no additional meaning or usage hints beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (execute) and resource (shell command on remote host via SSH). However, it does not explicitly differentiate from the sibling tool ssh_sudo_exec; the distinction is implied.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives (e.g., ssh_sudo_exec). Lacks when-not or context for selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
ssh_sudo_execB
Execute a shell command with sudo on a remote host via SSH.
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Provide a configured key shortcut or a full path to the private key file (supports a leading ~ for the home directory). | |
| host | Yes | IP address or hostname of the remote server | |
| port | No | SSH port (default: 22) | |
| user | No | SSH username (default: root) | root |
| command | Yes | Shell command to execute with sudo (do not include 'sudo' prefix) | |
| timeout | No | Timeout in milliseconds (default: 60000) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses that the command runs with sudo but does not mention authentication requirements, key handling specifics, potential side effects, or error conditions. The disclosure is minimal beyond the core purpose.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that conveys the core purpose without waste. It could include slightly more context (e.g., mentioning the key parameter or that 'sudo' should not be included in the command) without becoming verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With 6 parameters, no output schema, and no annotations, the description is too brief to be complete. It lacks details about return values, error handling, authentication process, and usage caveats. The description only covers the basic purpose, leaving significant gaps for an agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% coverage with descriptions for all 6 parameters. The description adds no additional meaning beyond what the schema already provides. Baseline score is appropriate given the schema's thoroughness.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Execute' and the resource 'a shell command with sudo on a remote host via SSH'. It distinguishes this tool from the sibling tool ssh_exec by explicitly mentioning 'with sudo', making its unique purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when sudo is needed but does not provide explicit guidance on when to use this versus ssh_exec, nor does it mention prerequisites or scenarios where this tool should be avoided. The context is implied but not clearly stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
2 tool updates
v1.0.0- First observed
ssh_exec - First observed
ssh_sudo_exec
TDQS
The two tools have clearly distinct purposes: one for regular commands, one for privileged commands with sudo. No ambiguity.
Both tools follow a consistent 'ssh_verb' pattern with underscores, using 'ssh_exec' and 'ssh_sudo_exec'.
Two tools is slightly below the typical range but appropriate for the narrow domain of remote command execution, covering the essential distinction.
The set covers the core operations for remote command execution (regular and sudo), but lacks additional utilities like file transfer or key management.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Run commands and read/write files on your servers over Termalin's keyless tunnels (hosted MCP).
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Zero-install remote MCP server for proof-of-existence file attestation.
Related MCP Servers
- AlicenseBqualityDmaintenanceA server that enables remote command execution over SSH through the Model Context Protocol (MCP), supporting both password and private key authentication.112MIT
- AlicenseAqualityDmaintenanceZero-config SSH/SFTP MCP server that lets an LLM client open temporary SSH/SFTP sessions to remote hosts, run commands, and upload/download files without holding any pre-baked credentials.17102MIT
- AlicenseNot gradedqualityAmaintenanceA local MCP server that enables LLMs to execute shell commands on remote hosts over SSH with multiple authentication methods.353MIT
- AlicenseNot gradedqualityDmaintenanceA minimal MCP server that executes commands on remote hosts by delegating to the local ssh binary, supporting batch-mode execution and optional timeout.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Calevi-Consulting/ssh-mcp-dynamic'
If you have feedback or need assistance with the MCP directory API, please join our Discord server