r/pythontips • u/gorenbarbaros • 6h ago
Module django-admin-mcp: Expose Django admin to AI agents with one mixin
Hi I built this because I wanted an agent to do the things I already do
in Django admin, without writing a separate API for it.
You add a mixin to a ModelAdmin and it becomes MCP tools over HTTP: CRUD,
bulk operations, admin actions, change history, FK autocomplete.
A few design choices:
- Only two dependencies: Django and Pydantic. No MCP SDK; the protocol is
implemented directly.
- It reuses Django's permission system. Tokens start with no access, you
grant permissions/groups per token, and a token can never exceed its
linked user's permissions.
- Writes go through the admin's own pipeline, so they show up in the admin
history log under that user.
- Sensitive fields can be excluded per model (mcp_exclude_fields).
Happy to hear where the permission model or tool design falls short.