Skip to main content
Glama

MCP SSH Agent

by AiondaDotCom

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.

-
security - not tested
F
license - not found
-
quality - not tested

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.

  1. Overview
    1. Example Usage
      1. Key Features
        1. Functions
          1. Installation
            1. Usage
              1. Integration with MCP Clients
                1. Project Structure
                  1. Requirements
                    1. Security Notes
                      1. Troubleshooting
                        1. Development

                          Related MCP Servers

                          • A
                            security
                            A
                            license
                            A
                            quality
                            A simple MCP server that facilitates website fetching through a configurable server platform using stdio or SSE transport, allowing integration with tools like Cursor for streamlined access.
                            Last updated -
                            2
                            23
                            Python
                            MIT License
                          • -
                            security
                            F
                            license
                            -
                            quality
                            A simple MCP server that allows accessing and executing shell commands on a VM machine through a web-based terminal interface, with automatic tunneling to make the VM accessible from anywhere.
                            Last updated -
                            39
                            2
                            JavaScript
                          • -
                            security
                            A
                            license
                            -
                            quality
                            An MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.
                            Last updated -
                            13
                            JavaScript
                            MIT License
                            • Linux
                            • Apple
                          • -
                            security
                            -
                            license
                            -
                            quality
                            A secure server that implements the Model Context Protocol (MCP) to enable controlled execution of authorized shell commands with stdin support.
                            Last updated -
                            Python

                          View all related MCP servers

                          MCP directory API

                          We provide all the information about MCP servers via our MCP API.

                          curl -X GET 'https://glama.ai/api/mcp/v1/servers/AiondaDotCom/mcp-ssh'

                          If you have feedback or need assistance with the MCP directory API, please join our Discord server