ssh mcp server
A Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.
A Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.
A Model Context Protocol (MCP) server implementation that provides SSH capabilities. This server allows for secure remote access and execution through the MCP protocol.
git clone <repository-url>
cd ssh-server
npm install
npm run build
The server uses a SQLite database (ssh.db
) to store SSH credentials. The
database file will be created automatically when the server starts.
The server provides the following tools:
Execute a command over SSH.
Input Parameters:
host
: The host to connect to. (required)command
: The command to execute. (required)username
: The username to use for the SSH connection. (required)privateKeyPath
: The path to the private key file. (required)Example Usage:
{
"tool_name": "ssh_exec",
"arguments": {
"host": "example.com",
"command": "ls -l",
"username": "user",
"privateKeyPath": "/path/to/private/key"
}
}
Note: The privateKeyPath
must be a valid path to a private key file.
Add a new SSH credential.
Input Parameters:
name
: The name of the credential. (required)host
: The host to connect to. (required)username
: The username to use for the SSH connection. (required)privateKeyPath
: The path to the private key file. (required)Example Usage:
{
"tool_name": "add_credential",
"arguments": {
"name": "my_credential",
"host": "example.com",
"username": "user",
"privateKeyPath": "/path/to/private/key"
}
}
Note: The privateKeyPath
must be a valid path to a private key file.
List all stored SSH credentials.
Input Parameters:
Example Usage:
{
"tool_name": "list_credentials",
"arguments": {}
}
Remove a stored SSH credential.
Input Parameters:
name
: The name of the credential to remove. (required)Example Usage:
{
"tool_name": "remove_credential",
"arguments": {
"name": "my_credential"
}
}
npm start
The server will start running on the configured port (default settings can be modified in the source code).
src/
- Source code directorybuild/
- Compiled JavaScript outputnode_modules/
- Project dependencies@modelcontextprotocol/sdk
: MCP protocol implementationsqlite3
: SQLite database drivertypescript
: Development dependency for TypeScript supportTo make changes to the project:
src/
directorynpm run build
npm start
ISC
[
{
"description": "Execute command over SSH using private key file path",
"inputSchema": {
"properties": {
"command": {
"type": "string"
},
"host": {
"type": "string"
},
"privateKeyPath": {
"type": "string"
},
"username": {
"type": "string"
}
},
"required": [
"host",
"command",
"username",
"privateKeyPath"
],
"type": "object"
},
"name": "ssh_exec"
},
{
"description": "Add a new SSH credential with private key file path",
"inputSchema": {
"properties": {
"host": {
"type": "string"
},
"name": {
"type": "string"
},
"privateKeyPath": {
"type": "string"
},
"username": {
"type": "string"
}
},
"required": [
"name",
"host",
"username",
"privateKeyPath"
],
"type": "object"
},
"name": "add_credential"
},
{
"description": "List all stored SSH credentials",
"inputSchema": {
"properties": {},
"required": [],
"type": "object"
},
"name": "list_credentials"
},
{
"description": "Remove a stored SSH credential",
"inputSchema": {
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"name": "remove_credential"
},
{
"description": "Copy files/directories between local and remote server via rsync",
"inputSchema": {
"properties": {
"credentialName": {
"description": "Name of the stored credential to use",
"type": "string"
},
"direction": {
"description": "Direction of copy (toRemote or fromRemote)",
"enum": [
"toRemote",
"fromRemote"
],
"type": "string"
},
"localPath": {
"description": "Path on the local machine",
"type": "string"
},
"remotePath": {
"description": "Path on the remote server",
"type": "string"
}
},
"required": [
"credentialName",
"localPath",
"remotePath",
"direction"
],
"type": "object"
},
"name": "rsync_copy"
}
]