Django MCP
An implementation of the Model Context Protocol for Django that enables AI agents to interact with applications by exposing models, logic, and REST Framework APIs as tools.
What is Django MCP?
Django MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to implementation of the model context protocol for django that enables ai agents to interact with applications by exposing models, logic, and rest framework apis as tools.
An implementation of the Model Context Protocol for Django that enables AI agents to interact with applications by exposing models, logic, and REST Framework APIs as tools.
This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- An implementation of the Model Context Protocol for Django t
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx django-mcp-serverConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Django MCP
Django MCP Server is a Django extension that implements the Model Context Protocol inside any existing Django application, enabling AI agents to interact with your models, business logic, and REST Framework APIs as structured MCP tools. It works on both WSGI and ASGI infrastructure without requiring architectural changes, and integrates with clients like Claude AI and Google Agent Development Kit. Developers define tools by subclassing ModelQueryToolset or MCPToolset in a standard mcp.py file, and the library automatically exposes them at a configurable HTTP endpoint.
Prerequisites
- Python 3.8 or later with an existing Django project
- Django installed (3.2+ recommended)
- Django REST Framework installed if you want to expose DRF APIs as MCP tools
- An MCP-compatible client such as Claude Desktop, Claude Code, or Google ADK
Install django-mcp-server
Install the package from PyPI into your Django project's virtual environment.
pip install django-mcp-serverAdd to INSTALLED_APPS
Add mcp_server to the INSTALLED_APPS list in your Django settings.py file.
INSTALLED_APPS = [
# ... existing apps ...
'mcp_server',
]Include the MCP URL endpoint
Add the MCP server URL routes to your project's urls.py. By default the endpoint is served at /mcp unless you configure DJANGO_MCP_ENDPOINT in settings.
from django.urls import path, include
urlpatterns = [
# ... existing urls ...
path("", include('mcp_server.urls')),
]Define your MCP tools in mcp.py
Create an mcp.py file in your Django app directory. Use ModelQueryToolset to expose a Django model as a queryable tool, or MCPToolset to publish arbitrary Python methods.
from mcp_server import ModelQueryToolset, MCPToolset
from .models import Product
class ProductQueryTool(ModelQueryToolset):
model = Product
class MyTools(MCPToolset):
def calculate_discount(self, price: float, pct: float) -> float:
"""Calculate discounted price"""
return price * (1 - pct / 100)Configure optional settings
Set optional Django settings to customize authentication, the server name, stateless mode, and output rendering. These all have sensible defaults.
# settings.py
DJANGO_MCP_GLOBAL_SERVER_CONFIG = {
'name': 'My App MCP Server',
'stateless': False,
}
DJANGO_MCP_AUTHENTICATION_CLASSES = [
'rest_framework.authentication.TokenAuthentication',
]
DJANGO_MCP_ENDPOINT = 'mcp'Test the MCP endpoint
Start your Django development server and connect an MCP client to http://localhost:8000/mcp to verify the tools are exposed correctly.
python manage.py runserverDjango MCP Examples
Client configuration
Connect Claude Desktop to a running Django MCP server. The server must be running and reachable at the configured URL before the client connects.
{
"mcpServers": {
"django-app": {
"url": "http://localhost:8000/mcp",
"transport": "streamable-http"
}
}
}Prompts to try
Example prompts to use once an AI agent is connected to your Django MCP server.
- "List all products in the database with price greater than $50"
- "Find the top 10 users who signed up this month"
- "Calculate the discounted price for a $120 item at 15% off"
- "Query orders with status pending and show their totals"
- "What tools are available on this server?"Troubleshooting Django MCP
MCP endpoint returns 404
Verify that mcp_server is in INSTALLED_APPS and that `path("", include('mcp_server.urls'))` is included in urls.py. Run `python manage.py show_urls` (if django-extensions is installed) to confirm the /mcp route is registered.
AI agent cannot see my tools defined in mcp.py
Ensure the mcp.py file is inside a Django app that is listed in INSTALLED_APPS. Django MCP Server auto-discovers toolsets by scanning installed apps for an mcp.py module at startup.
Authentication errors when connecting from a remote MCP client
Configure DJANGO_MCP_AUTHENTICATION_CLASSES to match your project's auth scheme (e.g. TokenAuthentication). For local development, you can temporarily set an empty list to disable auth, but never do this in production.
Frequently Asked Questions about Django MCP
What is Django MCP?
Django MCP is a Model Context Protocol (MCP) server that implementation of the model context protocol for django that enables ai agents to interact with applications by exposing models, logic, and rest framework apis as tools. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Django MCP?
Follow the installation instructions on the Django MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Django MCP?
Django MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Django MCP free to use?
Yes, Django MCP is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
Django MCP Alternatives — Similar Coding Agents Servers
Looking for alternatives to Django MCP? Here are other popular coding agents servers you can use with Claude, Cursor, and VS Code.
Dify
★ 142.2kProduction-ready platform for agentic workflow development.
Ruflo
★ 54.0k🌊 The leading agent orchestration platform for Claude. Deploy intelligent multi-agent swarms, coordinate autonomous workflows, and build conversational AI systems. Features enterprise-grade architecture, self-learning swarm intelligence, RAG integrat
Goose
★ 45.7kan open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
Antigravity Awesome Skills
★ 38.3kInstallable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.
AgentScope
★ 25.5kBuild and run agents you can see, understand and trust.
Serena
★ 24.5kA coding agent toolkit that provides IDE-like semantic code retrieval and editing tools, enabling LLMs to efficiently navigate and modify codebases using symbol-level operations instead of basic file reading and string replacements.
Browse More Coding Agents MCP Servers
Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Django MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Django MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.