Django MCP

v1.0.0Coding Agentsstable

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.

agentic-aiaidjangomodelcontextprotocol
Share:
334
Stars
0
Downloads
0
Weekly
0/5

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

Expose Django models to AI
REST API integration with agents
Application logic automation
gts360

Maintainer

LicenseMIT License
Languagepython
Versionv1.0.0
UpdatedMay 17, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx django-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

Install django-mcp-server

Install the package from PyPI into your Django project's virtual environment.

pip install django-mcp-server
2

Add to INSTALLED_APPS

Add mcp_server to the INSTALLED_APPS list in your Django settings.py file.

INSTALLED_APPS = [
    # ... existing apps ...
    'mcp_server',
]
3

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')),
]
4

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)
5

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'
6

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 runserver

Django 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.

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.

Quick Config Preview

{ "mcpServers": { "django-mcp-server": { "command": "npx", "args": ["-y", "django-mcp-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides