MS

mingyang91/ssh-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 8 forks 质量 52 趋势 14

A Rust implementation of an SSH client server with Model Context Protocol (MCP) integration, allowing Large Language Models (LLMs) to connect to a SSH server and utilize SSH features.

概览

A Rust implementation of an SSH client server with Model Context Protocol (MCP) integration, allowing Large Language Models (LLMs) to connect to a SSH server and utilize SSH features. - 🚀 ssh-mcp: only 4.3MB binary size, 1.8MB memory footprint - 🔄 ssh-mcp-stdio: only 1.5MB binary size, 2.3MB memory usage - 🐳 docker: only 27.5MB final image size - : Connect to SSH servers via MCP commands - : Run commands on remote SSH servers - : Setup SSH tunnels and port forwards (enabled by default via the port_forward feature) - : Track and manage multiple SSH sessions - : Built with poem-mcpserver to enable AI/LLM compatibility - : Maintain SSH sessions across multiple commands No Rust toolchain required - just Docker! Prerequisites: - Rust 1.70.0 or later - Cargo package manager To use SSH-MCP with mcpServers, add the following configuration to your mcpServers JSON configuration: This will register the SSH handler, allowing LLMs to manage SSH connections through your MCP server.

README

以下为原文 README 节选,完整内容请查看原文。

SSH-MCP Server

A Rust implementation of an SSH client server with Model Context Protocol (MCP) integration, allowing Large Language Models (LLMs) to connect to a SSH server and utilize SSH features.

Lightweight and Efficient:

  • 🚀 ssh-mcp: only 4.3MB binary size, 1.8MB memory footprint
  • 🔄 ssh-mcp-stdio: only 1.5MB binary size, 2.3MB memory usage
  • 🐳 docker: only 27.5MB final image size

Features

  • SSH Client Integration: Connect to SSH servers via MCP commands
  • SSH Command Execution: Run commands on remote SSH servers
  • Port Forwarding: Setup SSH tunnels and port forwards (enabled by default via the port_forward feature)
  • Session Management: Track and manage multiple SSH sessions
  • MCP Protocol Support: Built with poem-mcpserver to enable AI/LLM compatibility
  • Stateful Connections: Maintain SSH sessions across multiple commands

Installation and Integration

You have two options for installation:

No Rust toolchain required - just Docker!

# Pull the pre-built image from Docker Hub
docker pull mingyang91/ssh-mcp

# Run the server
docker run -p 8000:8000 mingyang91/ssh-mcp

Or build the image yourself:

# Build the Docker image
docker build -t ssh-mcp .

# Run the server
docker run -p 8000:8000 ssh-mcp

Option 2: Installing via Cargo

Prerequisites:

  • Rust 1.70.0 or later
  • Cargo package manager
cargo install ssh-mcp

Integration with mcpServers

To use SSH-MCP with mcpServers, add the following configuration to your mcpServers JSON configuration:

If installed via Cargo:

{
  "mcpServers": {
    "ssh": {
      "command": "ssh-mcp-stdio", 
      "args": []
    }
  }
}

If using Docker:

{
  "mcpServers": {
    "ssh": {
      "command": "docker",
      "args": ["run", "--entrypoint", "ssh-mcp-stdio", "-i", "--rm", "ssh-mcp"]
    }
  }
}

This will register the SSH handler, allowing LLMs to manage SSH connections through your MCP server.

Usage

Connecting to an SSH Server

Using Password Authentication

{
  "command": "ssh_connect",
  "params": {
    "address": "example.com:22",
    "username": "user",
    "password": "password"
  }
}

Using Key Authentication

{
  "command": "ssh_connect",
  "params": {
    "address": "example.com:22",
    "username": "user",
    "key_path": "/path/to/private_key"
  }
}

Using SSH Agent Authentication

{
  "command": "ssh_connect",
  "params": {
    "address": "example.com:22",
    "username": "user"
  }
}

Response:

{
  "session_id": "c8a3b2e1-4f5d-6e7c-8a9b-0c1d2e3f4a5b",
  "message": "Successfully connected to [email protected]:22",
  "authenticated": true
}

If connection fails:

{
  "error": "Failed to connect: Connection refused"
}
在 GitHub 查看完整 README

安装

docker run --entrypoint ssh-mcp-stdio -i --rm ssh-mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "ssh": { "command": "ssh-mcp-stdio", "args": [] } } }