Django Admin MCP

io.github.7tg由 GitHub 账号 7tg 发布v0.11.1更新于 Oct 24, 2026

基于MCP的Django admin模型:CRUD、操作、历史记录、自动补全——受Django权限限制。

AI 翻译由 AI 模型根据下方的原文描述翻译,可能有误。

原文描述

Django admin models over MCP: CRUD, actions, history, autocomplete — capped by Django permissions.

已验证STDIO仅桌面数据库开发者工具

概览

Django Admin 的本地 MCP 服务;无需登录;STDIO。

暂无 AI 概览:以下信息来自注册中心条目和服务本身。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Django Admin MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

django-admin-mcp

[PyPI version] [PyPI downloads] [Python versions] [Django] [Tests] [codecov] [Documentation] [License] [MCP Registry] [Glama MCP server]

Add a mixin to your ModelAdmin and MCP clients get CRUD, admin actions and relationship traversal, inside Django's existing permissions. Only Django and Pydantic as dependencies.

[Meet django-admin-mcp: one mixin turns a ModelAdmin into MCP tools, every call goes through the admin's permissions, validation and audit log, one token per user, a conversation with the agent, and how to get started]

One mixin, the request's path through the admin, a token, a conversation with the agent, then getting started. 50 seconds · 1080p · 60 fps · original soundtrack. Watch the film.

Why not just give the agent database access?

A database connection hands the agent raw tables. The Django admin is where your project already encodes who may touch what, how records are validated, and what the sanctioned bulk operations are. This package puts the agent behind that layer instead of around it:

  • Permissions — every call goes through ModelAdmin.has_*_permission(). A token can only do what its linked user can do, and starts with no access until you grant it.
  • Validation — writes run full_clean() and your save_model() / save_related() hooks, so the agent cannot save a record the admin form would reject.
  • Audit history — every create, update, delete and action is written to Django's LogEntry under the token's user. You can see what the agent changed, and the agent can read the history too.
  • Admin actions — "publish", "refund", "export CSV" and your other registered actions become tools, including two-step confirmation flows. The agent uses the operations you designed rather than inventing SQL.
  • Scoped exposure — mcp_fields / mcp_exclude_fields keep password hashes and secrets out of the agent's view; get_queryset() still limits which rows it can see.

How it compares

A generic Django MCP server or a hand-rolled FastMCP wrapper asks you to define tools, schemas and permission checks yourself, one function at a time. This package reads the ModelAdmin classes you already maintain and generates the tools from them, so field choices, querysets, validation, actions and permissions stay in one place and the agent inherits every change you make to the admin. It also ships as a plain Django app with no MCP SDK or extra HTTP stack.

Installation

bash
pip install django-admin-mcp
python
# settings.pyINSTALLED_APPS = [    'django_admin_mcp',    # ...]
# urls.pyurlpatterns = [    path('mcp/', include('django_admin_mcp.urls')),    # ...]
bash
python manage.py migrate django_admin_mcp

Quick start

1. Expose a model. Set mcp_expose = True to generate tools for it. Models with the mixin but without the flag are discoverable through find_models only.

python
from django.contrib import adminfrom django_admin_mcp import MCPAdminMixinfrom .models import Article, Author
@admin.register(Article)class ArticleAdmin(MCPAdminMixin, admin.ModelAdmin):    mcp_expose = True                    # list_article, get_article, create_article, ...    mcp_exclude_fields = ['internal_notes']    list_display = ['title', 'author', 'published']
@admin.register(Author)class AuthorAdmin(MCPAdminMixin, admin.ModelAdmin):    pass                                 # discoverable, no direct tools

2. Create a token in the admin at /admin/django_admin_mcp/mcptoken/. Grant it exactly the permissions and groups the agent needs. The linked user caps what the token can do and is the identity its changes are logged under.

3. Point your MCP client at it, for example in a .mcp.json for Claude Code:

json
{  "mcpServers": {    "django-admin": {      "type": "http",      "url": "http://localhost:8000/mcp/",      "headers": { "Authorization": "Bearer YOUR_TOKEN" }    }  }}

4. Ask the agent.

User: Show me the latest 10 articlesAgent: [calls list_article with limit=10]
User: Mark articles 1, 2 and 3 as publishedAgent: [calls action_article with action="mark_as_published", ids=[1, 2, 3]]
User: What changed on article 42?Agent: [calls history_article with id=42]

Tools

For each exposed model (here Article) the server generates:

ToolDoes
list_article, get_articleRead with pagination and filtering (needs view)
create_article, update_article, delete_articleWrite single records (needs add / change / delete)
bulk_articleCreate, update or delete many records at once
actions_article, action_articleList and run registered admin actions, including file-returning exports
describe_articleField definitions, types and constraints
related_articleFollow foreign keys and reverse relations
history_articleDjango admin change history
autocomplete_articleSearch suggestions for foreign-key fields

Plus find_models to discover everything exposed, MCP prompts for common workflows, and read-only resources at models:// and data:// URIs. The endpoint speaks JSON-RPC 2.0 over HTTP with GET /mcp/health/ for health checks. Full reference in the docs.

Security in brief

  • Tokens look like mcp_<key>.<secret>; only a salted hash of the secret is stored.
  • Each token carries its own permissions and groups, intersected with its user's permissions. Deactivating the user disables its tokens.
  • Expiry is configurable; revoke a token by deactivating or deleting it in the admin.
  • Sensitive values are redacted from log messages, and large action downloads are capped by MCP_ACTION_MAX_FILE_BYTES (default 5 MiB).

See Permissions and Token Management for details.

Requirements

Python 3.10 to 3.14, Django 3.2 to 6.0, Pydantic 2. Tested against every Django release in that range.

Support the project

If this saved you time, a star on GitHub helps others find it. Issues and PRs are welcome; see the contributing guide.

[Star History Chart]

[PyPI Download History]

License

MIT

来源:README.md,提交 2f8e09a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

8
  1. v0.11.1最新Oct 20, 2026
  2. v0.11.0Oct 16, 2026
  3. v0.10.1Oct 9, 2026
  4. v0.10.0Oct 5, 2026
  5. v0.9.0Oct 4, 2026
  6. v0.8.1Sep 29, 2026
  7. v0.8.0Sep 17, 2026
  8. v0.7.2Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分