ssh-alias-mcp
Enables AI agents to SSH into Linux servers, run commands, deploy code, and manage servers via natural language, also doubles as a CLI for manual use.
README
π ssh-alias-mcp β Let Your AI Agent Manage Linux Servers
π Full Technical Docs (DOCS.md) β architecture, all config fields, MCP tools reference, script examples
Agent Setup in One Sentence
Read https://github.com/leehom0123/ssh-alias-mcp/blob/main/AI_INSTALL.md β set up the SKILL and install the MCP service as described.
What Is This?
A ~2,000-line Python tool that lets AI agents (Claude Code, Codex CLI, Cursor, Windsurf) SSH into your Linux servers, run commands, deploy code, tail logs, restart services. It also doubles as a nice CLI for day-to-day manual use.
One set of YAML config, one connection pool, works for both AI and humans.
Why I Built This
I do a lot of dev and ops work: deploying projects, checking logs, troubleshooting server crashes. Painful, honestly β every time it's open terminal, SSH in, type commands. One server is fine; bouncing between several gets old fast.
When AI agents started getting capable, I thought: why not let AI check my logs, analyze errors, deploy apps? But there was a problem β every time I asked AI to do something, it had to write out SSH connection details from scratch, burning through tokens fast. It hurt to watch.
I first wrote a Python script for AI to call. It worked, but it didn't feel clean enough. So I took it all the way β built this MCP + CLI tool: configure your servers in YAML once, AI and CLI both use it, AI never writes connection boilerplate again.
Open-sourcing in case other devs stuck in the ops trenches find it useful.
Get Started
π₯ Installation: read AI_INSTALL.md β set up MCP and add SKILL.md as described. (You can also just paste the GitHub URL to your AI agent and let it install itself.)
| Tool | Description |
|---|---|
ssh_list_servers |
List all configured servers |
ssh_run |
Execute a command on a remote server |
ssh_run_sudo |
Execute as root (requires sudo_password) |
ssh_upload_script |
Upload a script, optionally run immediately |
ssh_run_script |
Run an uploaded script |
ssh_run_alias |
Run an alias-defined command |
ssh_alias:{server}:{name} |
One-click alias, one MCP tool per alias |
β οΈ Don't inline
sudo -Sβ usessh_run_sudo. For docker permission issues, setsudo: truein the alias.
β¨οΈ CLI Mode
python cli.py list-servers # See all servers
python cli.py my-server run "uptime" # Run a command
python cli.py my-server sudo "apt update" # Run as root
python cli.py my-server alias healthcheck # Run an alias
python cli.py my-server upload script.sh -r # Upload & run immediately
π― Key Highlights
1. YAML Config Reuse + extends Inheritance
One server = one YAML file. Structure it like this:
servers/
βββ _shared/common.yml # Shared aliases, inherited by all servers
βββ prod-web-01.yml # Production server
βββ prod-web-02.yml # Another production server
βββ staging.yml # Staging
Define common checks and commands once in _shared/common.yml β every server extends it:
# _shared/common.yml
aliases:
- name: healthcheck
inline: "df -h / && free -h && uptime"
desc: "One-click health check"
- name: docker-ps
inline: "docker ps --format 'table {{.Names}}\t{{.Status}}'"
desc: "Running containers"
- name: logs-nginx
inline: "tail -50 /var/log/nginx/error.log"
desc: "Nginx error logs"
# prod-web-01.yml
extends:
- _shared/common.yml # Inherit shared aliases
server:
host: "198.51.100.10"
user: "deploy"
password: "xxx"
sudo_password: "xxx"
system: "Ubuntu 22.04 LTS"
aliases:
- name: deploy
script: deploy.sh
desc: "Deploy main site"
timeout: 600
sudo: true
- name: restart
inline: "systemctl restart my-app && echo 'restarted'"
desc: "Restart app"
sudo: true
5, 10, or 20 servers β same effortless maintenance. Same aliases work for AI and CLI. You never write anything twice.
2. Aliases Become MCP Tools Automatically
Define deploy in YAML, and your AI agent gets ssh_alias:prod-web-01:deploy. One line of YAML = one AI skill. To the agent, server operations feel like local function calls.
3. One Connection Pool, Shared by AI & Humans
AI Agent βββ MCP Protocol βββ ssh_client.py βββ Remote Server
Terminal βββ CLI βββββββββββββββ ssh_client.py βββ Remote Server
Same SSH connection, same connection pool, same config. AI deploys something, then you verify with python cli.py β same logic underneath. No duplicate tools, no duplicate config.
4. Connection Pool + Proxy + Sudo
- Connection pool: SSH connections auto-reused with 60s keepalive β no repeated handshakes
- SOCKS5 proxy: Global or per-server, auto falls back to direct connect if proxy is down
- Sudo: configure
sudo_passwordonce, run root commands without interactive prompts
Who Is This For?
- π§βπ» You manage multiple VPS instances and don't want to SSH into each one manually
- π₯ Small teams with no dedicated DevOps β let AI help with daily checks
- π€ You want your AI agent to actually do things, not just chat
Tech Stack
Pure Python. Dependencies: paramiko + pyyaml + pysocks. Under 2,000 lines. Easy to read and hack.
pip install -r requirements.txt
License & Feedback
MIT licensed. Use it however you want. A β means a lot to me.
Issues and PRs welcome β Chinese or English, both fine.
GitHub: https://github.com/leehom0123/ssh-alias-mcp
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.