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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。