Install and Set Up an MCP Server on a Debian 12 VPS

Install and Set Up an MCP Server on a Debian 12 VPS


Project Description
  • 1
  • July 25, 2025

Last updated: July 2025
Difficulty: Intermediate
Estimated Time: 30–45 minutes


Introduction

The Model Context Protocol (MCP) Server is a powerful backend for AI-driven applications. It allows you to integrate AI content generation, chatbots, and marketing automation into your projects. In this tutorial, you’ll learn how to install and configure an MCP server on a Debian 12 VPS — perfect for powering websites, AI marketing tools, and n8n workflows.


Prerequisites

Before we start, ensure that you have:

  • A Debian 12 VPS (with root access).

  • Docker and Docker Compose installed.

  • A domain or subdomain (e.g., mcp.yourdomain.com) pointing to your VPS IP.

  • NGINX and Certbot installed for SSL (HTTPS).

  • Basic knowledge of the Linux command line.


Step 1: Update Your VPS

Update the package lists and upgrade existing packages:

bash
sudo apt update && sudo apt upgrade -y

Step 2: Install Docker and Docker Compose

If you don’t already have Docker, install it with:

bash
sudo apt install -y ca-certificates curl gnupg lsb-release curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io

Install Docker Compose:

bash
sudo apt install -y docker-compose-plugin

Enable Docker at startup:

bash
sudo systemctl enable docker sudo systemctl start docker

Step 3: Create Project Directory

Create a directory for your MCP server:

bash
mkdir -p ~/docker/mcp cd ~/docker/mcp

Step 4: Create Docker Compose File

Create a docker-compose.yml file:

bash
nano docker-compose.yml

Paste the following (adjust domain names and API keys as needed):

yaml
version: "3.8" services: mcp-server: build: ./mcp-server container_name: mcp-server restart: always environment: - OPENAI_API_KEY=your_openai_api_key_here - HEYGEN_API_KEY=your_heygen_api_key_here - MCP_PORT=3000 ports: - "127.0.0.1:3000:3000"

Save and exit.


Step 5: Get the MCP Server Files

Download or clone the MCP server repository into ./mcp-server:

bash
git clone https://github.com/<repo>/mcp-server.git ./mcp-server

(Replace <repo> with your MCP server repository URL.)


Step 6: Start the MCP Server

Build and start the container:

bash
docker compose up -d --build

Check logs:

bash
docker logs -f mcp-server

Step 7: Configure NGINX Reverse Proxy

To serve the MCP server securely via HTTPS, create a new NGINX config:

bash
sudo nano /etc/nginx/sites-available/mcp

Paste:

nginx
server { listen 80; server_name mcp.yourdomain.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name mcp.yourdomain.com; ssl_certificate /etc/letsencrypt/live/mcp.yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mcp.yourdomain.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

Enable and test the configuration:

bash
sudo ln -s /etc/nginx/sites-available/mcp /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx

Step 8: Add SSL with Certbot

Install Certbot if not already installed:

bash
sudo apt install certbot python3-certbot-nginx -y

Obtain a certificate:

bash
sudo certbot --nginx -d mcp.yourdomain.com --email you@yourdomain.com --agree-tos --no-eff-email

Step 9: Test the MCP Server

Send a test request:

bash
curl -X POST https://mcp.yourdomain.com/generate-content \ -H "Content-Type: application/json" \ -d '{"prompt":"Write 2 LinkedIn posts about AI marketing"}'

If everything is correct, you’ll receive AI-generated content as JSON.


Step 10: Integrate with n8n or Your Website

  • n8n: Use an HTTP Request node to call https://mcp.yourdomain.com/generate-content and store results in Google Sheets or databases.

  • WordPress: Use a custom plugin or AJAX call to send form data to https://mcp.yourdomain.com/store-lead.

  • Scaling: Add multiple MCP containers or use a load balancer if traffic increases.