Skip to main content

django-mcpz

https://img.shields.io/readthedocs/django-mcpz?style=for-the-badge https://img.shields.io/github/actions/workflow/status/adamchainz/django-mcpz/main.yml.svg?branch=main&style=for-the-badge https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge https://img.shields.io/pypi/v/django-mcpz.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit

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

django_mcpz-1.0.3.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mcpz-1.0.3-py3-none-any.whl (49.1 kB view details)

Uploaded Python 3

File details

Details for the file django_mcpz-1.0.3.tar.gz.

File metadata

  • Download URL: django_mcpz-1.0.3.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for django_mcpz-1.0.3.tar.gz
Algorithm Hash digest
SHA256 6a373430c73e055dd726f26d2992fad524f252ebc51b640f89ac82691e22cac6
MD5 050c5468856a4e9795f577a66d7efd52
BLAKE2b-256 8e00baf424b80e2ac4565103b568c1ce1d6afdd6ff7cc64dfed9a26b09b83be3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcpz-1.0.3.tar.gz:

Publisher: main.yml on adamchainz/django-mcpz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_mcpz-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: django_mcpz-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 49.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for django_mcpz-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e3f8ab6eeca8f17370ee24128d203410ffc8442a9932b3a14c5c0421a37c4442
MD5 3393dd0cd0328f432660cd1e76cf5bce
BLAKE2b-256 12d77715447b69bab02563a5f19bab14f02eaa901ba9093c93e7bdf27e962841

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcpz-1.0.3-py3-none-any.whl:

Publisher: main.yml on adamchainz/django-mcpz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page