mcpField
M
MCP SSH Agent

MCP SSH Agent

本地服务
github.com/AiondaDotCom开发工具10411 周前更新

关于 MCP SSH Agent

MCP SSH Agent 是一个用于管理和控制 SSH 连接的 MCP 服务,主要面向 Claude Desktop 等 MCP 客户端用户。它从 ~/.ssh/config 和 ~/.ssh/known_hosts 自动发现主机,并调用系统原生的 ssh 与 scp 执行操作。密码通过本地注解读取,不会传递给模型。

主要功能

  1. 01从 SSH 配置自动发现主机
  2. 02调用原生 ssh 与 scp 命令执行操作
  3. 03通过 scp 上传和下载文件
  4. 04批量顺序执行多条命令
  5. 05支持 @password 注解的密码认证
  6. 06支持 Include 指令与 ProxyJump 跳板机

适用场景

  1. 01在 Claude Desktop 中列出并检查远程主机连通性
  2. 02在远程服务器上执行命令并查看结果
  3. 03上传配置文件或下载应用日志

MCP 相关

该项目是一个通过 STDIO 运行的 MCP 服务,向 MCP 客户端暴露 listKnownHosts、runRemoteCommand、uploadFile 等 7 个工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

7

收录的工具列表 · 更新于 3 周前

此工具无需参数。

详细介绍

MCP SSH Agent

测试

用于管理和控制 SSH 连接的模型上下文协议(MCP)服务。此服务可与 Claude Desktop 及其他兼容 MCP 的客户端无缝集成,提供 AI 驱动的 SSH 操作。

概述

此 MCP 服务通过简洁、标准化的接口提供 SSH 操作,供 Claude Desktop 等兼容 MCP 的语言模型使用。服务会自动从 ~/.ssh/config 和 ~/.ssh/known_hosts 文件中发现 SSH 主机,并使用原生 SSH 工具执行命令,以确保最高可靠性。

快速开始

MCP Bundle 安装(推荐)

安装 MCP SSH Agent 最简单的方法是将其作为 MCP Bundle 安装:

  1. 从 GitHub 发布页面下载最新的 mcp-ssh-*.mcpb 文件
  2. 双击 .mcpb 文件,将其安装到 Claude Desktop 中

此 Bundle 格式之前称为 Desktop Extension,使用 .dxt 扩展名。v1.3.9 在过渡期间同时发布了这两种文件;之后的版本仅包含 .mcpb。如果你的 Claude Desktop 版本太旧而无法接受 .mcpb 文件, 请更新它,或使用以下安装方法之一。

  1. SSH 工具会自动在你与 Claude 的对话中可用
其他安装方法
通过 npx 安装
npx @aiondadotcom/mcp-ssh
手动配置 Claude Desktop

若要通过手动配置在 Claude Desktop 中使用此 MCP 服务,请将以下内容添加到 MCP 设置文件中:

macOS:~/Library/Application Support/Claude/claude_desktop_config.json Windows:%APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-ssh": {
      "command": "npx",
      "args": ["@aiondadotcom/mcp-ssh"]
    }
  }
}

添加此配置后,重启 Claude Desktop。SSH 工具即可在你与 Claude 的对话中使用。

全局安装
npm install -g @aiondadotcom/mcp-ssh
本地开发
git clone https://github.com/aiondadotcom/mcp-ssh.git
cd mcp-ssh
npm install   # also compiles src/ -> dist/
npm start

此服务使用 TypeScript 编写,代码位于 src/;运行 npm install 会构建项目。编辑源文件后,请运行 npm run build(或运行 npm test,它会直接读取 src/)。

使用示例

MCP SSH Agent 示例

上方截图展示了 MCP SSH Agent 的运行情况,演示了它如何与兼容 MCP 的客户端集成,以无缝执行 SSH 操作。

与 Claude 集成

Claude MCP 集成

此截图展示了 MCP SSH Agent 与 Claude 的集成,说明 AI 助手如何通过 MCP 协议直接管理 SSH 连接并执行远程命令。

主要功能

  • 可靠的 SSH:使用原生 ssh/scp 命令,而非 JavaScript SSH 库
  • 自动发现:从 SSH 配置和 known_hosts 文件中查找主机
  • 全面支持 SSH:支持 SSH agent、密钥及所有身份验证方式
  • 密码身份验证:支持基于密码的 SSH 登录,并可通过 @password 注释指定密钥口令 — 密码不会离开你的计算机
  • 文件操作:使用 scp 上传和下载文件
  • 批量命令:按顺序执行多个命令
  • 错误处理:提供全面的错误报告,并支持超时设置

函数

此 Agent 提供以下 MCP 工具:

  1. listKnownHosts() - 列出所有已知 SSH 主机,优先显示 ~/.ssh/config 中的条目,然后显示来自 ~/.ssh/known_hosts 的其他主机
  2. runRemoteCommand(hostAlias, command) - 使用 ssh 在远程主机上执行命令
  3. getHostInfo(hostAlias) - 返回特定主机的详细配置
  4. checkConnectivity(hostAlias) - 测试与主机的 SSH 连接
  5. uploadFile(hostAlias, localPath, remotePath) - 使用 scp 将文件上传到远程主机
  6. downloadFile(hostAlias, remotePath, localPath) - 使用 scp 从远程主机下载文件
  7. runCommandBatch(hostAlias, commands) - 按顺序执行多个命令

配置示例

Claude Desktop 集成

Claude Desktop 配置应如下所示:

{
  "mcpServers": {
    "mcp-ssh": {
      "command": "npx",
      "args": ["@aiondadotcom/mcp-ssh"]
    }
  }
}
手动配置服务

如果你更喜欢手动运行服务,或将其集成到其他 MCP 客户端中:

{
  "servers": {
    "mcp-ssh": {
      "command": "npx",
      "args": ["@aiondadotcom/mcp-ssh"]
    }
  }
}

要求

  • Node.js 20 或更高版本
  • 已安装 SSH 客户端(可使用 ssh 和 scp 命令)
  • SSH 配置文件(~/.ssh/config 和 ~/.ssh/known_hosts)

在 Claude Desktop 中使用

配置完成后,你可以让 Claude 帮助你执行以下 SSH 操作:

  • “列出我的所有 SSH 主机”
  • “检查与我的生产服务器的连接”
  • “在我的 Web 服务器上运行命令”
  • “将此文件上传到我的远程服务”
  • “从我的应用服务器下载日志”

Claude 将使用 MCP SSH 工具安全、高效地执行这些操作。

使用方法

该 Agent 作为 Model Context Protocol 服务通过 STDIO 运行。通过 npm 安装后,你可以直接使用:

# Run via npx (recommended)
npx @aiondadotcom/mcp-ssh

# Or if installed globally
mcp-ssh

# For development - run with debug output
npm start

该服务通过 STDIO 使用纯 JSON 进行通信,非常适合 Claude Desktop 等 MCP 客户端。

高级配置

环境变量
  • MCP_SILENT=true - 禁用调试输出(作为 MCP 服务使用时会自动设置)
SSH 配置

该 Agent 会读取标准 SSH 配置文件:

  • ~/.ssh/config - SSH 客户端配置(支持 Include 指令)
  • ~/.ssh/known_hosts - 已知主机密钥

请确保你的 SSH 密钥已正确配置,并可通过 SSH agent 或密钥文件访问。

密码身份验证

对于需要基于密码进行身份验证的主机(网络基础设施设备,例如交换机和路由器,通常会使用这种方式),你可以使用特殊注释标记,将密码直接存储在 ~/.ssh/config 中:

Host myrouter
    HostName 192.168.1.1
    User admin
    # @password:yourSecretPassword

Host myserver
    HostName 10.0.0.5
    User deploy
    IdentityFile ~/.ssh/id_rsa
    # @password:myKeyPassphrase

工作原理:

  • MCP 服务会在本地读取 # @password: 注释标记——密码绝不会传输给 AI 模型或任何云服务提供商
  • 适用于登录密码和 SSH 密钥口令
  • 密码会在第一个 : 处分割,因此支持包含 : 的密码
  • 列出主机时,只会显示 passwordAuth: true——绝不会暴露实际密码

安全要求:

  • 使用 @password 注释标记时,SSH 配置文件的权限必须为 600
  • 如果文件权限设置得过于宽松,MCP 服务将拒绝启动
  • 使用以下命令修复:chmod 600 ~/.ssh/config
Include 指令支持

MCP SSH Agent 完全支持 SSH Include 指令,可将配置分散到多个文件中。不过,有一个重要的 SSH 错误需要注意:

⚠️ SSH Include 指令错误警告

SSH 存在一个配置解析错误:Include 语句必须放在 ~/.ssh/config 文件的开头才能正常工作。如果放在末尾,SSH 会读取这些语句,但不会正确应用所包含的配置。

✅ 正确位置(文件开头):

# ~/.ssh/config
Include ~/.ssh/config.d/*
Include ~/.ssh/work-hosts

# Global settings
ServerAliveInterval 55

# Host definitions
Host myserver
    HostName example.com

❌ 错误位置(文件末尾)——无法生效:

# ~/.ssh/config
# Global settings
ServerAliveInterval 55

# Host definitions
Host myserver
    HostName example.com

# These Include statements won't work properly due to SSH bug:
Include ~/.ssh/config.d/*
Include ~/.ssh/work-hosts

MCP SSH Agent 无论 Include 指令在文件中的位置如何,都会正确处理这些指令。因此,即使 SSH 本身无法正确处理你的配置,你仍能完整发现所有主机。

~/.ssh/config 示例

以下是一个 SSH 配置文件示例,展示了多种连接场景,包括 Include 指令和用于基于密码进行身份验证的 @password 注释:

# Include directives must be at the beginning due to SSH bug
Include ~/.ssh/config.d/*
Include ~/.ssh/work-servers

# Global settings - keep connections alive
ServerAliveInterval 55

# Production server with jump host
Host prod
    Hostname 203.0.113.10
    Port 22022
    User deploy
    IdentityFile ~/.ssh/id_prod_rsa

# Root access to production (separate entry)
Host root@prod
    Hostname 203.0.113.10
    Port 22022
    User root
    IdentityFile ~/.ssh/id_prod_rsa

# Router with password authentication (no SSH key)
Host router
    Hostname 192.168.1.1
    User admin
    # @password:cQbG0q@019TAoehZel7V

# Archive server accessed through production jump host
Host archive
    Hostname 2001:db8:1f0:cafe::1
    Port 22077
    User archive-user
    ProxyJump prod

# Web servers with specific configurations
Host web1.example.com
    Hostname 198.51.100.15
    Port 22022
    User root
    IdentityFile ~/.ssh/id_ed25519

Host web2.example.com
    Hostname 198.51.100.25
    Port 22022
    User root
    IdentityFile ~/.ssh/id_ed25519

# Database server with custom key and passphrase-protected key
Host database
    Hostname 203.0.113.50
    Port 22077
    User dbadmin
    IdentityFile ~/.ssh/id_database_rsa
    IdentitiesOnly yes
    # @password:U1Jqn=NoKdELYn&h1jVT

# Mail servers (password auth, no SSH key)
Host mail1
    Hostname 198.51.100.88
    Port 22078
    User mailuser
    # @password:7iBiV8lyoq*zANv46ALD

Host root@mail1
    Hostname 198.51.100.88
    Port 22078
    User root
    # @password:MRDHI2h!zhhN=ZJIxWzH

# Monitoring server
Host monitor
    Hostname 203.0.113.100
    Port 22077
    User monitoring
    IdentityFile ~/.ssh/id_monitor_ed25519
    IdentitiesOnly yes

# Load balancers
Host lb-a
    Hostname 198.51.100.200
    Port 22077
    User root

Host lb-b
    Hostname 198.51.100.201
    Port 22077
    User root

# One host reachable under several aliases - both names work
Host docker-lxc hlab
    Hostname 10.9.0.105
    User root

此配置展示了:

  • 全局设置:使用 ServerAliveInterval 保持连接活动
  • 自定义端口:使用非标准 SSH 端口提升安全性
  • 多个用户:同一主机使用不同的用户帐户(例如,prod 和 root@prod)
  • 多个别名:同一主机声明为多个名称(例如,docker-lxc hlab),每个名称都可用于连接
  • 跳板主机:使用 ProxyJump 通过堡垒主机访问服务器
  • IPv6 地址:支持现代网络
  • 身份文件:为不同服务器指定特定的 SSH 密钥
  • 安全选项:使用 IdentitiesOnly yes 仅使用指定的密钥
  • 密码身份验证:为不支持 SSH 密钥的设备(例如,路由器、交换机)或受密码短语保护的密钥使用 # @password: 注释
会发现哪些主机

listKnownHosts() 会报告它在 ~/.ssh/config 中找到的所有可连接主机(包括通过 Include 引入的所有内容),然后列出 ~/.ssh/known_hosts 中的其他主机名。以下三条规则决定 哪些主机可连接:

多别名区块中的每个别名都可用。 Host 接受一组模式,而不是单个 名称,因此一个区块可以一次声明多个别名:

Host docker-lxc hlab
    Hostname 10.9.0.105
    User root

docker-lxc 和 hlab 都可以连接到此主机。响应会在 aliases 字段中包含完整列表, 而 alias 则保存第一个别名。

默认值区块会被跳过。 仅包含通配符和否定模式的区块会为其他主机设置默认值—— 它本身不是可连接的主机,因此不会列入主机列表:

Host *
    ServerAliveInterval 55

Host * !bastion          # "everything except bastion" — a defaults block, not a host
    User deploy
    IdentityFile ~/.ssh/id_deploy

(OpenSSH 允许使用 ! 否定模式。匹配到否定模式会排除整行,因此否定模式只有在作为通配符的例外时才有意义。)

没有 Hostname 的主机会被跳过,因为没有可供连接的目标。

像裸写的 ServerAliveInterval 55 这样的顶层指令属于 ssh 本身的配置,不会参与主机发现;不过 ssh 仍会应用这些指令,因为每项操作都会通过系统的 ssh 二进制文件执行。

MCP SSH Agent 如何使用你的配置

MCP SSH Agent 会自动发现并使用你的 SSH 配置:

  1. 主机发现:~/.ssh/config 中的所有可连接主机均可用——请参阅上述规则
  2. 原生 SSH:使用系统的 ssh 命令,因此所有配置选项都有效
  3. 身份验证:遵循你的 SSH Agent、密钥文件和身份验证设置
  4. 跳板主机:支持复杂的代理链和堡垒主机设置
  5. 端口转发:支持自定义端口和连接选项

Claude Desktop 使用示例:

  • “列出我的 SSH 主机” → 显示所有已配置的主机,包括 prod、archive、web1.example.com 等
  • “连接到 archive 服务器” → 自动使用 ProxyJump 配置
  • “在 web1.example.com 上运行 'df -h'” → 使用正确的用户、端口和密钥连接
  • “将文件上传到数据库服务器” → 使用指定的身份文件和端口配置

故障排除

常见问题
  1. 找不到命令:确保已安装 ssh 和 scp,并且它们位于 PATH 中
  2. 权限被拒绝:检查 SSH 密钥权限和 SSH agent
  3. 找不到主机:确认主机存在于 ~/.ssh/config 或 ~/.ssh/known_hosts 中,并且对应的配置块包含 Hostname;没有 Hostname 的配置块以及 Host * 这类纯默认配置块都不是可连接的主机。请参阅发现哪些主机
  4. 连接超时:检查网络连接和防火墙设置
  5. Windows:所有命令均以退出码 255 失败,且输出为空:此问题已在 1.3.8 之后修复。早期版本会继承 MCP 主机经过精简的环境,其中缺少 Win32-OpenSSH 启动时所需的 %ProgramData%。请升级,或在客户端配置的 env 块中添加 "ProgramData": "C:\\ProgramData"
调试模式

启用调试输出以查看详细的操作日志:

# Enable debug mode
MCP_SILENT=false npx @aiondadotcom/mcp-ssh

SSH 密钥设置指南

要让 MCP SSH Agent 正常工作,需要设置 SSH 密钥身份验证。以下是完整指南:

1. 创建 SSH 密钥

生成新的 SSH 密钥对(使用 Ed25519 可获得更好的安全性):

# Generate Ed25519 key (recommended)
ssh-keygen -t ed25519 -C "[email protected]"

# Or generate RSA key (if Ed25519 is not supported)
ssh-keygen -t rsa -b 4096 -C "[email protected]"

重要:系统提示输入密码短语时,请留空(按 Enter)。MCP SSH Agent 以非交互方式运行,无法处理受密码保护的密钥。

Enter passphrase (empty for no passphrase): [Press Enter]
Enter same passphrase again: [Press Enter]

这会创建两个文件:

  • ~/.ssh/id_ed25519(私钥)——请妥善保密!
  • ~/.ssh/id_ed25519.pub(公钥)——将复制到服务器
2. 在远程服务器上安装公钥

将公钥复制到远程服务器的 authorized_keys 文件中:

# Method 1: Using ssh-copy-id (easiest)
ssh-copy-id user@hostname

# Method 2: Manual copy
cat ~/.ssh/id_ed25519.pub | ssh user@hostname "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

# Method 3: Copy and paste manually
cat ~/.ssh/id_ed25519.pub
# Then SSH to the server and paste into ~/.ssh/authorized_keys
3. 服务器端 SSH 配置

要在 SSH 服务器上启用安全的仅密钥身份验证,请编辑 /etc/ssh/sshd_config:

# Edit SSH daemon configuration
sudo nano /etc/ssh/sshd_config

添加或修改以下设置:

# Enable public key authentication
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

# Disable password authentication (security best practice)
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

# Root login options (choose one):
# Option 1: Allow root login with SSH keys only (recommended for admin access)
PermitRootLogin prohibit-password

# Option 2: Completely disable root login (most secure, but less flexible)
# PermitRootLogin no

# Optional: Restrict SSH to specific users
AllowUsers deploy root admin

# Optional: Change default port for security
Port 22022

编辑后,重启 SSH 服务:

# On Ubuntu/Debian
sudo systemctl restart ssh

# On CentOS/RHEL/Fedora
sudo systemctl restart sshd

# On macOS
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load /System/Library/LaunchDaemons/ssh.plist
4. 设置正确的权限

SSH 对文件权限的要求非常严格。请正确设置权限:

在本地计算机上:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
chmod 644 ~/.ssh/config
chmod 644 ~/.ssh/known_hosts

在远程服务器上:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
5. 测试 SSH 密钥身份验证

使用 MCP SSH Agent 前,先测试连接:

# Test connection
ssh -i ~/.ssh/id_ed25519 user@hostname

# Test with verbose output for debugging
ssh -v -i ~/.ssh/id_ed25519 user@hostname

# Test specific configuration
ssh -F ~/.ssh/config hostname
6. 为不同服务器使用多个密钥

可以为不同的服务器创建不同的密钥:

# Create specific keys
ssh-keygen -t ed25519 -f ~/.ssh/id_production -C "production-server"
ssh-keygen -t ed25519 -f ~/.ssh/id_staging -C "staging-server"

然后在 ~/.ssh/config 中进行配置:

Host production
    Hostname prod.example.com
    User deploy
    IdentityFile ~/.ssh/id_production
    IdentitiesOnly yes

Host staging
    Hostname staging.example.com
    User deploy
    IdentityFile ~/.ssh/id_staging
    IdentitiesOnly yes

威胁模型与信任边界

MCP SSH Agent 可以代表你驱动 ssh 和 scp。使用前,请务必了解:如果攻击者控制了 LLM 的指令(例如通过网页、电子邮件、代码库文件或其他 MCP 服务的输出进行提示词注入),他们可以做些什么:

  • **runRemoteCommand 可在你配置的每台主机上执行完整的远程代码。**如果你的 ~/.ssh/config 中包含 production 条目,LLM 就能以该用户身份在这台主机上运行任意命令。这是此工具的用途,并非漏洞——但这意味着你只应配置愿意让 LLM 操作的主机,并优先使用权限最小化的账户。
  • **uploadFile 和 downloadFile 让 LLM 能以运行 MCP 服务的用户权限访问本地文件系统。**LLM 可以读取进程有权读取的任何文件(包括 ~/.ssh/id_*、浏览器数据、源代码目录、.env 文件),也可以写入进程有权写入的任何路径(包括 ~/.ssh/authorized_keys)。路径参数不会受到沙箱限制,因为此工具的用途就是“传输任意文件”。
  • **MCP 服务通过本地 STDIO 运行,但 LLM 并不可信。**STDIO 仅描述传输方式——工具参数的内容由模型决定,而模型可能受到其在对话中摄取的任何不可信文本的影响。
  • # @password: 注释不会进入 LLM 的上下文,但会保存在磁盘上的 ~/.ssh/config 中。任何能让攻击者任意读取本地文件的情况(见上文)也会暴露这些密码。该注释只能防止 LLM 通过 MCP 协议看到密码,无法防止本地文件泄露。
建议
  • 在专用的、无特权的操作系统用户下运行 MCP SSH Agent,该用户的主目录中只包含你确实希望 LLM 使用的 SSH 配置和密钥。
  • 或者在容器 / 沙箱中运行它,其中只提供精简的 ~/.ssh,且无法访问机器上的其他机密信息。
  • 将 ~/.ssh/config 中的主机精简到你信任 LLM 操作的最小集合。在远程端尽可能使用受限的 shell 用户。
  • 如果 LLM 摄取了不可信内容(网页、电子邮件、第三方代码库、其他 MCP 服务的输出),请将相关会话视为可能对 MCP SSH 操作构成威胁。
  • 如果怀疑存在漏洞,请通过此代码库的 GitHub 私密漏洞报告功能进行报告。

安全最佳实践

SSH 密钥安全
  • 切勿在 MCP SSH Agent 中使用受密码保护的密钥
  • 切勿共享私钥——私钥应只保存在你的机器上
  • 尽可能使用 Ed25519 密钥(比 RSA 更安全)
  • 为不同环境 / 用途创建单独的密钥
  • 定期轮换密钥(每 6-12 个月)
服务端安全
  • 完全禁用密码身份验证
  • 使用非标准 SSH 端口,以减少自动化攻击
  • 通过 AllowUsers 限制可访问 SSH 的用户
  • 选择合适的 root 登录策略:
    • PermitRootLogin prohibit-password - 仅允许使用 SSH 密钥进行 root 访问(推荐用于管理任务)
    • PermitRootLogin no - 完全禁用 root 登录(最安全,但需要 sudo 访问权限)
  • 为所有账户启用仅限 SSH 密钥的身份验证
  • 考虑使用跳板主机来增加安全层
网络安全
  • 生产服务器使用 VPN 或堡垒主机
  • 部署 fail2ban 以阻止暴力破解尝试
  • 定期监控 SSH 日志
  • 谨慎使用 SSH 密钥转发(不需要时禁用)

构建 MCP Bundle

希望在本地构建 Bundle 的开发者:

前置条件
  • Node.js 20 或更高版本
  • npm
构建
npm install
npm run build:mcpb

这会生成 build/mcp-ssh-<version>.mcpb,可安装到 Claude Desktop 中。

此软件包由仅包含生产依赖项的暂存副本打包而成,因此不包含测试和构建工具链。如果 manifest.json 与 package.json 中的版本不一致,构建将拒绝运行。

发布版本
npm run build:mcpb
gh release upload v1.3.9 build/mcp-ssh-1.3.9.mcpb

贡献

欢迎贡献!请随时提交 Pull Request。

npm install        # also compiles src/ -> dist/ via the prepare script
npm run build      # tsc
npm run typecheck  # tsc --noEmit, strict for src/ and relaxed for tests
npm run lint       # eslint with type-aware rules
npm test           # vitest with coverage
npm run test:watch # watch mode

服务使用 TypeScript 编写,位于 src/ 下,并编译到 dist/;bin/mcp-ssh.js 会加载该目录中的内容,这些内容也会发布到 npm。dist/ 不在 git 中——全新检出后会通过 npm install 获取该目录。

提交 PR 前请了解以下三点:

  • 覆盖率是构建门槛。 vitest.config.mjs 将 src/ 的语句、分支、函数和行覆盖率设为 100%,因此新增未测试代码行的更改会导致 CI 失败。如果某个分支确实无法到达,通常直接删除它比绕过阈值更好。
  • Lint 规则经过专门调整,并非默认配置。 放宽某条规则时,旁边会有注释说明原因。特别是,prefer-nullish-coalescing 刻意豁免了字符串和数字:对于环境变量(被剥离的启动器环境会返回空字符串,参见 issue #10)或 timeout || DEFAULT,|| 和 ?? 并不能互换。
  • CI 在 Linux 和 Windows 上运行,覆盖 Node 20、22 和 24。通过伪造 process.platform 并重新导入模块,在任一操作系统上测试特定平台的代码路径——参见 src/test-helpers.ts 中的 loadServerAs()——而不是在某个平台上跳过测试。

许可证

MIT 许可证——详情请参阅 LICENSE 文件。

项目结构

mcp-ssh/
├── src/                       # TypeScript sources
│   ├── server.ts              # Entry point: MCP server wiring and main()
│   ├── tools.ts               # Tool definitions and dispatch
│   ├── ssh-client.ts          # All ssh/scp operations
│   ├── ssh-config-parser.ts   # Host discovery from config and known_hosts
│   ├── config-values.ts       # ssh-config value normalization
│   ├── platform.ts            # Platform detection, binary resolution, logging
│   ├── types.ts               # Shared types
│   └── server.test.ts         # Test suite (vitest)
├── dist/                      # Compiled output (generated, not in git)
├── bin/
│   └── mcp-ssh.js             # Executable entry point (loads dist/server.js)
├── tsconfig.json              # Strict compiler options for src/
├── tsconfig.build.json        # Build config (excludes tests)
├── tsconfig.test.json         # Relaxed options for test files
├── eslint.config.mjs          # typescript-eslint, type-aware rules
├── vitest.config.mjs          # Test and coverage configuration
├── manifest.json              # MCP Bundle manifest
├── package.json               # Dependencies and scripts
├── README.md                  # Documentation
├── LICENSE                    # MIT License
├── CHANGELOG.md               # Release history
├── PUBLISHING.md              # Publishing instructions
├── .gitattributes             # Forces LF checkout on every platform
├── start.sh                   # Development startup script
├── start-silent.sh            # Silent startup script
├── scripts/
│   └── build-mcpb.sh          # MCP Bundle build script
└── doc/                       # Documentation assets
    ├── example.png            # Usage example screenshot
    └── Claude.png             # Claude Desktop integration example

关于

本项目由 aionda.com 维护,通过 Model Context Protocol 为 AI 助手与 SSH 基础设施提供可靠的桥接。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。