Building Your Own MCP Server for AI
Deploy Your MCP Server
Run the server on a VPS or cloud VM, keep it alive, and put HTTPS in front with a reverse proxy.
Deployment is boring on purpose: a Linux user, a venv, a systemd unit, nginx, and a certificate. If that looks like this site’s own stack, that is intentional.
Ship the code
- Copy the project to the server (git clone is enough).
- Create a venv, install
requirements.txt. - Create a dedicated OS user that cannot sudo.
systemd
[Unit]
Description=hello MCP HTTP
After=network.target
[Service]
User=mcp
WorkingDirectory=/home/mcp/hello-mcp
EnvironmentFile=/home/mcp/hello-mcp.env
ExecStart=/home/mcp/hello-mcp/.venv/bin/python /home/mcp/hello-mcp/server.py
Restart=on-failure
[Install]
WantedBy=multi-user.targethello-mcp.env holds GITHUB_TOKEN= and MCP_TRANSPORT=http. chmod 600 that file. server.py must run the HTTP transport in this unit, not stdio — systemd is not an IDE.
nginx and HTTPS
Terminate TLS on nginx (or Caddy). Proxy to 127.0.0.1:PORT. Use Let’s Encrypt. Redirect HTTP to HTTPS. Do not open the app port on the public firewall.
location /mcp/ {
proxy_pass http://127.0.0.1:8000/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}Check it
systemctl statusis active. Journal has no traceback loop.- HTTPS URL loads from your laptop. HTTP redirects.
- A host config that uses the URL can list tools. Secrets are not in git.