SSH MCP Server

SSH MCP Server

site icon
2025.03.28 0
JavaScript远程命令执行SSH服务器开发效率
mcp-ssh-server 是一个基于SSH2和Model Context Protocol (MCP)的SSH服务器,提供远程命令执行功能。它通过MCP协议提供SSH远程命令执行工具,支持密码和私钥认证,并返回命令执行结果(stdout/stderr/exit code)。该项目基于TypeScript开发,具有类型安全的特性。
View on GitHub

Overview

基本能力

产品定位

mcp-ssh-server 是一个基于SSH2和MCP协议的SSH服务器,主要用于远程命令执行。

核心功能

  • 通过MCP协议提供SSH远程命令执行工具
  • 支持密码和私钥认证
  • 返回命令执行结果(stdout/stderr/exit code)
  • 基于TypeScript开发,类型安全

适用场景

  • 远程服务器管理
  • 自动化脚本执行
  • 开发环境中的远程命令调用

工具列表

  • execute_ssh_command:用于执行远程SSH命令的工具

常见问题解答

使用教程

使用依赖

  • Node.js >= 16.0.0
  • TypeScript >= 5.0.0

安装教程

# 克隆仓库
git clone https://github.com/your-repo/ssh-server.git
cd ssh-server

# 安装依赖
npm install

# 构建项目
npm run build

调试方式

  1. 启动服务器:
npm start
  1. 通过MCP客户端调用execute_ssh_command工具:

请求示例:

{
  "connection": {
    "host": "example.com",
    "port": 22,
    "username": "user",
    "password": "password"  // 或使用 privateKey
  },
  "command": "ls -la"
}

开发

# 开发模式
npm run build -- --watch

# 运行测试
# (需要添加测试脚本)

许可证

该项目遵循 MIT 开源许可条款。