Dev.to
8/1/2026

Building a Secure MCP Server for AI-Assisted VPS Operations Without Giving the AI a Shell
Short summary
A detailed walkthrough of building a secure MCP (Model Context Protocol) server that lets AI assistants inspect a VPS without exposing a raw shell. The server maps each AI tool call to a fixed, allowlisted script via SSH, rejecting free-form command execution entirely. The architecture uses Python with AsyncSSH and Pydantic, prioritizing a narrow control-plane design where the AI gets operational visibility without operational chaos.
- •MCP server exposes only narrowly defined operations (system health, disk usage, container logs, SSL expiry) mapped to fixed allowlisted scripts
- •Security model: no free-form shell execution, structured JSON requests only, dedicated SSH user without unrestricted sudo
- •Python chosen over Java for faster iteration on a small control-plane MVP; Spring Boot would make sense if integrated into a larger internal platform
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



