SSH MCP is a tool that provides SSH functionality through an MCP (Machine Communication Protocol) interface. It allows you to connect to SSH servers, execute commands, transfer files, and manage SSH sessions.
- SSH connection management (connect/disconnect)
- Authentication methods (password, key-based)
- Command execution with timeout handling
- File transfer (upload/download)
- Directory listing
- Session management
- Security features (host allowlist/denylist, command filtering, rate limiting)
main.go: The main application entry pointinternal/: Internal packagesssh/: SSH client functionalitysession/: Session managementfile/: File operationssecurity/: Security featuresserver/: MCP server implementation
e2e/: End-to-end tests
This project uses testcontainers for end-to-end testing with a real SSH server.
The e2e directory contains end-to-end tests that verify the SSH MCP tool works correctly with a real SSH server. These tests use testcontainers to automatically create and manage an SSH server container for testing.
For more details, see e2e/README.md.
- Docker
- Go 1.24 or later
- Clone the repository
- Start the SSH MCP server:
# Start with HTTP transport (default)
go run main.go
# Or specify the transport explicitly
go run main.go -t http
# Start with stdio transport
go run main.go -t stdioWhen using HTTP transport, the server will start on port 8081.
# Unit tests
go test ./internal/...
# End-to-end tests
cd e2e
go test -vThe end-to-end tests will automatically start the necessary containers and servers for testing.
The SSH MCP tool provides the following tools:
ssh_connect: Establish an SSH connectionssh_execute: Execute a command over SSHssh_disconnect: Close an SSH connectionssh_list_sessions: List active SSH sessionsssh_upload_file: Upload a file to the SSH serverssh_download_file: Download a file from the SSH serverssh_list_directory: List contents of a directory on the SSH serverssh_upload_directory: Upload a directory to the SSH serverssh_download_directory: Download a directory from the SSH server
These tools can be accessed through the MCP interface at http://localhost:8081/mcp (HTTP transport) or via standard input/output (stdio transport).