Skip to content

Django Admin MCP

Expose Django admin models to MCP (Model Context Protocol) clients via HTTP. Add a mixin to your ModelAdmin classes and get instant access to CRUD operations, admin actions, model history, and more.


Features

  • Only Two Dependencies — Django and Pydantic, nothing else. No MCP SDK, no extra HTTP stack, no supply-chain sprawl
  • Token Authentication — secure Bearer token auth with per-token permissions and configurable expiry
  • Django Admin Permissions — respects existing view/add/change/delete permissions
  • Field Filtering — control which fields are exposed via mcp_fields and mcp_exclude_fields
  • Full CRUD — list, get, create, update, delete operations for all exposed models
  • Admin Actions — execute registered Django admin actions on selected records, including two-step confirmation flows
  • Bulk Operations — create, update, or delete multiple records at once
  • Model Introspection — describe model fields and relationships programmatically
  • Related Objects — traverse foreign keys and reverse relations
  • Change History — access Django admin's history log for audit trails
  • Autocomplete — search suggestions for foreign key fields
  • MCP Prompts & Resources — workflow guides plus read-only data access via models:// and data:// URIs

Quick Example

from django.contrib import admin
from django_admin_mcp import MCPAdminMixin
from .models import Article

@admin.register(Article)
class ArticleAdmin(MCPAdminMixin, admin.ModelAdmin):
    mcp_expose = True  # Exposes list_article, get_article, etc.
    list_display = ['title', 'author', 'published']

Once configured, the agent can use the tools directly:

User: Show me the latest 10 articles
Agent: [calls list_article with limit=10]

User: Update article 42 to set published=True
Agent: [calls update_article with id=42, data={"published": true}]

Requirements

Dependency Version
Python >= 3.10
Django >= 3.2
Pydantic >= 2.0

Supported Django Versions

Django 3.2 LTS · 4.0 · 4.1 · 4.2 LTS · 5.0


License

MIT


Ready to get started? Check out the Installation Guide or jump straight to the Quick Start.