django-xprez-mcp
Provides an admin-style MCP server for Django, exposing registered providers, models, admin classes, and plain functions as MCP tools, resources, and prompts, filtered by the calling user's permissions.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
django-xprez-mcp
Admin-style MCP servers for Django. Register providers, models, admin classes and plain functions on a server; they become MCP tools, resources and prompts, filtered by the calling user's permissions.
Early development: phases 1 (core), 2 (models) and 3 (admin). See docs/design.md for the full design and roadmap.
Guides: getting started, permissions, security checklist.
# settings.py
INSTALLED_APPS = [..., "xprez_mcp", "xprez_mcp.contrib.tokens"]
XPREZ_MCP = {
"PERMISSION": "myapp.use_mcp", # required: who may use the server at all
}
# urls.py
from xprez_mcp import mcp
urlpatterns = [path("mcp/", mcp.urls)]Clients send Authorization: Bearer <key>. With xprez_mcp.contrib.tokens
users create keys under "MCP tokens" in the admin (shown once, stored hashed,
revoked by deleting). Projects with their own token model leave the app out
and set XPREZ_MCP["TOKEN_RESOLVER"] = "myapp.tokens.resolve"
((request, token) -> user | None).
# myapp/mcp.py: discovered automatically, like admin.py
from xprez_mcp import Provider, mcp, prompt, resource, tool
@mcp.register
class NotesProvider(Provider):
namespace = "notes"
@tool(read_only=True, permission="myapp.view_note")
def search(self, ctx, query: str, limit: int = 20):
"""Search notes by title."""
notes = Note.objects.filter(owner=ctx.user, title__icontains=query)
return {"notes": list(notes.values("id", "title")[:limit])}
@resource("notes://{id}", mime_type="text/markdown")
def note(self, ctx, id: int):
return Note.objects.get(owner=ctx.user, pk=id).text
@prompt
def summary(self, ctx, id: int):
"""Summarize one note."""
return f"Summarize the note notes://{id}."
@mcp.tool
def ping(ctx) -> str:
return "pong"# myapp/mcp.py: tools generated from a model
from xprez_mcp import ModelProvider, mcp
@mcp.register(Note)
class NoteProvider(ModelProvider):
fields = ["id", "title", "created"]
search_fields = ["title"]
filters = {"created_after": "created__gte"}
actions = ["list", "get", "update"] # notes_list, notes_get, notes_update
def get_queryset(self, ctx):
return Note.objects.filter(owner=ctx.user)With many models, MCPServer(exposure="generic") exposes them through a few
shared tools (models_list, records_search, record_get, ...) instead of
tools per model. A provider can choose for itself with exposure.
# the admin, with exactly the permissions each user has there
from django.contrib import admin
from xprez_mcp import AdminProvider, mcp
@mcp.register(Note)
class NoteAdminProvider(AdminProvider): # uses the registered NoteAdmin
actions = ["list", "get", "update"] # writes are opt-in
admin_actions = ["publish"] # ModelAdmin actions, opt-in
# the rest of admin.site (models registered above keep their own provider)
mcp.register_admin(admin.site, exposure="generic")Write tools from installed third-party apps are held back until listed in
XPREZ_MCP["ALLOW_WRITES"].
Development
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/python -m django test xprez_mcp.tests --settings=xprez_mcp.tests.settings
.venv/bin/black --check .Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Your DRF API as MCP tools — 1,800 endpoints become 16 dispatchers, permissioned by Django.
Toolstile is a managed MCP gateway that connects remote MCP servers behind one endpoint, with per-agent permissions, shared accounts and activity logs. Connect at https://mcp.toolstile.com/mcp over Streamable HTTP with OAuth; sign in at https://toolstile.com, select a workspace and connect your upstream servers. Available tools, resources and prompts depend on that workspace and the agent's granted access.
Related MCP Servers
- AlicenseAqualityBmaintenanceExpose Django admin models to MCP clients for CRUD, admin actions, model introspection, and more via HTTP with token authentication.37432 PyPI33MIT
- AlicenseNot gradedqualityBmaintenanceExposes Django admin's ModelAdmin as MCP tools, with identical permissions, form validation, and session authentication.58 PyPI5MIT
- AlicenseNot gradedqualityDmaintenanceTurns Django models into MCP tools and a REST API from a single class, and can generate a Django project from a MySQL or Postgres schema.2MIT
- AlicenseNot gradedqualityDmaintenanceExposes Django REST Framework APIs as MCP tools for AI agents via the Model Context Protocol, with automatic discovery and security.1MIT