Skip to main content

🚀 ServerAsMcp

Give your AI agents unrestricted root access to unlimited Linux servers — via MCP.

npm version PyPI version License: MIT MCP

Quick Start · Configuration · Tools · Deployment Skill · Security · Contributing


What is ServerAsMcp?

ServerAsMcp is a Model Context Protocol (MCP) server that lets AI agents (Codex, Claude, Cursor, etc.) connect to and control unlimited remote Linux servers over SSH. Once configured, your agent can:

  • ⚡ Execute any shell command as root on any server
  • 📦 Upload and deploy files via SFTP
  • 🌐 Configure Cloudflare DNS to make apps publicly live
  • 🔄 Self-heal failed deployments — it reads logs, diagnoses errors, fixes them, and retries until production is confirmed
  • 🖥️ Run the same command across all servers simultaneously

No Web UI. No multi-user complexity. No sandbox. Just raw power for a single operator who trusts their agent.


✨ Features

Multi-server Define unlimited servers via SERVER_N_* env vars or add at runtime
Password + SSH key auth Both supported per-server
Any command Zero restrictions — the agent runs literally anything
File deployment Upload via SFTP, then run commands
Built-in deployment skill Agent calls get_skill to learn the full 7-phase production workflow
Cloudflare DNS integration Automatically create/update A records via API
Self-healing loop Detects failures, reads logs, auto-fixes, retries up to 10 times
Audit logging Every operation logged to ~/.mcp-deploy/audit.log
Dual runtime Available as npx (Node.js) and uvx (Python)
Zero network listener Runs as stdio subprocess — no open ports, no attack surface

🚀 Quick Start

Option 1: npx (Node.js)

Copy-paste into your MCP client config (Claude Desktop, Codex, Cursor, etc.):

{
  "mcpServers": {
    "deploy": {
      "command": "npx",
      "args": ["-y", "serverasmcp"],
      "env": {
        "SERVER_1_NAME": "web-1",
        "SERVER_1_HOST": "203.0.113.5",
        "SERVER_1_USER": "root",
        "SERVER_1_PASSWORD": "your-password-1",

        "SERVER_2_NAME": "db-1",
        "SERVER_2_HOST": "203.0.113.6",
        "SERVER_2_USER": "root",
        "SERVER_2_PASSWORD": "your-password-2"
      }
    }
  }
}

Option 2: uvx (Python / uv)

{
  "mcpServers": {
    "deploy": {
      "command": "uvx",
      "args": ["serverasmcp"],
      "env": {
        "SERVER_1_NAME": "web-1",
        "SERVER_1_HOST": "203.0.113.5",
        "SERVER_1_USER": "root",
        "SERVER_1_PASSWORD": "your-password-1"
      }
    }
  }
}
{
  "mcpServers": {
    "deploy": {
      "command": "npx",
      "args": ["-y", "serverasmcp"],
      "env": {
        "SERVER_1_NAME": "web-1",
        "SERVER_1_HOST": "203.0.113.5",
        "SERVER_1_USER": "root",
        "SERVER_1_KEY_PATH": "/home/you/.ssh/id_rsa"
      }
    }
  }
}

That's it. Your agent now has root access to all configured servers.


⚙️ Configuration

Environment variables per server

Add as many server blocks as you need — SERVER_1_*, SERVER_2_*, SERVER_3_*, etc.

Variable Required Default Description
SERVER_N_NAME No server-N Label the agent uses to reference this server
SERVER_N_HOST ✅ — IP address or hostname
SERVER_N_PORT No 22 SSH port
SERVER_N_USER No root SSH username
SERVER_N_PASSWORD One of — SSH password
SERVER_N_KEY_PATH One of — Path to SSH private key file
SERVER_N_KEY One of — SSH private key content (inline)

Auth rule: Each server needs exactly one of SERVER_N_PASSWORD, SERVER_N_KEY_PATH, or SERVER_N_KEY.

Runtime server management

The agent can also add/remove servers at runtime using the add_server and remove_server tools. These are saved to ~/.mcp-deploy/servers.json and persist across sessions.

Storage

File Purpose
~/.mcp-deploy/servers.json Runtime-added servers
~/.mcp-deploy/audit.log Append-only operation log

🛠️ Tools

Your agent gets 8 tools:

Tool Description
get_skill Returns the full deployment skill — the agent should call this first
list_servers Show all configured servers (env + runtime)
run_command Execute any shell command on a specific server
run_all Execute the same command on all servers simultaneously
deploy_file Upload file(s) via SFTP + run commands after
check_status Test SSH connectivity + get system info
add_server Add a server at runtime
remove_server Remove a runtime-added server

Tool examples

Agent: run_command(server: "web-1", command: "apt update && apt upgrade -y")
Agent: run_all(command: "df -h && free -m")
Agent: deploy_file(server: "web-1", files: [{content: "...", remotePath: "/opt/app/index.html"}], commands: ["systemctl restart nginx"])
Agent: check_status(server: "db-1")

📖 Deployment Skill

When your agent calls get_skill, it receives a complete production deployment workflow:

Phase 1: Server Registration
    └── add_server → check_status (verify SSH connectivity)

Phase 2: Git Detection & Push
    └── Check git remote → push latest → or ask user to set up Git

Phase 3: Server Preparation
    └── Detect project type → install Node/Python/Docker/Git if missing

Phase 4: Deploy Application
    └── git clone on server → npm install / pip install / docker compose up

Phase 5: Configure & Start Service
    └── Create systemd service → start → verify locally

Phase 6: Cloudflare DNS Configuration
    └── Get Zone ID → get server IP → create/update A record → enable proxy

Phase 7: Self-Healing Production Loop (up to 10 attempts)
    ├── Is service running? → restart if not
    ├── Is app responding on localhost? → read logs, diagnose, fix
    ├── Is public URL live? → wait for DNS, check SSL
    └── Loop until confirmed: systemctl active + localhost 200 + public 200

Error auto-fix reference

The skill includes a built-in error diagnosis table:

Error Auto-fix
MODULE_NOT_FOUND npm install
EADDRINUSE Kill process on port, restart
SyntaxError Show code to user
Permission denied Fix file permissions
Port blocked ufw allow <port>
DNS not resolving Wait for Cloudflare propagation
SSL errors Fix Cloudflare SSL mode
ECONNREFUSED (DB) Check database service status

Deployment summary

After a successful deployment, the agent produces:

══════════════════════════════════════════════════════
  DEPLOYMENT SUMMARY
══════════════════════════════════════════════════════

  Status: ✅ LIVE

  Server:    web-1 (203.0.113.5)
  Git:       main @ abc1234
  App:       /opt/app
  Service:   app.service (systemd, active)
  Port:      3000
  URL:       https://app.mydomain.com
  DNS:       A record → 203.0.113.5 (Cloudflare proxied)
  SSL:       Cloudflare Full (strict)

  Issues found & fixed:
    1. Missing express → npm install
    2. Port 3000 blocked → ufw allow 3000

  Verified:
    - systemctl is-active app → active
    - curl localhost:3000 → 200 OK
    - curl https://app.mydomain.com → 200 OK

══════════════════════════════════════════════════════

💬 Example Conversations

Simple command execution

You: "Run apt update on web-1"
Agent: calls run_command(server: "web-1", command: "apt update")
Agent: "Exit code: 0. All packages updated."

You: "Check disk space on all servers"
Agent: calls run_all(command: "df -h /")
Agent: "web-1: 45% used. db-1: 78% used. cdn-1: 12% used."

Full deployment

You: "Deploy my app from https://github.com/me/myapp to web-1 and make it live at app.mydomain.com"
Agent: calls get_skill → reads the full workflow
Agent: calls check_status(server: "web-1") → connected
Agent: calls run_command → git clone https://github.com/me/myapp /opt/app
Agent: calls run_command → npm install
Agent: calls deploy_file → creates systemd service
Agent: calls run_command → systemctl start app
Agent: calls run_command → Cloudflare API to create DNS record
Agent: calls run_command → curl https://app.mydomain.com → 200 OK
Agent: "✅ App is LIVE at https://app.mydomain.com"

Self-healing in action

You: "Deploy my app to web-1"
Agent: calls run_command → npm install
Agent: "Error: Cannot find module 'express'"
Agent: calls run_command → npm install express
Agent: calls run_command → systemctl restart app
Agent: calls run_command → curl localhost:3000 → 200 OK
Agent: "Fixed missing dependency. App is now running."

🔒 Security

⚠️ READ THIS BEFORE USE

This tool gives AI agents unrestricted root access to your servers. This is by design.

What this means

  • The agent can execute literally any command — including rm -rf /, reboot, shutdown
  • There is no sandbox, no allowlist, no confirmation gate
  • SSH credentials are stored in your MCP client config (or ~/.mcp-deploy/servers.json for runtime-added servers)

What protects you

Protection How
Audit log Every operation logged to ~/.mcp-deploy/audit.log with timestamp, tool, args, and result
Credential isolation Passwords/keys live in your MCP config — the agent sees tools, not raw credentials
stdio transport No network listener — the MCP server runs as a subprocess of your agent client
Single-user design Only you (the operator) can configure which servers the agent can access

Recommendations

  1. Use SSH keys instead of passwords
  2. Only connect trusted agents — you are giving them root
  3. Review the audit log regularly: cat ~/.mcp-deploy/audit.log
  4. Test on staging servers before production
  5. Rotate credentials if you suspect compromise

🏗️ Architecture

┌─────────────────────────────────────────────────────┐
│           MCP Client (Agent)                        │
│      Codex / Claude / Cursor / any MCP client       │
└──────────────────────┬──────────────────────────────┘
                       │ stdio (JSON-RPC)
                       ▼
┌─────────────────────────────────────────────────────┐
│           ServerAsMcp                               │
│                                                     │
│  ┌───────────────────────────────────────────────┐  │
│  │  MCP Tools                                    │  │
│  │  get_skill · list_servers · run_command       │  │
│  │  run_all · deploy_file · check_status         │  │
│  │  add_server · remove_server                   │  │
│  └──────────────────────┬────────────────────────┘  │
│                          │                          │
│  ┌──────────────────────▼────────────────────────┐  │
│  │  SSH Connection Pool (per server)             │  │
│  │  • Password auth                              │  │
│  │  • Private key auth                           │  │
│  │  • SFTP file transfer                         │  │
│  │  • Exec channel                               │  │
│  └──────────────────────┬────────────────────────┘  │
│                          │                          │
│  ┌──────────────────────▼────────────────────────┐  │
│  │  Config Store                                 │  │
│  │  • ~/.mcp-deploy/servers.json (runtime)       │  │
│  │  • ~/.mcp-deploy/audit.log                    │  │
│  │  • Env vars (SERVER_N_*)                      │  │
│  └───────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────┘
           │                │                │
           ▼                ▼                ▼
    ┌─────────────┐  ┌─────────────┐  ┌─────────────┐
    │   web-1     │  │   db-1      │  │   cdn-1     │
    │  (root SSH) │  │  (root SSH) │  │  (root SSH) │
    └─────────────┘  └─────────────┘  └─────────────┘

📦 Installation

From npm (Node.js)

npm install -g serverasmcp
# or use directly
npx -y serverasmcp

From PyPI (Python)

pip install serverasmcp
# or use directly
uvx serverasmcp

From source

git clone https://github.com/akillv/serverASmcp.git
cd serverASmcp
npm install && npm run build
node dist/index.js

🤝 Contributing

git clone https://github.com/akillv/serverASmcp.git
cd serverASmcp
npm install
npm run build

Run tests against a local SSH server:

# Start a test SSH server
mkdir -p /tmp/sshd-test
ssh-keygen -t ed25519 -f /tmp/sshd-test/ssh_host_ed25519_key -N ''
cat > /tmp/sshd-test/sshd_config << 'CONF'
Port 2222
HostKey /tmp/sshd-test/ssh_host_ed25519_key
PermitRootLogin yes
PasswordAuthentication yes
Subsystem sftp internal-sftp
CONF
/usr/sbin/sshd -f /tmp/sshd-test/sshd_config -D

# Run the MCP server
node dist/index.js

📄 License

MIT


Built with MCP · ssh2 · asyncssh

Metadata

Release files for serverasmcp 0.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serverasmcp 0.4.6
File Size Uploaded Provenance Actions
serverasmcp-0.4.6.tar.gz 15.5 kB Without provenance Details for serverasmcp-0.4.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for serverasmcp 0.4.6
File Interpreter ABI Platform Actions
serverasmcp-0.4.6-py3-none-any.whl Python 3 none any Details for serverasmcp-0.4.6-py3-none-any.whl

Total release size: 33.5 kB

Release files / serverasmcp-0.4.6.tar.gz

Download URL serverasmcp-0.4.6.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e050df3fa436016a51c46edc6d899bf41506d3627288b09ecdf3d4a079f152cc
BLAKE2b-256 checksum
How to use checksums
60b58385e3654ed2741135d762138bd0cd0776269de69d57e1b5a2c63b4427cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / serverasmcp-0.4.6-py3-none-any.whl

Download URL serverasmcp-0.4.6-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fa91197ccb4a6e4ae7f1ac409376e3f1c85ecf307f99a2155ba023af3501128
BLAKE2b-256 checksum
How to use checksums
c6e6080e6350a0f031ade1eced727a175b9ee3b043c163a6734af98ff57f7dab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for serverasmcp 0.4.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page