Skip to main content
Glama
ssh-agent-mcp
by zhijun

SSH Agent MCP

License: MIT

中文文档 README_CN.md

Manage SSH and SFTP via MCP tools for AI assistants.

SSH Agent MCP is a Python-based MCP (Model Context Protocol) stdio server that lets AI assistants manage SSH connections, execute commands, and transfer files via SFTP. It supports zero-argument startup, pure CLI configuration, and JSON config files, making it simple to operate multiple remote servers securely.

  • Requires: Python >= 3.12

  • Project status: Beta

Why uvx?

  • No local install: run uvx ssh-agent-mcp@latest directly

  • Always up-to-date: pin to @latest for consistent versioning

  • Ideal for desktop assistants: simplest setup for Claude Desktop

Related MCP server: mcp-ssh

Why SSH Agent MCP?

  • Multiple concurrent sessions: manage and track many SSH connections at once

  • Async long-running tasks: stream outputs and control jobs like top, tail, logs

  • Built-in SFTP: upload/download, list, mkdir, remove, and rename directories/files

  • Auto keepalive & reconnect: maintain session health and minimize drops

  • Interactive commands: handle sudo, shells, editors with input events

Install

  • Recommended (no local install): uvx ssh-agent-mcp@latest

  • Pip (use PyPI to avoid cached mirrors): pip install -i https://pypi.org/simple ssh-agent-mcp

  • Externally managed environments: use virtualenv or pipx

    • python -m venv .venv && source .venv/bin/activate

    • pipx install ssh-agent-mcp

Quick Start

Run via uvx (Claude Desktop)

Minimal config:

{
  "mcpServers": {
    "ssh-mcp": {
      "command": "uvx",
      "args": ["ssh-agent-mcp@latest"]
    }
  }
}

The assistant can then connect using ssh_connect or ssh_connect_by_name.

CLI examples

  • Zero-argument startup: ssh-agent-mcp

  • Direct params: ssh-agent-mcp --host example.com --user admin --password secret

  • With config file: ssh-agent-mcp --config /path/to/ssh_config.json --connection production

Minimal config file

ssh_config.json:

{
  "connections": [
    {
      "name": "production",
      "host": "prod.example.com",
      "username": "admin",
      "private_key": "/home/user/.ssh/id_rsa"
    }
  ],
  "auto_connect": ["production"]
}

Tools (MCP)

  • Connection: ssh_connect, ssh_connect_by_name, ssh_disconnect, ssh_list_connections

  • Commands: ssh_execute, ssh_execute_interactive, ssh_execute_async

  • Lifecycle: ssh_check_status, ssh_terminate, ssh_list_async

  • SFTP: sftp_upload, sftp_download, sftp_list, sftp_mkdir, sftp_remove, sftp_rename

  • Files: remote_read_file, remote_write_file

  • Status: ssh_status

Example: Connect and Execute

{
  "tool": "ssh_connect",
  "params": {
    "name": "prod",
    "host": "prod.example.com",
    "username": "admin",
    "private_key": "/home/user/.ssh/id_rsa"
  }
}
{
  "tool": "ssh_execute",
  "params": {
    "connection": "prod",
    "command": "uname -a"
  }
}

Notes

  • Prefer uvx ssh-agent-mcp@latest for frictionless use.

  • If domestic mirrors cache old versions, specify PyPI index explicitly.

  • For full CLI options and advanced usage, see the Chinese guide: README_CN.md.

License

MIT License. See LICENSE.

Available Tools

27 tools
ssh_auto_connectA

自动连接配置文件中标记为auto_connect的连接

Inputs: no named parameters.

ssh_cleanup_commandsC

清理已完成的异步命令

Inputs: max_age.

ssh_connectC

建立SSH连接

Inputs: host (required), username (required), port, password, +2 more.

ssh_connect_by_config_hostC

使用SSH config文件中的主机名建立连接

Inputs: config_host (required), username, password, private_key, +1 more.

ssh_connect_by_nameB

使用配置文件中的连接名称建立SSH连接

Inputs: connection_name (required).

ssh_create_remote_directoryB

在远程服务器上创建目录

Inputs: connection_id (required), remote_path (required), mode, parents.

ssh_disconnectC

断开SSH连接

Inputs: connection_id (required).

ssh_disconnect_allB

断开所有SSH连接

Inputs: no named parameters.

ssh_download_fileC

从远程服务器下载文件

Inputs: connection_id (required), remote_path (required), local_path (required).

ssh_executeB

在SSH连接上执行命令

Inputs: connection_id (required), command (required), timeout.

ssh_get_command_statusA

获取异步命令状态和最新输出

Inputs: command_id (required).

ssh_get_interactive_outputB

获取交互式会话的输出

Inputs: session_id (required), max_lines.

ssh_get_remote_file_infoB

获取远程文件或目录信息

Inputs: connection_id (required), remote_path (required).

ssh_list_async_commandsB

列出所有异步命令状态

Inputs: no named parameters.

ssh_list_configB

列出配置文件中的所有SSH连接

Inputs: filter_tag.

ssh_list_connectionsB

列出所有SSH连接

Inputs: no named parameters.

ssh_list_interactive_sessionsA

列出所有活跃的交互式会话

Inputs: no named parameters.

ssh_list_remote_directoryC

列出远程目录内容

Inputs: connection_id (required), remote_path.

ssh_remove_remote_fileB

删除远程文件或目录

Inputs: connection_id (required), remote_path (required).

ssh_rename_remote_pathB

重命名远程文件或目录

Inputs: connection_id (required), old_path (required), new_path (required).

ssh_send_inputA

向交互式会话发送输入(如密码、命令等)

Inputs: session_id (required), input_text (required).

ssh_start_async_commandB

启动长时间运行的异步命令

Inputs: connection_id (required), command (required).

ssh_start_interactiveC

启动交互式SSH会话(支持sudo、vim、mysql等需要交互输入的命令)

Inputs: connection_id (required), command (required), pty_width, pty_height.

ssh_statusB

查询SSH连接状态

Inputs: connection_id.

ssh_terminate_commandB

终止正在运行的异步命令

Inputs: command_id (required).

ssh_terminate_interactiveC

终止交互式会话

Inputs: session_id (required).

ssh_upload_fileB

上传文件到远程服务器

Inputs: connection_id (required), local_path (required), remote_path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 27 tools

    Disambiguation4/5

    Tools are mostly distinct with clear purposes, but there is some overlap among connect variations (auto_connect, connect_by_config_host, connect_by_name) and execution types (execute, async, interactive). Descriptions help differentiate, but the large number of similar-sounding tools could cause confusion.

    Naming Consistency5/5

    All tools follow the consistent pattern 'ssh_verb_noun' in snake_case, making it easy to predict tool names and understand their actions. No mixing of conventions.

    Tool Count4/5

    27 tools is slightly above the typical well-scoped range, but each tool addresses a specific need (connection, file ops, sync/async/interactive commands). The count is justified for the breadth of SSH management tasks.

    Completeness5/5

    The tool surface covers the full lifecycle: connect/disconnect, file transfer, directory operations, synchronous and asynchronous commands, interactive sessions, and status management. No obvious gaps for standard SSH operations.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to securely connect to and manage remote servers via SSH, supporting command execution, file transfers via SFTP, and multi-server management with both password and SSH key authentication.
      9
      34 npm
      2
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI models to access and manage SSH connections through a standardized interface, allowing AI assistants to perform SSH operations like connecting to servers, executing commands, and managing files.
      23
      81
      ISC
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to execute commands and transfer files on remote servers over SSH connections.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to execute SSH commands and perform token-efficient file operations on remote servers via the Model Context Protocol.
      5
      99 npm
      13
      MIT