Stateless Model Context Protocol (MCP) server for Django, built on the 2026-07-28 spec.
Project description
django-stateless-mcp
A stateless Model Context Protocol server for Django, built on the 2026-07-28 spec. An MCP endpoint becomes an ordinary Django view — no sessions, no SSE, no sticky routing, and no dedicated single-process service.
- GitHub | PyPI | Documentation
- Created by Ben Atkinson | GitHub @BenA-SA
- MIT License
Why stateless
Before 2026-07-28, MCP needed a persistent connection: elicitation held an open stream and a blocked worker, so a reply that round-robined to another worker failed. The 2026-07-28 spec makes MCP plain request/response HTTP — Django's home turf — and turns elicitation into a retry any instance can serve. That is the change this package is built on; see Why stateless for the full story.
Usage
# myproject/mcp.py
from mcp.server.mcpserver import MCPServer
from django_stateless_mcp import request_state_security
server = MCPServer(
name="my-server",
version="1.0.0",
request_state_security=request_state_security(),
)
@server.tool()
def add(a: int, b: int) -> int:
"""Add two integers."""
return a + b
# urls.py
from django.urls import path
from django_stateless_mcp import mcp_view
from myproject.mcp import server
urlpatterns = [path("mcp/", mcp_view(server))]
That is the whole integration. The endpoint runs under both WSGI and ASGI.
What it provides
mcp_view(server)— serve anMCPServeras a stateless streamable-HTTP Django view, optionally requiring OAuth bearer auth via atoken_verifier.mcp.pyautodiscovery — adddjango_stateless_mcptoINSTALLED_APPSand each app'smcp.pyregisters tools, likeadmin.py.request_state_security()— key the SDK's elicitation-resume encryption fromSECRET_KEY, so elicitation survives a multi-worker deployment.django_request(ctx)— reach the authenticated Django request from inside a tool, with no global state.StructlogRequestLogger— optional flow-logging middleware.
Tool registration, elicitation, resources and prompts are the MCP SDK's own API; this package is the Django layer around it.
Supported versions
- Python 3.12–3.14
- Django 5.2 LTS and 6.0
mcp2.0.x
Each is exercised in CI, along with an advisory job tracking the SDK's git main.
Try it live
The repo ships a runnable example project. just demo-asgi starts it behind
four worker processes; the example README walks through
watching an elicitation started on one worker resume on another — the
package's thesis, observable with curl or any MCP client.
Documentation
Full documentation, including a worked elicitation example and the design decisions behind the package, is at https://django-stateless-mcp.readthedocs.io/.
Development
git clone git@github.com:Streamlined-Analytics/django-stateless-mcp.git
cd django-stateless-mcp
uv sync
uv run pytest # quick run: locked Django
uvx --with tox-uv tox run -f py313 # the full matrix: Django 5.2 + 6.0
just qa # format, lint, type check, test
just conformance # the official MCP conformance suite
Author
django-stateless-mcp was created in 2026 by Ben Atkinson.
Started from the audreyfeldroy/cookiecutter-pypackage template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_stateless_mcp-0.1.4.tar.gz.
File metadata
- Download URL: django_stateless_mcp-0.1.4.tar.gz
- Upload date:
- Size: 175.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f682911e9e8508874bbf157feb102a727efdc04f9f2cbb715641ee8351a89440
|
|
| MD5 |
2a22d6951bfc51f4a9b3da9f353b8be1
|
|
| BLAKE2b-256 |
7cdf80d0c702b2018f9772861b3eca3380c32cc1384178dfcc62ec8ec558a254
|
Provenance
The following attestation bundles were made for django_stateless_mcp-0.1.4.tar.gz:
Publisher:
publish.yml on Streamlined-Analytics/django-stateless-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_stateless_mcp-0.1.4.tar.gz -
Subject digest:
f682911e9e8508874bbf157feb102a727efdc04f9f2cbb715641ee8351a89440 - Sigstore transparency entry: 2291410730
- Sigstore integration time:
-
Permalink:
Streamlined-Analytics/django-stateless-mcp@d888ed94816a82824621be910edc0c122d8f1f6d -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/Streamlined-Analytics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d888ed94816a82824621be910edc0c122d8f1f6d -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_stateless_mcp-0.1.4-py3-none-any.whl.
File metadata
- Download URL: django_stateless_mcp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1abad8795182609d594d79fe12f62b6a70955277ee9ef5885e81a37ffbcb98a4
|
|
| MD5 |
9514ca88ce1246154e49ffc1f92b09b4
|
|
| BLAKE2b-256 |
08d4984a092a2e3ec72ae05084ccb88e8731444b6d4bc83adf0f79d28e388845
|
Provenance
The following attestation bundles were made for django_stateless_mcp-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on Streamlined-Analytics/django-stateless-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_stateless_mcp-0.1.4-py3-none-any.whl -
Subject digest:
1abad8795182609d594d79fe12f62b6a70955277ee9ef5885e81a37ffbcb98a4 - Sigstore transparency entry: 2291410761
- Sigstore integration time:
-
Permalink:
Streamlined-Analytics/django-stateless-mcp@d888ed94816a82824621be910edc0c122d8f1f6d -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/Streamlined-Analytics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d888ed94816a82824621be910edc0c122d8f1f6d -
Trigger Event:
push
-
Statement type: