Registry / web-framework / django-mcp-server

django-mcp-server

JSON →
library0.5.7pypypiunverified

Django MCP Server is a Django extension that enables AI Agents to interact with Django Apps through the Model Context Protocol (MCP). It works on both WSGI and ASGI, providing a simple way to expose Django models and views as tools for AI agents. Current version 0.5.7, release cadence is irregular as the library is still in early development.

pip install django-mcp-server
INSTALL
IMPORT
SIG · DJANGO-MCP-SERVER
D
django-mcp-server
web-frameworkpythonv0.5.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MCPServer
from mcp_server import MCPServer
from django_mcp_server import MCPServer

Create an MCP endpoint at /mcp/ exposing Django ORM tools.

# In your Django app's models.py or mcp.py from django_mcp_server import MCPServer from django_mcp_server.decorators import tools mcp_server = MCPServer() @tools.register def get_product_count(request) -> int: """Return the number of products in the database.""" from myapp.models import Product return Product.objects.count() # In urls.py from django.urls import path from . import mcp urlpatterns = [ path('mcp/', mcp.mcp_server.urls), ] # Then run with ASGI (uvicorn) or WSGI # uvicorn myproject.asgi:application --reload
Debug
Known issues
breakingIn version 0.5.x, the MCPServer class moved from django_mcp_server.server to django_mcp_server directly. If you import from the old path, it will break.
fix
Change imports to 'from django_mcp_server import MCPServer'
affects: >=0.5.0
deprecatedThe @tools.register decorator signature changed in v0.5.4: the 'name' parameter is deprecated. Use the function name directly.
fix
Remove name argument; if you need a custom name, use the @mcp_tool decorator instead
affects: >=0.5.4
gotchaWhen using the @tools.register decorator, the first argument must be a request object (HttpRequest), not a plain dictionary. Many users mistakenly pass a dict from an external API call.
fix
Ensure the tool function signature is 'def my_tool(request, ...)'
affects: >=0.1.0
gotchaThe MCP endpoint expects POST requests with Content-Type application/json. Some users try to access the endpoint via GET, resulting in a 405 Method Not Allowed error.
fix
Use a tool like curl with -X POST -H 'Content-Type: application/json'
affects: all
Upgrade
Version history
0.5.7latest on PyPI · released Oct 10, 2025
Audit
Dependencies
djangorequiredRequired, Django >=3.2
pydanticrequiredUsed for data validation in MCP schema
uvicornoptionalOptional, required for ASGI mode
Agent activity
29 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
django-mcp-server — pip install django-mcp-server · libregistry