Sponsored by Deepsite.site

MCP SSH Docker Server

Created By
aweher8 months ago
MCP server to play with IA and containerlab instances
Content

MCP SSH Docker Server

A Message Control Protocol (MCP) server that provides SSH and Docker command execution capabilities. This server allows you to execute commands on remote systems and Docker containers through a standardized interface.

Features

  • SSH command execution on remote systems
  • Docker container command execution
  • Real-time command output streaming
  • Progress reporting for long-running commands
  • Structured JSON output support
  • Command cancellation support
  • Connection and command timeouts
  • Comprehensive error handling

Prerequisites

  • Python 3.7+
  • SSH access to target system
  • Docker installed on target system (for Docker commands)

Installation

Using pip

pip install mcp-ssh-frr

From source

  1. Clone the repository:
git clone https://github.com/aweher/mcp-ssh-frr.git
cd mcp-ssh-frr
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Install the package in development mode:
pip install -e .
  1. Configure SSH:

    • Place your SSH private key in ./config/id_rsa

    • Set up environment variables:

      export SSH_HOST="your-remote-host"
      export SSH_USER="your-username" # Defaults to root
      export SSH_PORT="22"  # Optional, defaults to 22
      
    • Don't forget to add your pubkey into authorized_keys file on your-remote-host

Usage

Starting the Server

python mcp_ssh_docker_server.py

Available Tools

1. SSH Command Execution (ssh_exec)

Execute any command on the remote system:

{
    "name": "ssh_exec",
    "args": {
        "command": "ls",
        "args": ["-la", "/etc"],
        "stream": false,  # Set to true for real-time output
        "structured_output": false  # Set to true for JSON output
    }
}

2. Docker Command Execution (ssh_exec_docker)

Execute commands inside Docker containers:

{
    "name": "ssh_exec_docker",
    "args": {
        "container": "my-container",
        "command": "vtysh",
        "args": ["-c", "show ip bgp"],
        "stream": false,
        "structured_output": false
    }
}

List available containers:

{
    "name": "ssh_exec_docker",
    "args": {
        "list_containers": true,
        "structured_output": false
    }
}

Output Formats

  1. Text Output (default):
$ command arg1 arg2
(exit code 0)

output line 1
output line 2
  1. Structured JSON Output:
{
    "command": "command arg1 arg2",
    "exit_code": 0,
    "stdout": "output line 1\noutput line 2",
    "stderr": "",
    "duration": 0.123,
    "metadata": {
        "container": "my-container"  // For Docker commands
    }
}
  1. Progress Updates (when streaming):
[progress] 45% - Bytes read: 1024

Configuration

Timeouts

  • SSH Connection Timeout: 10 seconds
  • Command Execution Timeout: 30 seconds
  • Stream Maximum Time: 300 seconds (5 minutes)

Buffer Size

  • Stream Buffer Size: 1024 bytes

Error Handling

The server handles various error scenarios:

  • Connection timeouts
  • Authentication failures
  • Command execution errors
  • Docker container errors
  • Command cancellation

Security

  • Uses SSH key-based authentication
  • Command arguments are properly escaped
  • No command injection vulnerabilities
  • Secure connection handling

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

GPLv3

Author

Ariel S. Weher <ariel[at]weher.net>

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Serper MCP ServerA Serper MCP Server
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
DeepChatYour AI Partner on Desktop
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.