Get the FREE Ultimate OpenClaw Setup Guide →

django

Django MCP Server is a Django extensions to easily enable AI Agents to interact with Django Apps through the Model Context Protocol it works equally well on WSGI and ASGI

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gts360-django-mcp-server python manage.py stdio_server \
  --env DJANGO_SETTINGS_MODULE="your_project.settings" \
  --env DJANGO_MCP_AUTHENTICATION_CLASSES="optional or set to your auth classes"

How to use

This Django MCP Server exposes a Model Context Protocol (MCP) surface from your Django project. By integrating django-mcp-server into your Django app, you make your models and DRF-backed endpoints available as MCP tools that AI agents and MCP clients can call. The server runs inside your Django application and serves the MCP endpoint at /mcp. Tools are declared by subclassing MCP toolsets (for example via ModelQueryToolset for model-backed queries) or by annotating DRF views to publish REST APIs as MCP tools. You can inspect declared tools with the provided manage.py mcp_inspect command and test calls via the MCP Python SDK against http://<your-host>/mcp. Claude AI and Claude Desktop can connect to this endpoint over a streamable HTTP protocol once proper OAuth2 and authentication are configured. To run locally, start the stdio server provided by django-mcp-server (as shown in the Quick Start: Run the CLI command for your environment) and ensure the server is reachable at the host/port where your Django app runs. The server supports both model-based tools (via ModelQueryToolset) and generic MCPToolset methods for arbitrary logic, including DRF-based APIs exposed as MCP tools.

How to install

Prerequisites:\n- Python 3.8+ (recommended) and a running Django project\n- pip (Python package installer)\n\nInstall the MCP server package:\nbash\npip install django-mcp-server\n\nIf you prefer installing directly from GitHub:\nbash\npip install git+https://github.com/omarbenhamid/django-mcp-server.git\n\nIntegrate into your Django project:\n1) Add the app to INSTALLED_APPS in your settings:\npython\nINSTALLED_APPS = [\n # ... your apps,\n 'mcp_server',\n]\n\n2) Include the MCP URL configuration in your project URLs (mcp endpoint defaults to /mcp):\npython\nfrom django.urls import path, include\n\nurlpatterns = [\n # your urls...\n path("", include('mcp_server.urls')),\n]\n\n3) Run the MCP server inside Django using the stdio server command (example):\nbash\npython manage.py stdio_server\n\nIf you want to run via a traditional Django runserver for development, you can also rely on your existing Django start command, but the stdio_server approach is recommended to expose an MCP-friendly stream interface.\nbash\npython manage.py runserver 0.0.0.0:8000\n

Additional notes

Tips and notes:\n- To publish DRF APIs as MCP tools, consider using the provided DRF publishing helpers (drf_publish_create_mcp_tool, drf_publish_update_mcp_tool, etc.).\n- For production usage, configure authentication via DJANGO_MCP_AUTHENTICATION_CLASSES and follow OAuth2 guidance if integrating with Claude or other OAuth-enabled clients.\n- If Tools are not visible, run python manage.py mcp_inspect to verify tool declarations.\n- Environment variables can configure Django MCP specifics, such as authentication and permission schemes.\n- The endpoint is typically available at /mcp within your Django project; ensure your server is reachable from clients you plan to use (e.g., localhost:8000 or a deployed domain).

Related MCP Servers

Sponsor this space

Reach thousands of developers