Get the FREE Ultimate OpenClaw Setup Guide →

django

Connect Django apps to AI assistants with Model Context Protocol. Simple decorators expose models, admin functions, and custom tools to Claude and other AI assistants.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio hyperb1iss-django-mcp uvx django-mcp \
  --env DJANGO_MCP_URL_PREFIX="mcp (URL path prefix for MCP endpoints)" \
  --env DJANGO_MCP_SERVER_NAME="My Django MCP Server (optional, defaults to project name)" \
  --env DJANGO_MCP_INSTRUCTIONS="Instructions for the AI assistant"

How to use

Django-MCP exposes your Django app to AI assistants using the Model Context Protocol. It auto-discovers MCP components such as tools (functions), models, and DRF viewsets, and serves them over an ASGI-compatible channel so an AI assistant can invoke your app’s capabilities. To use it, install the package in your Django project, add the MCP app to INSTALLED_APPS, configure the basic MCP settings, and run your Django server. The AI assistant can then connect to your MCP endpoint (for example /mcp/) and start invoking tools like product searches, model CRUD operations, and more, depending on what you’ve exposed with the provided decorators and admin/DRF integrations. The system supports ASGI for real-time communications and SSE-based MCP messaging, making interactions feel responsive and stateful where needed.

How to install

Prerequisites:

  • Python 3.10 or newer
  • Django 4.0 or newer
  • Access to install Python packages (pip)

Step-by-step:

  1. Install Django-MCP in your Django project:

    pip install django-mcp

  2. Optionally install via UV (recommended for asynchronous MCP communications):

    uv add django-mcp

  3. Add the MCP app to your Django project settings:

    settings.py

    INSTALLED_APPS = [ # ... your other apps ... 'django_mcp', ]

  4. Configure MCP settings (optional but recommended):

    settings.py

    DJANGO_MCP_SERVER_NAME = "My Django App" DJANGO_MCP_URL_PREFIX = "mcp" # URL prefix for MCP endpoints DJANGO_MCP_INSTRUCTIONS = "This server provides access to my Django app."

  5. Run your Django development server (ASGI) and expose MCP endpoints:

    python manage.py runserver 0.0.0.0:8000

    Or with UV (if using uvx):

    uvx django-mcp

  6. Visit the MCP dashboard and endpoints to verify discovery and tool exposure as described in the docs.

Additional notes

Tips and notes:

  • Controller and tools are auto-discovered if you enable auto-discovery in settings (DJANGO_MCP_AUTO_DISCOVER).
  • You can expose Django models, admin actions, and DRF viewsets for AI access via the decorated interfaces.
  • Configure CORS and security settings as needed, especially when exposing MCP endpoints publicly.
  • If you modify exposed tools or resources, re-run the server or trigger a refresh to update the MCP registry.
  • The dashboard is available at /mcp/dashboard/ to review all registered tools, resources, and prompts.

Related MCP Servers

Sponsor this space

Reach thousands of developers