integration · Django

Django MCP integration.

Your Django + DRF app already serializes models, validates input, and generates an OpenAPI schema via drf-spectacular. Here's how to point wmcp.sh at that schema and ship a Model Context Protocol server agents can call — without touching a single view.

wmcp.sh is not affiliated with the Django Software Foundation or Anthropic. Django, DRF, and drf-spectacular are open-source projects.

DRF already emits OpenAPI. You're 80% done.

What you have today

DRF viewsets and serializers in views.py, routed through a DefaultRouter, with drf-spectacular emitting an OpenAPI 3 schema at /api/schema/. Auth handled by DRF's authentication classes (Token, JWT, Session, OAuth2).

What agents need

A Model Context Protocol server exposing each viewset action as a typed tool. wmcp.sh reads /api/schema/ and emits the MCP server at https://wmcp.sh/mcp/<your-id>. Zero changes to views.py.

A DRF viewset, exposed as MCP tools.

Plain Django REST Framework; drf-spectacular emits the spec; wmcp.sh ingests it.

# views.py — Django 5 + DRF
from rest_framework import viewsets, serializers
from drf_spectacular.utils import extend_schema
from .models import Order

class OrderSerializer(serializers.ModelSerializer):
    class Meta:
        model = Order
        fields = ['id', 'sku', 'qty', 'status', 'created_at']

class OrderViewSet(viewsets.ModelViewSet):
    queryset = Order.objects.all()
    serializer_class = OrderSerializer

    @extend_schema(tags=['agent'], summary='Update order status')
    def partial_update(self, request, *args, **kwargs):
        return super().partial_update(request, *args, **kwargs)

# urls.py — drf-spectacular publishes the schema at /api/schema/
# Then: curl 'https://wmcp.sh/api/v1/tools?url=https://acme.example.com/api/schema/&tag=agent'
# Result: every tagged operation becomes an MCP tool, types inferred from your serializer.

Hand-rolled MCP server vs wmcp.sh on Django.

CapabilityHand-rolledwmcp.sh + drf-spectacular
Tool schemas synced with serializers ⚠️ Manual; drifts when serializers change ✅ drf-spectacular regenerates spec on every deploy
Authentication declared once ⚠️ Re-implement DRF auth at the MCP layer ✅ DRF's securitySchemes flow through to wmcp.sh
Pagination + filtering ⚠️ Re-export DRF filters as MCP parameters by hand ✅ Spec lists query params; wmcp.sh exposes them as tool inputs
MCP transport (Streamable HTTP) ⚠️ You build it ✅ Served at https://wmcp.sh/mcp/<your-id>
Per-tool gating ⚠️ Manual @extend_schema(tags=['agent']) + &tag=agent ingest filter
Spec drift detection ❌ Silent breakage ✅ Re-ingest in CI; type mismatches surface immediately

Common questions from Django teams.

Does this require DRF, or can plain Django views work?
Plain Django works but you'll hand-write the OpenAPI spec. DRF + drf-spectacular is the lowest-friction path because the spec generation is automatic from your serializers and viewsets.
Python version?
Python 3.12+ recommended (matches current DRF support). Django 4.2 LTS or 5.x; DRF 3.14+; drf-spectacular 0.27+.
How does authentication flow through?
Whatever DRF authentication you've declared appears as securitySchemes in drf-spectacular's output. wmcp.sh reads it and forwards the appropriate credential — bearer tokens, API keys, or full OAuth 2.1 via /mcp/<provider>.
Will Django sessions interfere?
SessionAuthentication is fine for browser users but awkward for agents. For MCP-facing endpoints, prefer TokenAuthentication, django-rest-knox, or djangorestframework-simplejwt. Keep CSRF off the agent paths; production auth gates the endpoint.
Can I expose only some endpoints?
Yes. Use @extend_schema(tags=['agent']) to mark MCP-callable operations, then pass &tag=agent when ingesting. Admin and internal endpoints stay invisible.
What about Django Ninja or DRF alternatives?
Django Ninja emits an OpenAPI spec natively — even cleaner than DRF for this use case. Point wmcp.sh at /api/openapi.json and it works identically. The "Django" name on this page covers any Django-rooted API framework that publishes OpenAPI.
Need this done for you?

Skip the wiring — we ship the OpenAPI + MCP for your Django app.

Audit your DRF viewsets, tune drf-spectacular for agent traffic, deploy MCP at mcp.yourbrand.com. Starter $499 one-time setup; Managed Retainer $999/mo for ongoing maintenance; Enterprise $4,999+/mo for SLA + private deploy.

See /managed → Submit (free)