django-mcpz
Easy peasy MCP servers in Django.
django-mcpz lets you build a Model Context Protocol (MCP) server in your Django project. Create an MCP server object with metadata, give it a URL, and attach Python functions to it as tools. The MCP server acts like a regular synchronous Django view, handling the intricacies of the MCP protocol. django-mcpz leans on msgspec for defining schemas and fast JSON serialization and deserialization.
A quick example:
from typing import Literal
import msgspec
from django_mcpz.server import MCPServer
from django_mcpz.bearer_tokens.auth import token_auth
from example.models import Order
server = MCPServer(
name="shop",
version="1.0.0",
instructions="Query the shop’s order database.",
auth=token_auth,
)
class CountOrdersParams(msgspec.Struct):
status: Literal["pending", "shipped", "cancelled"] | None = None
class CountOrdersResult(msgspec.Struct):
count: int
@server.tool(
description="Count Order rows, optionally filtered by status.",
read_only=True,
)
def count_orders(request, params: CountOrdersParams) -> CountOrdersResult:
qs = Order.objects.all()
if params.status is not None:
qs = qs.filter(status=params.status)
return CountOrdersResult(count=qs.count())
Documentation
Please see https://django-mcpz.readthedocs.io/.
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_mcpz-1.0.1.tar.gz.
File metadata
- Download URL: django_mcpz-1.0.1.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
155ac888c715dc614cb1e5a9c3f8b0bf70d49a3eee797f7fbb33597287c76cd8
|
|
| MD5 |
aac5b4dc56741f380d162e9687e36fb0
|
|
| BLAKE2b-256 |
0977af17a26b22135ce3fa90016eb6f79413462ae37d4a20deea4b5fa99c4db7
|
Provenance
The following attestation bundles were made for django_mcpz-1.0.1.tar.gz:
Publisher:
main.yml on adamchainz/django-mcpz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_mcpz-1.0.1.tar.gz -
Subject digest:
155ac888c715dc614cb1e5a9c3f8b0bf70d49a3eee797f7fbb33597287c76cd8 - Sigstore transparency entry: 2851317412
- Sigstore integration time:
-
Permalink:
adamchainz/django-mcpz@65816015dd7c5c699d6df5bf96c041bc3e4827d2 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/adamchainz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@65816015dd7c5c699d6df5bf96c041bc3e4827d2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_mcpz-1.0.1-py3-none-any.whl.
File metadata
- Download URL: django_mcpz-1.0.1-py3-none-any.whl
- Upload date:
- Size: 48.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26cb564526cac47f5e5774f36a4bf545f0ca667e385f90d194c1f1c5b4060766
|
|
| MD5 |
7b356e23be1a7e698850cdfd718845f4
|
|
| BLAKE2b-256 |
97df63b287feb3834c174d56c93d4b2b97ef60d7552de1680b5116c286602953
|
Provenance
The following attestation bundles were made for django_mcpz-1.0.1-py3-none-any.whl:
Publisher:
main.yml on adamchainz/django-mcpz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_mcpz-1.0.1-py3-none-any.whl -
Subject digest:
26cb564526cac47f5e5774f36a4bf545f0ca667e385f90d194c1f1c5b4060766 - Sigstore transparency entry: 2851317491
- Sigstore integration time:
-
Permalink:
adamchainz/django-mcpz@65816015dd7c5c699d6df5bf96c041bc3e4827d2 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/adamchainz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@65816015dd7c5c699d6df5bf96c041bc3e4827d2 -
Trigger Event:
push
-
Statement type: