home / mcp / django migrations mcp server

Django Migrations MCP Server

A Model Context Protocol (MCP) service for managing Django migrations in distributed environments.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "mrrobotke-django-migrations-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-d",
        "--name",
        "django_migrate_mcp",
        "-e",
        "DJANGO_SETTINGS_MODULE=your_project.settings",
        "-e",
        "MCP_SERVICE_PORT=8000",
        "-v",
        "/path/to/your/django/project:/app/project",
        "-p",
        "8000:8000",
        "django-migrations-mcp"
      ],
      "env": {
        "REDIS_URL": "redis://host.docker.internal:6379",
        "MCP_SERVICE_PORT": "8000",
        "DJANGO_SETTINGS_MODULE": "your_project.settings"
      }
    }
  }
}

You can manage Django migrations across distributed services by running a dedicated MCP server. This service wraps Django’s migration commands and exposes them as MCP endpoints, enabling centralized migration management, validation, and safe application in CI/CD pipelines.

How to use

You interact with the Django Migrations MCP Server using an MCP client. First, verify the current migration status across apps, then generate and apply migrations in a controlled way. Use the client to check status, create new migrations with validation, and apply migrations with safety checks. You can integrate these steps into your CI/CD workflow to ensure migrations are correct before affecting production.

How to install

Prerequisites: Python and Docker installed on your machine, plus access to your Django project. You will also need a working network to pull container images or run local containers.

  • If you use Docker, you can run the provided image to start the MCP server.
  • No source code modification is required for basic usage.

Step-by-step commands to run locally with Docker (complete runtime command shown):

docker run -d \
  --name django_migrate_mcp \
  -e DJANGO_SETTINGS_MODULE=your_project.settings \
  -e MCP_SERVICE_PORT=8000 \
  -v /path/to/your/django/project:/app/project \
  -p 8000:8000 \
  django-migrations-mcp

Additional sections

Configuration focuses on environment variables that control how the MCP server runs, including which Django settings module to use and which port the service exposes.

Security and best practices include restricting access to the MCP endpoints, using CI/CD gating for migrations, and validating migration plans before applying changes to environments beyond development.

Notes about usage: you can run the service directly with Python or via Docker. When running through Docker, you typically build the image first and then start a container with the necessary environment variables and volume mounts to point to your Django project.

Tools and endpoints

The Django Migrations MCP Server provides key tools to manage migrations programmatically via MCP endpoints.

  • show_migrations — check migration status across apps
  • make_migrations — create new migrations with validation
  • migrate — apply migrations with safety checks

Available tools

show_migrations

Check the current migration status for all apps, equivalent to Django's showmigrations command.

make_migrations

Generate new migrations for selected apps with validation to ensure proper structure before applying.

migrate

Apply migrations with safety checks, including plan or dry-run options to pre-check changes.