linux
Linux MCP server for NAF AC4 workshop
claude mcp add --transport stdio jnprautomate-linux-mcp-server python linux_mcp_server.py \ --env LOG_LEVEL="Logging level (e.g., INFO, DEBUG)" \ --env LINUX_HOST="target Linux host IP or hostname" \ --env LINUX_PORT="SSH port (default 22)" \ --env LINUX_TIMEOUT="Connection timeout in seconds" \ --env LINUX_PASSWORD="SSH password (if using password auth; leave empty if using SSH key)" \ --env LINUX_USERNAME="SSH username for the target host" \ --env LINUX_SSH_KEY_PATH="Path to SSH private key (recommended if using key-based auth)" \ --env LINUX_BLOCK_CRITICAL="true|false to completely block critical commands" \ --env LINUX_ENABLE_WARNINGS="true|false to enable/disable warnings" \ --env LINUX_REQUIRE_CONFIRMATION="true|false whether dangerous commands require confirmation"
How to use
This MCP server runs a Linux command execution service over SSH on a remote host. It provides tools to execute arbitrary Linux commands, gather system information, list directories with detailed options, and perform file operations (read, write, append) securely using SSH authentication. You can connect using either SSH keys (recommended) or password authentication, and you can tune connection timeouts, logging levels, and safety settings (such as warning prompts and blocking of critical commands). The available tools include: execute_command to run shell commands remotely; get_system_info to collect hostname, OS, memory, disk usage, and CPU details; list_directory to inspect remote directories with optional detail; and file_operations to read, write, or append to files on the remote host. The server supports environment-based configuration for credentials and can automatically handle reconnection as needed.
How to install
Prerequisites:
- Python 3.x installed on the host running the MCP server
- Access to the remote Linux host via SSH (with either password or SSH key authentication)
- network access between the MCP host and the target Linux host
Steps:
- Install dependencies
pip install -r requirements.txt
- Create and configure environment file
cp .env.example .env
Edit .env with your credentials, for example:
# Required
LINUX_HOST=your-server-ip
LINUX_USERNAME=your-username
# Authentication (choose one)
LINUX_PASSWORD=your_password # if using password auth
# or
LINUX_SSH_KEY_PATH=/path/to/your/private/key # if using SSH key auth (recommended)
# Optional
LINUX_PORT=22
LINUX_TIMEOUT=30
LOG_LEVEL=INFO
LINUX_ENABLE_WARNINGS=true
LINUX_BLOCK_CRITICAL=false
LINUX_REQUIRE_CONFIRMATION=true
- Run the MCP server
python linux_mcp_server.py
- Alternative: run via uv (if using uv-based workflow)
uv run python linux_mcp_server.py
- Verify connectivity and test tools using the MCP client interface as described in the documentation.
Additional notes
Tips and notes:
- SSH keys are strongly recommended for authentication. Ensure your public key is added to the target host's authorized_keys.
- The environment includes several safety flags: LINUX_ENABLE_WARNINGS, LINUX_BLOCK_CRITICAL, and LINUX_REQUIRE_CONFIRMATION. When enabled, dangerous commands may be warned or blocked, and high-risk commands may require explicit confirmation.
- If you encounter connection issues, verify host, port, and SSH service status on the target, and ensure the MCP host has access through any firewalls. Ensure the SSH private key has proper permissions (600).
- For production deployments, consider restricting the MCP server user with limited sudo rights and using a dedicated user on the target host for MFA-style separation.
- Keep the .env file secure and do not commit it to version control.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP