django-rest-framework-mcp: Expose your Django APIs to AI agents like Claude with a few lines of code

I wanted Claude to interact directly with my Django app data, so I built a library that exposes Django REST Framework APIs as callable MCP tools with just a few lines of code.

  @mcp_viewset() # <-- Just add this decorator to any ViewSet!
  class CustomerViewSet(ModelViewSet):
    queryset = Customer.objects.all()
    serializer_class = CustomerSerializer

I’ve been using Claude Desktop to do admin tasks and it’s supercharged my workflows:

  • “Deactivate Josh Mason’s account” → tools/call deactivate_user
  • “Extend Jack Wallaby’s free trial by 1 week” → tools/call update_plans
  • “How many new users joined week-over-week the past 3 months” → tools/call list_users → LLM synthesizes the returned data into chart!

It automatically generates tool schemas from your Django serializers and works with any existing auth/permissions (or you can set up MCP-specific rules).

It’s still in alpha (v0.1.0a3), but definitely stable enough for real use. There’s a demo Blog Django app set up in the repo to showcase, but I’d really love more feedback from folks trying it with real Django apps.

Let me know your thoughts / questions!

GitHub: https://github.com/zacharypodbela/djangorestframework-mcp
PyPI: pip install django-rest-framework-mcp

1 Like