The Django MCP server. Even if you don't use Django.
Already on Django? One class, two lines of code, and your models become typed tools LLM agents can call โ over stdio for desktop assistants, over HTTP (JSON-RPC POST) for HTTP clients. The REST API ships at the same time, from the same source. Not on Django? Point 0-mcp init at any MySQL or Postgres database and walk away with a complete Django + 0-mcp project ten seconds later. Either way, you end up with the same battle-tested stack: async by default, Redis-native, multi-tenant aware. Zero MCP boilerplate. Zero schema drift. One source of truth.
Already have a database? Skip the model and resource boilerplate entirely:
pip install 'django-zeromcp[gen-mysql]' 0-mcp init --db mysql://user:pass@host/dbname --output ./myproject
In ~10 seconds, every table is a model, every model is an MCP tool, every tool has typed schemas. Read the full walkthrough.
Setup (once per app)
from zeromcp import BaseResource from myapp.models import Space
Your entire resource โ 2 lines
class SpaceResource(BaseResource):
model = SpaceThat's it. You now have a complete MCP server:
list_spaceโ typed input, ranked search, paginated outputget_space,create_space,update_space,delete_space- Full JSON Schema, descriptions, output shapes โ all derived from your model
stdiotransport for Claude Desktop / CursorHTTPtransport (JSON-RPC over POST) for web agents
And โ without writing a single extra line โ the same class also serves a REST API:
GET /spacesโ paginated listGET /spaces/{id}โ detailPOST /spacesโ createPATCH /spaces/{id}โ updateDELETE /spaces/{id}โ deleteGET /docsโ interactive OpenAPI UIGET /openapi.jsonโ full spec
No second codebase. No schema drift. Your agent surface and your API are the same source of truth.
Async dispatch, session and API-key auth, per-IP rate limit, scanner blocking, sanitized 500s, HMAC-SHA256 anti-replay tokens, multi-tenant DB routing โ all on by default. For both MCP and REST. You did not configure them. You did not even import them.
Need filters, search, ordering, write whitelists, cache, ownership scoping, Pydantic validation? Add one attribute at a time:
class SpaceResource(BaseResource):
model = Space
list_fields = ['id', 'name', 'description', 'active']
filter_fields = ['active', 'name']
search_fields = ['name', 'description']
create_fields = ['name', 'description']
update_fields = ['name', 'description', 'active']
cache = True
owner_field = 'owner_id'What you didn't have to write
- MCP tool registry with stdio + HTTP transports
- JSON Schema generation from Django fields and Pydantic models
- Tool descriptions, summaries and bounded output shapes
- Async list view with pagination, ordering, search, field selection
- Filter parser that accepts URL params and JSON expressions
- Field-level whitelists โ applied to both MCP tools and REST endpoints
- Session and API key authentication backed by Redis
- Per-IP rate limit + abuse blocking (auto-blocks scanners on first hit)
- Per-resource Redis cache with namespace invalidation that does not blow away unrelated rows
- Multi-tenant database routing
- Sanitized 500s in production
- OpenAPI 3.0.3 spec generation
- Two-column Scalar API reference, ready to share
None of it is wired by hand. None of it can drift. None of it is your problem anymore.
Built for agents first
Every Django app that exists today will need an agent surface tomorrow. Claude Desktop, Cursor, custom copilots, in-house automation โ they all expect typed tools with JSON Schema, descriptions and bounded outputs. Writing that by hand, alongside the API you already have, means two codebases that drift apart.
0-mcp closes the gap. The MCP server reuses the same model fields, Pydantic schemas, field whitelists, auth, rate limit and ownership scoping the REST layer uses. Same protections. Same source of truth. Turn it on and your existing Django app becomes agent-ready.
Same auth. Same rate limit. Same ownership scoping. No DSL to learn. No second codebase to keep in sync.
Built for the boring 90%
CRUD on a Django model. List with filters. Soft auth gates. Tenant DB routing. Most of what an agent needs โ and most of what your API does โ is this. Writing it from scratch, twice, is the slowest, dumbest part of the job.
0-mcp is the answer for that 90%. The remaining 10% โ the actual product โ gets all your attention.
Production-ready out of the box
| Concern | Status |
|---|---|
| MCP server (stdio + HTTP) | โ opt-in |
| MCP tool schema generation | โ default |
| Async views (Django 5+) | โ default |
| Redis-backed sessions, cache, rate limit | โ default |
| Multi-tenant DB routing | โ opt-in |
| Pydantic validation | โ opt-in |
| Scanner blocking + 4xx flood detection | โ default |
| OpenAPI 3.0.3 + Scalar UI | โ default |
| HMAC-SHA256 anti-replay token | โ opt-in |
| 165-test suite | โ green |
Who is this for
- Django teams building agents or copilots that need to read and act on app data
- Products integrating with Claude Desktop, Cursor, or any MCP client
- SaaS apps that want API + MCP from one definition, not two codebases
- Multi-tenant apps that need agent access scoped per tenant, automatically
- Teams that also want a clean REST API โ that comes free
- Solo founders shipping fast
The first MCP tool takes five minutes. The fiftieth takes five minutes too.
Project
- Author โ Stamatios Stamou Jr
- GitHub โ https://github.com/ssjunior/0-mcp
- License โ MIT
0-mcp by Stamatios Stamou Jr โ github.com/ssjunior/0-mcp