Skip to main content
Glama
guozhiwei01

ai-ssh-mcp

by guozhiwei01

ai-ssh-mcp

Natural language SSH server management via Claude Code.

Stop copying commands from AI to your terminal. This MCP server lets Claude Code connect directly to your servers — read logs, check services, run commands, transfer files — all in one conversation.


Features

  • Read logs — tail Laravel / nginx logs with keyword filtering

  • Service status — check nginx, php-fpm, mysql, redis and system resources (memory, disk, load)

  • Execute commands — run any shell command with a write-operation confirmation step

  • File transfer — upload / download files via SFTP

  • Batch execute — run a command across multiple servers in parallel, filtered by tag

  • Safety layer — blacklist for destructive commands, confirmation prompts for write ops, operation log

  • Fuzzy server matching — refer to servers by partial name (e.g. "生产API" matches "生产-API主服务器")

  • Connection reuse — SSH connections are cached for the session


Related MCP server: MCP SSH Server with Streamable HTTP

Prerequisites


Installation

No cloning required. Add the following to your project's .mcp.json:

{
  "mcpServers": {
    "ai-ssh-mcp": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/guozhiwei01/ai-ssh-mcp", "ai-ssh-mcp"]
    }
  }
}

Restart Claude Code. On first run, the config directory is created automatically at ~/.config/ai-ssh-mcp/ with a template servers.json copied in.


Configuration

1. Server list (~/.config/ai-ssh-mcp/servers.json)

The template is created automatically on first run. Edit it to add your servers:

{
  "servers": [
    {
      "name": "生产-API主服务器",
      "host": "47.x.x.1",
      "port": 22,
      "username": "root",
      "auth": {
        "type": "privateKey",
        "path": "~/.ssh/id_rsa"
      },
      "tags": ["prod", "api"],
      "projects": [
        {
          "name": "shop",
          "path": "/var/www/shop",
          "log": "/var/www/shop/storage/logs/laravel.log",
          "nginx_log": "/var/log/nginx/shop_error.log",
          "fpm_pool": "shop"
        }
      ]
    }
  ]
}

Key fields:

Field

Description

name

Display name (Chinese-friendly). Claude uses this to identify servers.

host

IP address or hostname

port

SSH port, default 22

username

SSH login user

auth.type

privateKey or password

auth.path

Path to private key file (supports ~)

auth.env_key

For password auth: the .env variable name that holds the password

tags

Used for batch operations, e.g. ["prod", "api"]

projects

List of deployed projects with log paths

2. Credentials (~/.config/ai-ssh-mcp/.env)

For password-authenticated servers, create ~/.config/ai-ssh-mcp/.env:

SERVER_生产数据库_PASSWORD=your_password_here

Private key auth needs no .env entries — just make sure the key file exists at the configured path.


Usage Examples

Once connected, talk to Claude naturally:

"列出所有服务器"

"看一下生产 API 服务器上 shop 项目最近的报错"

"检查生产数据库的服务状态"

"在测试环境重启 nginx" (Claude will ask for confirmation)

"所有 prod 服务器的磁盘使用情况"

"把本地的 config.php 上传到生产-API主服务器的 /var/www/shop/config.php"


Available Tools

Tool

Description

list_servers

List all configured servers

read_logs

Read project log files (app or nginx), with optional keyword filter

service_status

Check service health and system resources

exec_command

Run any shell command (write ops require confirmation)

transfer_file

Upload or download files via SFTP

batch_exec

Run a command on multiple servers in parallel


Security

  • Blacklist: rm -rf /, mkfs, dd if=...of=/dev, shutdown, reboot, halt, poweroff are always blocked.

  • Confirmation: Any write operation (restart, kill, file modification, package install, etc.) returns a confirmation prompt before executing.

  • Operation log: All executed commands are recorded in ~/.config/ai-ssh-mcp/operation.log — format: timestamp | server | user | command | exit_code.

  • Secrets: servers.json and .env live in your home directory and are never part of this repo.


License

MIT

Available Tools

6 tools
batch_execA
在多台服务器上同时执行同一命令。

参数:
- command: 要执行的 Shell 命令
- tag: 按标签筛选服务器,如"prod"、"api"
- servers: 指定服务器名列表,如["生产-API主服务器", "测试环境"]
- confirmed: 写操作时需确认后传 True
tag 和 servers 至少填一个。
ParametersJSON Schema
NameRequiredDescriptionDefault
tagNo
commandYes
serversNo
confirmedNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It mentions multi-server execution and the confirmed flag for write operations, but lacks details on permissions, error handling, or limits. Some transparency but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise with a clear main line followed by a bullet list for parameters and a constraint. No unnecessary words; every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters (1 required) and an output schema existing, the description covers the essential usage and constraints. It could mention what the tool returns (though output schema may handle that), but it's adequate for invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must add meaning. It fully explains each parameter: command is a Shell command, tag filters servers, servers is a list of server names, confirmed is for write confirmation. This goes beyond the schema's type-only definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'execute the same command on multiple servers simultaneously', which is a specific verb+resource. It distinguishes from sibling tools like exec_command (likely single server) by emphasizing multi-server execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides guidelines: parameters tag and servers must have at least one, and for write operations, confirmed must be True. It doesn't explicitly mention when to use alternatives like exec_command, but the constraint is helpful.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

exec_commandB
在指定服务器上执行任意 Shell 命令。

参数:
- server: 服务器中文名
- command: 要执行的 Shell 命令
- confirmed: 写操作时需用户确认后传 True,默认 False
ParametersJSON Schema
NameRequiredDescriptionDefault
serverYes
commandYes
confirmedNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description carries full burden. It discloses that write operations require user confirmation via the 'confirmed' parameter, adding safety context. However, it does not detail permissions, logging, or implications of arbitrary command execution.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with bulleted parameter list. It front-loads the main action. Could be slightly more structured but efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having an output schema, the description lacks usage context, differentiation from sibling tools, and behavioral details. An agent would struggle to know when to choose this tool over alternatives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%. The description adds meaning to all three parameters: server (Chinese name), command (shell command), confirmed (confirmation for write ops, default false). This compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes arbitrary shell commands on a specified server. It distinguishes from siblings by its focus on single-server command execution, though not explicitly mentioned.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus siblings like batch_exec or read_logs. The description lacks explicit when/when-not scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_serversA

列出所有配置的服务器及其基本信息(名称、IP、标签、项目)。

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states the basic listing behavior. It fails to disclose potential traits like access restrictions, rate limits, or whether the list includes all servers without filtering or pagination.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose and includes key output details, with no redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and an existing output schema, the description adequately covers the tool's action and output details (name, IP, tags, project). No gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are zero parameters, so the description cannot add value beyond the schema. Baseline for 0 parameters is 4, and the description correctly omits unnecessary parameter details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'list' and resource 'servers', and specifies included fields (name, IP, tags, project). It distinguishes well from sibling tools that focus on executing commands, reading logs, or managing services.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving server information, but provides no explicit when-to-use or when-not-to-use guidance, nor alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_logsA
读取指定服务器上某个项目的日志文件。

参数:
- server: 服务器中文名,如"生产-API主服务器"
- project: 项目名,如"shop"。服务器只有一个项目时可省略
- log_type: "app"(默认,Laravel log)或 "nginx"(nginx error log)
- lines: 读取最后 N 行,默认 100
- keyword: 关键词过滤,只返回包含该词的行,如"ERROR"
ParametersJSON Schema
NameRequiredDescriptionDefault
linesNo
serverYes
keywordNo
projectNo
log_typeNoapp

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries full burden. It describes the tool as a read operation and explains parameters but does not disclose potential side effects, authentication requirements, or rate limits. The nature of reading logs is low risk so this is adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficient and front-loaded with the purpose. It uses a bullet-style layout. However, it repeats parameter names in the same fashion as the schema, slightly increasing redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema and the moderate complexity (5 parameters, 1 required), the description covers parameter usage well. It lacks details about output format, but this is partially offset by the output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description compensates thoroughly by explaining each parameter with examples and default values. It adds meaning beyond the schema structure, especially for server, project, log_type, and keyword.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reads log files from a server and project, specifying the action and resource. It distinguishes from sibling tools like exec_command or list_servers which perform different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides detailed parameter guidance, including defaults and when to omit optional fields. However, it does not explicitly compare with sibling tools or state when not to use this tool, leaving usage context somewhat implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

service_statusA
检查服务器上关键服务的运行状态和系统资源。

参数:
- server: 服务器中文名
- services: 指定要检查的服务列表(可选),默认检查 nginx/php-fpm/mysql/redis 及系统资源
ParametersJSON Schema
NameRequiredDescriptionDefault
serverYes
servicesNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden. It discloses basic behavior (checking status and resources) and default services, but lacks information on side effects, permissions, or rate limits. It is adequate but not detailed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise, with two sentences plus parameter explanations. Every sentence adds value, no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity, the description covers purpose and parameters well. Output schema exists to explain return values, so no need for that here. It misses only minor details like error handling or prerequisites.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description compensates by explaining 'server' is the Chinese name and 'services' is an optional list with defaults (nginx, php-fpm, mysql, redis, system resources). This adds valuable context beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool checks running status and system resources of key services on a server, with explicit verb and resource. It distinguishes well from sibling tools like exec_command and read_logs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the use case (checking service status) but does not explicitly state when to use this tool versus alternatives. No exclusion criteria or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

transfer_fileA
在本地和服务器之间传输文件(SFTP)。

参数:
- server: 服务器中文名
- direction: "upload"(上传)或 "download"(下载)
- local_path: 本地文件路径
- remote_path: 服务器上的文件路径
- confirmed: 上传属于写操作,需确认后传 True
ParametersJSON Schema
NameRequiredDescriptionDefault
serverYes
confirmedNo
directionYes
local_pathYes
remote_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It mentions that uploads require confirmation as a write operation, but omits other behaviors such as overwrite policy, authentication requirements, size limits, or error handling. This is insufficient for a complete behavioral picture.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, with a bulleted list of parameters. It is front-loaded with the core purpose and parameter list. It wastes no words, though it could be slightly better structured with headings.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 5 parameters and an output schema (not shown but present). The description covers all parameters but lacks prerequisites, error cases, or behavioral notes beyond the confirmation requirement. It is adequate for simple usage but incomplete for complex scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It explains all five parameters: server (Chinese name), direction (upload/download), local and remote paths, and confirmed (write confirmation). This adds critical meaning not present in the schema, though it could be more precise (e.g., expected formats).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states '在本地和服务器之间传输文件(SFTP)' which translates to 'Transfer files between local and server (SFTP).' This specifies a specific verb, resource, and protocol, and it distinguishes the tool from siblings like exec_command or list_servers that are not for file transfer.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides parameter details but no explicit guidance on when to use this tool versus alternatives. It implicitly indicates use for file transfers via SFTP, but does not mention exclusions or conditions like when not to use it or compare with sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 6 tool updatesv0.1.0
    • First observedbatch_exec
    • First observedexec_command
    • First observedlist_servers
    • First observedread_logs
    • First observedservice_status
    • First observedtransfer_file

TDQS

A3.8/5.0

Scored across 6 tools

Disambiguation5/5

每个工具都有明确且互不重叠的用途:列出服务器、单机执行命令、批量执行命令、读取日志、检查服务状态、传输文件。描述清晰,代理可以轻松区分。

Naming Consistency4/5

大多数工具遵循 verb_noun 模式(如 exec_command, list_servers, read_logs, transfer_file),但 batch_exec 是 adj_verb 形式,service_status 是 noun_noun,存在小偏差,整体仍可接受。

Tool Count5/5

6个工具覆盖了远程服务器管理的基本需求:执行命令、批量操作、日志、状态、文件传输和服务器列表。数量合理,没有冗余或不足。

Completeness3/5

覆盖了核心运维任务(命令执行、日志、文件传输、状态),但缺少服务启停、配置编辑、用户管理等常见操作,存在明显缺口。

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables SSH remote access to servers through Claude, allowing users to execute commands, transfer files via SFTP, and manage multiple remote connections using natural language.
    12
    8
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Connects Claude to remote servers via SSH to execute commands, manage files, and browse directories. It allows users to add, edit, and switch between multiple server configurations through natural language conversations.
    -