SSH MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Manages SSH credentials storage through a SQLite database, enabling persistence of connection details for remote command execution.

SSH MCP 服务器

提供 SSH 功能的模型上下文协议 (MCP) 服务器实现。此服务器允许通过 MCP 协议进行安全的远程访问和执行。

特征

  • 使用MCP协议的SSH服务器实现
  • SQLite 数据库集成,实现数据持久化
  • TypeScript 实现类型安全和更好的开发体验

先决条件

  • Node.js(建议使用 v16 或更高版本)
  • npm 或 yarn 包管理器
  • 开发所需的 TypeScript 知识

安装

  1. 克隆存储库:
git clone <repository-url> cd ssh-server
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build

用法

配置

该服务器使用 SQLite 数据库 ( ssh.db ) 来存储 SSH 凭据。该数据库文件将在服务器启动时自动创建。

工具

该服务器提供以下工具:

ssh_exec

通过 SSH 执行命令。

输入参数:

  • host :要连接的主机。(必需)
  • command :要执行的命令。(必需)
  • username :用于 SSH 连接的用户名。(必需)
  • privateKeyPath :私钥文件的路径。(必需)

示例用法:

{ "tool_name": "ssh_exec", "arguments": { "host": "example.com", "command": "ls -l", "username": "user", "privateKeyPath": "/path/to/private/key" } }

注意: privateKeyPath必须是私钥文件的有效路径。

添加凭证

添加新的 SSH 凭证。

输入参数:

  • name :凭证的名称。(必需)
  • host :要连接的主机。(必需)
  • username :用于 SSH 连接的用户名。(必需)
  • privateKeyPath :私钥文件的路径。(必需)

示例用法:

{ "tool_name": "add_credential", "arguments": { "name": "my_credential", "host": "example.com", "username": "user", "privateKeyPath": "/path/to/private/key" } }

注意: privateKeyPath必须是私钥文件的有效路径。

列出凭据

列出所有存储的 SSH 凭据。

输入参数:

  • 没有任何

示例用法:

{ "tool_name": "list_credentials", "arguments": {} }

删除凭据

删除存储的 SSH 凭证。

输入参数:

  • name :要删除的凭证的名称。(必需)

示例用法:

{ "tool_name": "remove_credential", "arguments": { "name": "my_credential" } }

启动服务器

npm start

服务器将在配置的端口上开始运行(默认设置可以在源代码中修改)。

项目结构

  • src/ ——源代码目录
  • build/ ——编译后的 JavaScript 输出
  • node_modules/ ——项目依赖项

依赖项

  • @modelcontextprotocol/sdk :MCP 协议实现
  • sqlite3 :SQLite 数据库驱动程序
  • typescript :TypeScript 支持的开发依赖项

发展

要对项目进行更改:

  1. src/目录中进行更改
  2. 重建项目:
npm run build
  1. 启动服务器来测试您的更改:
npm start

执照

国际学习中心

贡献

  1. 分叉存储库
  2. 创建你的功能分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建新的 Pull 请求

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

模型上下文协议服务器实现,可通过 SSH 安全地执行远程命令,并具有管理和使用 SSH 凭据的功能。

  1. Features
    1. Prerequisites
      1. Installation
        1. Usage
          1. Configuration
          2. Tools
          3. Starting the server
        2. Project Structure
          1. Dependencies
            1. Development
              1. License
                1. Contributing
                  ID: miatd78x95