SSH MCP Server

SSH MCP Server

A toolset for executing commands and transferring files or directories on remote servers via SSH. It supports both direct connection parameters and pre-configured server profiles for seamless remote infrastructure management.

Category
访问服务器

README

SSH MCP Server

基于 Model Context Protocol (MCP) 的 SSH 服务器工具集,支持在远程服务器上执行命令和传输文件。

两种使用方式

本工具支持两种连接 SSH 服务器的方式

方式一:直接参数(临时连接)

直接在工具调用中指定服务器信息,适合临时操作:

{
  "tool": "ssh_execute_command",
  "arguments": {
    "host": "192.168.1.100",
    "port": 22,
    "username": "root",
    "password": "your_password",
    "command": "docker ps"
  }
}

方式二:配置文件(推荐)

预先配置服务器信息,通过名称调用,适合频繁使用的服务器:

  1. 创建 ssh-mcp.config.json 配置文件
  2. 使用 server 参数指定服务器名称
{
  "tool": "ssh_execute_command",
  "arguments": {
    "server": "production",
    "command": "docker ps"
  }
}

优势:

  • 无需每次输入密码
  • 支持多服务器配置
  • 通过 ssh_list_servers 工具查询可用服务器
  • Agent 可自主发现并使用服务器

安装

npm install
npm run build

MCP 客户端配置

OpenCode

配置文件位置:C:\Users\<用户名>\.config\opencode\opencode.jsonc

{
  "mcp": {
    "ssh-mcp": {
      "type": "local",
      "command": ["node", "path/to/ssh-mcp/dist/index.js"],
      "enabled": true
    }
  }
}

Claude Code

配置文件位置:C:\Users\<用户名>\.claude\CLAUDE.json

{
  "mcpServers": {
    "ssh-mcp": {
      "command": "node",
      "args": ["/path/to/ssh-mcp/dist/index.js"],
      "disabled": false
    }
  }
}

Claude Desktop

配置文件位置:

  • Windows: %APPDATA%/Claude/claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "ssh-mcp": {
      "command": "node",
      "args": ["/path/to/ssh-mcp/dist/index.js"],
      "disabled": false
    }
  }
}

SSH 配置文件

创建配置文件

{
  "servers": {
    "production": {
      "host": "192.168.1.100",
      "port": 22,
      "username": "root",
      "password": "your_password",
      "timeout": 60000
    },
    "development": {
      "host": "192.168.1.50",
      "port": 2222,
      "username": "admin",
      "password": "dev_password"
    }
  },
  "defaultServer": "development"
}

配置文件位置(按优先级)

  1. SSH_MCP_CONFIG 环境变量指定路径
  2. 当前项目目录 ssh-mcp.config.json
  3. 当前项目目录 .ssh-mcp-config.json
  4. 用户主目录 .ssh-mcp-config.json

配置文件参数说明

参数 必填 默认值 说明
host - SSH 服务器地址
port 22 SSH 端口
username - 用户名
password - 密码
timeout 30000 超时时间(毫秒)

使用示例

列出所有已配置的服务器

{
  "tool": "ssh_list_servers"
}

ssh_execute_command - 执行命令

使用配置文件中的服务器:

{
  "tool": "ssh_execute_command",
  "arguments": {
    "server": "production",
    "command": "docker ps -a"
  }
}

直接指定参数:

{
  "tool": "ssh_execute_command",
  "arguments": {
    "host": "192.168.1.100",
    "port": 22,
    "username": "root",
    "password": "123",
    "command": "df -h",
    "response_format": "markdown"
  }
}

指定工作目录:

{
  "tool": "ssh_execute_command",
  "arguments": {
    "server": "production",
    "working_dir": "/var/www/app",
    "command": "npm run build"
  }
}

ssh_upload_file - 上传文件

使用配置文件:

{
  "tool": "ssh_upload_file",
  "arguments": {
    "server": "production",
    "local_path": "./config/app.yml",
    "remote_path": "/etc/myapp/config.yml"
  }
}

直接指定参数:

{
  "tool": "ssh_upload_file",
  "arguments": {
    "host": "192.168.1.100",
    "port": 22,
    "username": "root",
    "password": "123",
    "local_path": "./deploy.sh",
    "remote_path": "/opt/deploy/deploy.sh"
  }
}

ssh_download_file - 下载文件

从服务器下载日志文件:

{
  "tool": "ssh_download_file",
  "arguments": {
    "server": "production",
    "remote_path": "/var/log/app/error.log",
    "local_path": "./logs/error.log"
  }
}

指定输出格式:

{
  "tool": "ssh_download_file",
  "arguments": {
    "server": "development",
    "remote_path": "/etc/nginx/nginx.conf",
    "local_path": "./config/nginx.conf",
    "response_format": "json"
  }
}

ssh_upload_directory - 上传目录

部署应用到服务器:

{
  "tool": "ssh_upload_directory",
  "arguments": {
    "server": "production",
    "local_path": "./dist",
    "remote_path": "/var/www/myapp"
  }
}

同步配置目录:

{
  "tool": "ssh_upload_directory",
  "arguments": {
    "server": "development",
    "local_path": "./config",
    "remote_path": "/etc/myapp/config"
  }
}

ssh_download_directory - 下载目录

下载服务器日志目录:

{
  "tool": "ssh_download_directory",
  "arguments": {
    "server": "production",
    "remote_path": "/var/log/myapp",
    "local_path": "./logs"
  }
}

备份项目目录:

{
  "tool": "ssh_download_directory",
  "arguments": {
    "server": "production",
    "remote_path": "/opt/project",
    "local_path": "./backup/project"
  }
}

工具列表

工具 说明
ssh_list_servers 列出所有已配置的服务器
ssh_execute_command 执行命令
ssh_upload_file 上传文件
ssh_download_file 下载文件
ssh_upload_directory 上传目录
ssh_download_directory 下载目录

ssh_execute_command 参数

参数 类型 必填 说明
server string 服务器名称(配置文件)
host string SSH 服务器地址
port number SSH 端口,默认 22
username string 用户名
password string 密码
timeout number 超时时间(毫秒)
command string 要执行的命令
working_dir string 工作目录
response_format string 输出格式(markdown/json)

ssh_upload_file 参数

参数 类型 必填 说明
server string 服务器名称(配置文件)
host string SSH 服务器地址
port number SSH 端口,默认 22
username string 用户名
password string 密码
timeout number 超时时间(毫秒)
local_path string 本地文件路径
remote_path string 远程目标路径
response_format string 输出格式(markdown/json)

ssh_download_file 参数

参数 类型 必填 说明
server string 服务器名称(配置文件)
host string SSH 服务器地址
port number SSH 端口,默认 22
username string 用户名
password string 密码
timeout number 超时时间(毫秒)
remote_path string 远程文件路径
local_path string 本地目标路径
response_format string 输出格式(markdown/json)

ssh_upload_directory 参数

参数 类型 必填 说明
server string 服务器名称(配置文件)
host string SSH 服务器地址
port number SSH 端口,默认 22
username string 用户名
password string 密码
timeout number 超时时间(毫秒)
local_path string 本地目录路径
remote_path string 远程目标目录
response_format string 输出格式(markdown/json)

ssh_download_directory 参数

参数 类型 必填 说明
server string 服务器名称(配置文件)
host string SSH 服务器地址
port number SSH 端口,默认 22
username string 用户名
password string 密码
timeout number 超时时间(毫秒)
remote_path string 远程目录路径
local_path string 本地目标目录
response_format string 输出格式(markdown/json)

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选