django_mcp — MCP & Admin Chat Agent
django_mcp does two independent things that share a configuration model and a tool registry:
- MCP protocol server — a JSON-RPC 2.0 endpoint that lets external AI clients (Claude Desktop, Cursor, custom agents) read and query your Django application’s data.
- Admin chat agent — an LLM-powered chat interface embedded directly in the Django admin dashboard. Superusers can ask natural-language questions and get answers backed by real Django queries.
Both subsystems use the same global tool registry, so any tool you register is available in both contexts immediately.
django_mcp requires django_llm for the admin chat agent. The MCP protocol server works without it.
What you can do with it
- Connect Claude Desktop, Cursor, or any MCP-compatible client to your Django app and let it query models, run management commands, and inspect the app structure.
- Let admin users ask “How many users signed up this week?” or “Show me the 10 largest orders” directly from the admin panel — no SQL, no custom views.
- Build custom tools that wrap any Django logic and expose them to both external MCP clients and the admin chat in one registration step.
- Track every tool call in
MCPAuditLogfor compliance and debugging.
Quick start
# api/config.py
from django_cfg import DjangoConfig
from django_cfg.modules.django_mcp.__cfg__ import DjangoMCPModuleConfig
class MyConfig(DjangoConfig):
mcp = DjangoMCPModuleConfig(
enabled=True,
access_key="your-secret-key",
)That’s enough to start the MCP server at POST /cfg/mcp/ and enable the admin chat. Add exposed_apps to let agents query your models.
ArchitectureHow the two subsystems are designed and how they share tools.ConfigurationFull reference for
DjangoMCPModuleConfig and all nested config models.MCP ToolsBuilt-in tools, custom tool creation, and the tool registry.Admin Chat AgentSSE streaming, session history, and the agentic loop.Redis & CachingQuery cache, per-session budget tracking, and chat history persistence.Last updated on