mcpField
S
ssh

ssh

Local
github.com/pulsemcpCloud & Infra81Updated 8w ago

About ssh

An MCP server for managing remote servers over SSH, with SSH agent authentication for passphrase-protected keys. It is aimed at users who want to avoid putting key passphrases in configuration. The private key stays inside the agent and is never read by the server.

Key features

  1. 01SSH agent authentication for passphrase-protected keys
  2. 02Private key file as fallback authentication
  3. 03Startup SSH connection health check
  4. 04Remote command execution and SFTP file transfer
  5. 05Tool groups that restrict available operations

Use cases

  1. 01Running shell commands on remote servers from an MCP client
  2. 02Uploading or downloading deployment files via SFTP
  3. 03Browsing remote directories in read-only mode

MCP support

This project is an MCP server that exposes ssh_execute, ssh_upload, ssh_download and ssh_list_directory tools, plus an ssh://config resource, to MCP clients.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"com-pulsemcp-ssh": {
"command": "npx",
"args": [
"-y",
"ssh-agent-mcp-server"
],
"env": {
"SSH_HOST": "<SSH_HOST>",
"SSH_USERNAME": "<SSH_USERNAME>",
"SSH_PORT": "<SSH_PORT>",
"SSH_AUTH_SOCK": "<SSH_AUTH_SOCK>",
"SSH_PRIVATE_KEY_PATH": "<SSH_PRIVATE_KEY_PATH>",
"SSH_PASSPHRASE": "<SSH_PASSPHRASE>",
"SSH_TIMEOUT": "<SSH_TIMEOUT>",
"SSH_COMMAND_TIMEOUT": "<SSH_COMMAND_TIMEOUT>",
"ENABLED_TOOLGROUPS": "<ENABLED_TOOLGROUPS>",
"SKIP_HEALTH_CHECKS": "<SKIP_HEALTH_CHECKS>",
"HEALTH_CHECK_TIMEOUT": "<HEALTH_CHECK_TIMEOUT>"
}
}
}
}
Run commandnpx -y ssh-agent-mcp-server
Environment variables to set
SSH_HOSTHostname or IP address of the SSH server.
SSH_USERNAMEUsername for SSH authentication.
SSH_PORTSSH port number.
SSH_AUTH_SOCKSecretPath to SSH agent socket for agent-based authentication.
SSH_PRIVATE_KEY_PATHSecretPath to private key file for direct key authentication.
SSH_PASSPHRASESecretPassphrase for encrypted private key.
SSH_TIMEOUTConnection timeout in milliseconds.
SSH_COMMAND_TIMEOUTDefault command activity timeout in milliseconds.
ENABLED_TOOLGROUPSComma-separated list of tool groups to enable (readonly, write, admin).
SKIP_HEALTH_CHECKSSkip SSH connection health check on startup.
HEALTH_CHECK_TIMEOUTHealth check timeout in milliseconds.

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmssh-agent-mcp-server0.1.5

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

SSH MCP Server

An MCP (Model Context Protocol) server for SSH remote server management with SSH agent authentication support.

This server solves a common problem with SSH MCP servers: support for passphrase-protected SSH keys. By using SSH agent authentication, you can securely connect to remote servers without exposing your key passphrase.

Highlights

  • SSH Agent Authentication - Seamlessly works with passphrase-protected SSH keys via SSH agent
  • Private Key File Support - Alternative authentication via direct private key file
  • Startup Health Check - Verifies SSH connectivity on startup with clear error messages
  • Command Execution - Run shell commands on remote servers
  • File Transfer - Upload and download files via SFTP
  • Directory Listing - Browse remote file systems
  • Tool Groups - Control which tools are available (readonly, write, admin)

Authentication Priority

The server supports multiple authentication methods and will use them in this order:

  1. SSH Agent (recommended) - If SSH_AUTH_SOCK is set or auto-detected
  2. Private Key File - If SSH_PRIVATE_KEY_PATH is set

Both methods can be configured simultaneously. If SSH agent authentication is available, it takes priority. The private key file method is used as a fallback or when the agent is not available.

Capabilities

Tools
ToolGroupDescription
ssh_connection_inforeadonly, write, adminGet configured SSH connection information
ssh_list_directoryreadonly, write, adminList directory contents on remote server
ssh_downloadreadonly, write, adminDownload file from remote server via SFTP
ssh_uploadwrite, adminUpload file to remote server via SFTP
ssh_executeadminExecute shell command on remote server
Resources
ResourceDescription
ssh://configSSH connection configuration and status (for debugging)
Tool Groups

Control which tools are available via the ENABLED_TOOLGROUPS environment variable:

GroupDescription
readonlySafe operations (connection info, list, download)
writeFile modifications (upload)
adminFull access including command execution

Examples:

  • ENABLED_TOOLGROUPS="readonly" - Only allow browsing and downloads
  • ENABLED_TOOLGROUPS="readonly,write" - Allow file transfers but no command execution
  • Not set - All tools enabled (default)
Startup Health Check

The server performs an SSH connection health check on startup to verify that the configured credentials and host are valid. This provides immediate feedback if there are configuration issues, rather than discovering them during workflow.

Benefits:

  • Faster feedback: Configuration errors surface at startup rather than mid-workflow
  • Clearer error messages: Startup failures include hints for common issues
  • Improved user experience: Eliminates ambiguity about server operational status

Configuration:

  • SKIP_HEALTH_CHECKS=true - Skip the health check (useful for lazy connection scenarios)
  • HEALTH_CHECK_TIMEOUT=10000 - Customize the health check timeout (default: 10 seconds)

Error hints provided for:

  • Authentication failures (SSH key not loaded, wrong key)
  • Connection timeouts (host unreachable)
  • Connection refused (SSH server not running)
  • DNS resolution errors (invalid hostname)

Quick Start

Installation
npx ssh-agent-mcp-server

Or install globally:

npm install -g ssh-agent-mcp-server
Configuration
Environment Variables
VariableRequiredDescriptionDefault
SSH_HOSTYesHostname or IP address of the SSH server-
SSH_USERNAMEYesUsername for SSH authentication-
SSH_PORTNoSSH port number22
SSH_AUTH_SOCKNoPath to SSH agent socketAuto-detected
SSH_PRIVATE_KEY_PATHNoPath to private key file-
SSH_PASSPHRASENoPassphrase for encrypted private key-
SSH_TIMEOUTNoConnection timeout in milliseconds30000
SSH_COMMAND_TIMEOUTNoDefault command activity timeout in milliseconds60000
ENABLED_TOOLGROUPSNoComma-separated tool groupsAll enabled
SKIP_HEALTH_CHECKSNoSkip SSH connection health check on startupfalse
HEALTH_CHECK_TIMEOUTNoHealth check timeout in milliseconds10000
Claude Desktop Configuration

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "ssh": {
      "command": "npx",
      "args": ["-y", "ssh-agent-mcp-server"],
      "env": {
        "SSH_HOST": "192.168.1.100",
        "SSH_USERNAME": "deploy",
        "SSH_AUTH_SOCK": "${SSH_AUTH_SOCK}"
      }
    }
  }
}

Restart Claude Desktop and you should be ready to go!

SSH Agent Authentication (Recommended)

SSH agent authentication is the recommended method for passphrase-protected keys:

  1. Ensure your SSH agent is running with your key loaded:

    # Check if agent is running
    ssh-add -l
    
    # If not, add your key
    ssh-add ~/.ssh/id_ed25519
    
  2. Pass the SSH_AUTH_SOCK environment variable to the MCP server

The server will automatically use the agent for authentication, and your passphrase-protected key stays secure in the agent.

How It Works
  1. Your passphrase-protected key is loaded into the SSH agent via ssh-add
  2. The agent exposes a Unix socket at $SSH_AUTH_SOCK
  3. This MCP server connects to that socket via the ssh2 library
  4. The agent signs authentication challenges using your decrypted key
  5. Your private key never leaves the agent - the MCP server never sees it

This is more secure than:

  • Storing your passphrase in environment variables
  • Using unprotected private keys
  • Manually entering passphrases

Tool Details

ssh_execute

Execute a command on the remote server.

Parameters:

  • command (required): Shell command to execute
  • cwd (optional): Working directory
  • timeout (optional): Activity timeout in milliseconds (default: 60000 or SSH_COMMAND_TIMEOUT)

Activity-based Timeout:

The timeout is activity-based rather than absolute. It resets whenever stdout or stderr output is received from the command. This allows long-running commands that produce periodic output (like builds, deployments, or claude -p commands) to complete successfully, while still timing out commands that hang with no activity.

For commands with delayed initial output (10-30+ seconds before any output), you can:

  1. Increase the default timeout via SSH_COMMAND_TIMEOUT environment variable
  2. Pass a higher timeout parameter for specific commands

Example:

{
  "command": "ls -la /var/log",
  "cwd": "/home/user"
}

Example with extended timeout for long-running commands:

{
  "command": "npm run build",
  "timeout": 300000
}

Returns: JSON with stdout, stderr, and exit code

ssh_upload

Upload a file to the remote server via SFTP.

Parameters:

  • localPath (required): Absolute path to local file
  • remotePath (required): Destination path on server
ssh_download

Download a file from the remote server via SFTP.

Parameters:

  • remotePath (required): Path on remote server
  • localPath (required): Local destination path
ssh_list_directory

List directory contents on the remote server.

Parameters:

  • path (required): Directory path to list

Returns: JSON array with filename, type, size, permissions, modified time

ssh_connection_info

Get information about the configured SSH connection.

Returns: JSON with host, port, username, and authentication details

Development

# Install dependencies
npm run install-all

# Build
npm run build

# Run in development mode
npm run dev

# Run tests
npm test
npm run test:integration

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.