Django DRF MCP Server

Django DRF MCP Server

Enables natural language interaction with Django REST Framework APIs by auto-discovering ViewSets and providing CRUD tools, requiring minimal setup.

Category
Visit Server

README

Django REST Framework + MCP Integration

A simple Django REST Framework application with integrated Model Context Protocol (MCP) server.

Overview

This project demonstrates the simplest way to add MCP (Model Context Protocol) support to any Django REST Framework project. Just copy one file (mcp_view.py) and add one URL pattern - that's it!

Features

  • Django REST Framework API - Complete CRUD operations for User management
  • Simple MCP Integration - Single file MCP view with auto-discovery
  • Zero Dependencies - Only uses Django, DRF, and Python standard library
  • Auto-discovery - Automatically finds DRF ViewSets and creates MCP tools

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Setup Database

python manage.py migrate

3. Start the Server

python manage.py runserver

The server provides:

  • REST API: http://localhost:8000/api/users/
  • MCP Endpoint: http://localhost:8000/mcp/
  • Admin: http://localhost:8000/admin/

Adding MCP to Your Django Project

Want to add MCP support to your existing Django DRF project? It's incredibly simple:

1. Copy the MCP View

Copy django_mcp_project/mcp_view.py to your Django project.

2. Add URL Pattern

In your urls.py:

from your_project.mcp_view import MCPView

urlpatterns = [
    # your existing patterns...
    path("mcp/", MCPView.as_view(), name="mcp"),
]

3. That's it!

Your Django project now has MCP support. The view automatically discovers all your DRF ViewSets and creates MCP tools for them.

Testing MCP Integration

Test that your MCP endpoint is working:

curl -X POST http://127.0.0.1:8000/mcp/ \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}'

API Endpoints

User Management

  • GET/POST /api/users/ - List all users / Create new user
  • GET/PUT/PATCH/DELETE /api/users/{id}/ - User detail operations
  • POST /api/users/{id}/activate/ - Activate user
  • POST /api/users/{id}/deactivate/ - Deactivate user

MCP Integration

  • POST /mcp/ - MCP JSON-RPC endpoint with auto-discovered tools

Project Structure

django-drf-mcp/
├── django_mcp_project/
│   ├── mcp_view.py          # 🌟 The magic file - copy this to any DRF project
│   ├── settings.py          # Django settings
│   ├── urls.py              # URL configuration with MCP endpoint
│   └── wsgi.py              # WSGI configuration
├── users/                   # Example Django app with User model
│   ├── models.py            # Extended User model
│   ├── serializers.py       # DRF serializers
│   ├── views.py             # DRF ViewSets
│   └── urls.py              # User API endpoints
├── manage.py                # Django management script
├── requirements.txt         # Dependencies
└── .vscode/                 # VS Code MCP client configuration

How It Works

The MCPView class in mcp_view.py:

  1. Auto-discovers all Django apps and their ViewSets
  2. Creates MCP tools for each CRUD operation (list, create, retrieve, update, destroy)
  3. Provides JSON-RPC interface compatible with MCP clients
  4. Requires zero configuration - just works out of the box

VS Code Integration

Add to your .vscode/mcp.json:

{
  "servers": {
    "django-mcp": {
      "type": "http",
      "url": "http://127.0.0.1:8000/mcp/"
    }
  }
}

License

MIT License - feel free to use this in your projects!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured