A Model Context Protocol (MCP) based SSH connection tool that allows large language models to securely connect to remote servers via SSH and perform file operations through the MCP protocol.
- SSH Connection Management: Connect to remote SSH servers
- Command Execution: Execute commands on remote servers
- File Transfer: Upload and download files
- Session Management: Maintain and close SSH sessions
- Python >= 3.12
- uv package manager
# Clone the project
git clone https://github.com/ffpy/my-mcp-ssh.git
# Enter the project directory
cd my-mcp-ssh
# Install dependencies
uv sync
{
"mcpServers": {
"my-mcp-ssh": {
"command": "uv",
"args": [
"--directory",
"<your_path>/my-mcp-ssh",
"run",
"src/main.py"
],
"env": {}
}
}
}
SSH connection parameters can be configured through environment variables:
SSH_HOST
: SSH server hostname or IP addressSSH_PORT
: SSH server portSSH_USERNAME
: SSH usernameSSH_PASSWORD
: SSH password (if using password authentication)SSH_KEY_PATH
: SSH private key file path (if using key authentication)SSH_KEY_PASSPHRASE
: SSH private key passphrase (if needed)SESSION_TIMEOUT
: Session timeout in minutes, default is 30 minutesMAX_OUTPUT_LENGTH
: Maximum command output length in characters, default is 5000 characters
Connect to an SSH server
Parameters:
host
: SSH server hostname or IP address, defaults toSSH_HOST
environment variableport
: SSH server port, defaults toSSH_PORT
environment variable or22
username
: SSH username, defaults toSSH_USERNAME
environment variablepassword
: SSH password, defaults toSSH_PASSWORD
environment variablekey_path
: SSH private key file path, defaults toSSH_KEY_PATH
environment variable or~/.ssh/id_rsa
key_passphrase
: SSH private key passphrase, defaults toSSH_KEY_PASSPHRASE
environment variable
Disconnect from an SSH session
Parameters:
session_id
: The session ID to disconnect
List all active SSH sessions
Parameters:
- None
Execute a command on the SSH server
Parameters:
session_id
: Session IDcommand
: Command to executestdin
: Input string to provide to the command, default is emptytimeout
: Command timeout in seconds, default is 60 seconds
Upload a file to the SSH server
Parameters:
session_id
: Session IDlocal_path
: Local file pathremote_path
: Remote file path
Download a file from the SSH server
Parameters:
session_id
: Session IDremote_path
: Remote file pathlocal_path
: Local file path
Run ./inspector.sh
for online debugging
my-mcp-ssh is licensed under the Apache License, Version 2.0