Django MCP server: code graph for AI agents
TL;DR. Which views, admin registrations, and signal receivers depend on a modified Django model? trace-mcp indexes your existing Django repository into a local static code graph. AI coding agents query URL patterns, CBV/FBV definitions, model relationships, and @receiver signal bindings directly through MCP instead of running broad text searches across apps.
What trace-mcp extracts in Django
The django plugin indexes Django 2.x through 5.x applications:
- Models & Relationships: Subclasses of
models.Model,ForeignKey,ManyToManyField, andOneToOneFieldmapping model associations across apps. - URL Routing & Patterns: Root
urlpatterns,path(),re_path(),include()modules, and Django REST Framework routers. - Views (CBV & FBV): Class-based views (
ListView,DetailView,CreateView,ViewSet) and function-based views, extracting model and template bindings (django_view_uses_model,django_view_template). - Signal Graph:
@receiverdecorators andsignal.connect()calls, mapping sender models to receiver callbacks (django_signal_receiver). - Admin Registrations:
@admin.register()andadmin.site.register()mappings (django_admin_registers). - Forms & ModelForms: Form field extraction and
Meta.modelbindings (django_form_meta_model).
Installation & Quickstart
Install trace-mcp globally, run initialization, and connect your Django repository:
npm i -g trace-mcp && trace init && trace add
Example question to your agent
“Which views, admin classes, and signal receivers depend on the
Invoicemodel in this Django repository?”
The AI agent invokes trace-mcp tools to query relationships, signals, and view bindings directly without searching hundreds of Python files.
Without graph vs with trace-mcp
Measurements below reflect corpus-level benchmarks from our PR review context benchmark across 60 pull requests.
| Capability | Without graph | With trace-mcp |
|---|---|---|
| Median input tokens | ~13595 tokens | ~3291 tokens (-72.7%) |
| Signal listener discovery | Hidden in disconnected files | Explicit django_signal_receiver edges |
| Model relationships | Search foreign keys with grep | Explicit model relation graph edges |
| URL pattern nesting | Traverses nested include() manually |
Flattened URL route-to-view graph |
| Admin & Form binding | Must read admin.py and forms.py | Direct edges from model to admin/forms |
| Tools exposed | None (reads full files) | 182 specialized MCP tools |
Frequently asked questions
How does trace-mcp index Django signals across apps?
trace-mcp parses @receiver decorators and signal.connect() calls, creating explicit graph edges that connect signal senders to receiver functions even when defined in separate apps.
Does trace-mcp support Django REST Framework (DRF)?
Yes. It indexes DRF DefaultRouter and SimpleRouter registrations, linking registered routes to ViewSet classes, and connects views to explicit model or queryset definitions.
Does trace-mcp connect Django admin registrations to models?
Yes. It indexes @admin.register() decorators and admin.site.register() calls, building django_admin_registers edges between ModelAdmin classes and models.
Next steps
Explore the full Tools reference for available query tools, see the Language capability matrix for Python AST details, view Comparisons against other tools, or browse all Supported frameworks.
Catalogue: Articles / frameworks
Last updated: October 20, 2026