MCP SSH Agent

MCP SSH Agent

A server that enables secure interaction with remote SSH hosts through standardized MCP interface, providing functions like listing hosts, executing commands, and transferring files using native SSH tools.

Category
Visit Server

README

MCP SSH Agent

A Model Context Protocol (MCP) server for managing and controlling SSH connections via STDIO interface. Uses native SSH commands for maximum reliability and compatibility.

Overview

This MCP server provides SSH operations through a clean, standardized interface that can be used by MCP-compatible language models. The server automatically discovers SSH hosts from your ~/.ssh/config and ~/.ssh/known_hosts files and executes commands using local ssh and scp tools.

Example Usage

MCP SSH Agent Example

The screenshot above shows the MCP SSH Agent in action, demonstrating how it integrates with MCP-compatible clients to provide seamless SSH operations.

Key Features

  • Reliable SSH: Uses native ssh/scp commands instead of JavaScript SSH libraries
  • Automatic Discovery: Finds hosts from SSH config and known_hosts files
  • Full SSH Support: Works with SSH agents, keys, and all authentication methods
  • File Operations: Upload and download files using scp
  • Batch Commands: Execute multiple commands in sequence
  • Error Handling: Comprehensive error reporting with timeouts

Functions

The agent provides the following MCP tools:

  1. listKnownHosts() - Lists all known SSH hosts, prioritizing entries from ~/.ssh/config first, then additional hosts from ~/.ssh/known_hosts
  2. runRemoteCommand(hostAlias, command) - Executes a command on a remote host using ssh
  3. getHostInfo(hostAlias) - Returns detailed configuration for a specific host
  4. checkConnectivity(hostAlias) - Tests SSH connectivity to a host
  5. uploadFile(hostAlias, localPath, remotePath) - Uploads a file to the remote host using scp
  6. downloadFile(hostAlias, remotePath, localPath) - Downloads a file from the remote host using scp
  7. runCommandBatch(hostAlias, commands) - Executes multiple commands sequentially

Installation

# Clone the repository
git clone <repository-url>
cd mcp-ssh

# Install dependencies
npm install

Usage

The agent runs as a Model Context Protocol server over STDIO:

# Start the MCP SSH agent
npm start

# Or use the provided startup script
./start.sh

The server will output initialization messages and then wait for MCP requests over STDIO.

Integration with MCP Clients

To use this agent with an MCP-compatible client:

{
  "mcpServers": {
    "ssh": {
      "command": "./start.sh",
      "cwd": "/path/to/mcp-ssh"
    }
  }
}

Alternative (more verbose) configuration:

{
  "mcpServers": {
    "ssh": {
      "command": "node",
      "args": ["server-simple.mjs"],
      "cwd": "/path/to/mcp-ssh"
    }
  }
}

Project Structure

mcp-ssh/
├── server-simple.mjs          # Main MCP server implementation
├── package.json               # Dependencies and scripts
├── start.sh                   # Startup script (./start.sh)
├── doc/
│   └── example.png            # Usage example screenshot
├── src/
│   ├── ssh-client.ts          # SSH operations implementation (TypeScript reference)
│   ├── ssh-config-parser.ts   # SSH configuration parsing (TypeScript reference)
│   ├── types.ts               # TypeScript type definitions
│   └── index.ts               # (Empty - using server-simple.mjs)
├── README.md                  # This file
└── IMPLEMENTATION_NOTES.md    # Technical implementation details

Requirements

  • Node.js 18 or higher
  • Existing SSH configuration with key-based authentication
  • SSH keys must be properly configured (no interactive password prompts)

Security Notes

  • Uses existing SSH keys and configurations
  • Does not store or handle passwords
  • Requires pre-configured SSH key authentication
  • All operations use your existing SSH setup

Troubleshooting

  1. Server won't start: Check that all dependencies are installed with npm install
  2. SSH operations fail: Verify your SSH configuration works with standard ssh commands
  3. Host not found: Ensure hosts are properly configured in ~/.ssh/config

Development

The server is implemented in JavaScript using:

  • @modelcontextprotocol/sdk for MCP protocol compliance
  • Native ssh and scp commands for reliable SSH operations
  • ssh-config for parsing SSH configuration files
  • Node.js child_process for command execution

The implementation prioritizes reliability and simplicity by leveraging the existing SSH infrastructure rather than complex JavaScript SSH libraries.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured