MCP server for remote SSH management
## SSH MCP Server: Remote Server Access The **SSH MCP Server** integrates SSH connectivity into Google Antigravity, enabling secure remote server access, command execution, and file transfer directly from your development environment. ### Why SSH MCP? - **Secure Connectivity**: Encrypted connections with key-based and password authentication - **Multi-Server Management**: Connect to multiple servers and switch between sessions - **File Transfer**: Upload and download files using SCP/SFTP protocols - **Port Forwarding**: Set up local and remote port tunnels for service access - **Session Persistence**: Maintain long-running sessions with automatic reconnection ### Key Features #### 1. Remote Commands ```python # Execute a command on remote server result = await mcp.exec( host="server.example.com", command="df -h", username="admin", key_file="~/.ssh/id_rsa" ) print(f"Exit code: {result['exit_code']}") print(result["stdout"]) ``` #### 2. Session Management ```python # Create a persistent session session = await mcp.connect( host="server.example.com", username="admin", key_file="~/.ssh/id_rsa" ) # Run multiple commands in same session await mcp.session_exec(session["id"], "cd /app") result = await mcp.session_exec(session["id"], "git pull") # Close session await mcp.disconnect(session_id=session["id"]) ``` #### 3. File Transfer ```python # Upload a file await mcp.upload( host="server.example.com", local_path="./build/app.tar.gz", remote_path="/app/releases/app.tar.gz", username="deploy" ) # Download files await mcp.download( host="server.example.com", remote_path="/var/log/app.log", local_path="./logs/app.log" ) # List remote directory files = await mcp.list_dir( host="server.example.com", path="/var/log" ) ``` #### 4. Port Forwarding ```python # Create local port forward (access remote service locally) tunnel = await mcp.forward_local( host="server.example.com", local_port=5432, remote_host="localhost", remote_port=5432 ) # Remote port forward (expose local service remotely) await mcp.forward_remote( host="server.example.com", remote_port=8080, local_host="localhost", local_port=3000 ) ``` ### Configuration ```json { "mcpServers": { "ssh": { "command": "npx", "args": ["-y", "@anthropic/mcp-ssh"], "env": { "SSH_DEFAULT_KEY": "~/.ssh/id_rsa", "SSH_CONFIG_FILE": "~/.ssh/config", "SSH_KNOWN_HOSTS": "~/.ssh/known_hosts" } } } } ``` ### Use Cases **Server Administration**: Execute administrative commands across multiple servers without switching terminal contexts. **Log Retrieval**: Download log files from production servers for local analysis and debugging. **Database Tunneling**: Create SSH tunnels to securely access remote databases without exposing ports publicly. **Deployment**: Upload application artifacts and execute deployment scripts on target servers. The SSH MCP enables secure remote server management directly within your Google Antigravity development environment.
{
"mcpServers": {
"ssh": {
"mcpServers": {
"ssh": {
"env": {
"SSH_HOST": "your-server.com",
"SSH_USER": "root",
"SSH_KEY_PATH": "~/.ssh/id_rsa"
},
"args": [
"-y",
"ssh-mcp"
],
"command": "npx"
}
}
}
}
}