django_mcp — MCP & Application Agent API
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.
- Application agent API — optional LLM-powered endpoints for application-specific clients. No chat panel is embedded in Django Admin Overview.
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 application 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.
- Integrate an application-specific assistant using the authenticated agent endpoints, when explicitly enabled.
- Build custom tools that wrap any Django logic and expose them to both external MCP clients and application agents in one registration step.
- Serve more than one surface from one process — an operator endpoint plus a key-protected, public-tools-only one — with profiles.
- Track every tool call in
MCPAuditLog, and in a one-line-per-call access log that records argument names but never argument values.
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/ without adding an admin chat panel. 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.Application Agent APISSE streaming, session history, and the agentic loop.Redis & CachingQuery cache, per-session budget tracking, and chat history persistence.MCP CommandsRegister with Claude Code / Codex (mcp_install) and diagnose the setup (mcp_doctor).Last updated on