FS

fryjustinc/ssh-mcp-sessions

开发工具

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

18 stars 7 forks 质量 70 趋势 22MIT

An MCP tool to manage persistent ssh connections to a collection of hosts enabling remote development, deployment, and information gathering.

概览

A Model Context Protocol (MCP) server that gives LLM clients safe, persistent SSH access to remote machines. ssh-mcp lets MCP-compatible clients (such as Claude Code, Cursor, or custom MCP inspectors) control remote machines through SSH. Once hosts are registered, the server maintains persistent shell sessions that retain environment state between commands—ideal for multi-step workflows, long-running processes, or interactive diagnostics. The server is implemented in TypeScript on top of the official @modelcontextprotocol/sdk. - exposes functionality through standard MCP tool definitions. - keep shell sessions alive, preserving working directory, environment variables, and process state across multiple commands. - manage SSH targets through durable JSON configuration (~/.ssh-mcp/hosts.json). - supports passwords, private keys, and SSH agent forwarding (fallback). - sessions auto-close after prolonged inactivity; commands are marked and monitored for completion.

README

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

SSH MCP Server

A Model Context Protocol (MCP) server that gives LLM clients safe, persistent SSH access to remote machines.


Table of Contents

  1. Overview
  2. Key Features
  3. Architecture
  4. Installation
  5. Running the Server
  6. Client Integrations
  7. Host Configuration
  8. Session Management
  9. Authentication Modes
  10. Timeouts & Inactivity Handling
  11. Directory Structure
  12. Using the MCP Tools
  13. Testing
  14. Troubleshooting
  15. Security Considerations
  16. Contributing
  17. License

Overview

ssh-mcp lets MCP-compatible clients (such as Claude Code, Cursor, or custom MCP inspectors) control remote machines through SSH. Once hosts are registered, the server maintains persistent shell sessions that retain environment state between commands—ideal for multi-step workflows, long-running processes, or interactive diagnostics.

The server is implemented in TypeScript on top of the official @modelcontextprotocol/sdk.


Key Features

  • MCP-compliant: exposes functionality through standard MCP tool definitions.
  • Persistent sessions: keep shell sessions alive, preserving working directory, environment variables, and process state across multiple commands.
  • Stored host profiles: manage SSH targets through durable JSON configuration (~/.ssh-mcp/hosts.json).
  • Flexible authentication: supports passwords, private keys, and SSH agent forwarding (fallback).
  • Timeout & cleanup safeguards: sessions auto-close after prolonged inactivity; commands are marked and monitored for completion.
  • Structured listings: query active sessions and saved hosts directly from the MCP client.

Architecture

MCP Client ─┬─> add-host / edit-host / remove-host
            │
            ├─> list-hosts
            │
            ├─> start-session ─┬─> PersistentSession (ssh2 shell)
            │                  ├─> exec (reuses shell, captures stdout/stderr)
            │                  └─> close-session / auto-timeout
            │
            └─> list-sessions

Persistent configuration → ~/.ssh-mcp/hosts.json
在 GitHub 查看完整 README

安装

npx ssh-mcp-sessions
新手?先看 mcpskill.org 教程 →

配置

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