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.0.tar.gz (34.5 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.0-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_mcpz-1.0.0.tar.gz
  • Upload date:
  • Size: 34.5 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.0.tar.gz
Algorithm Hash digest
SHA256 869f517848ff2f06737aeca60772bc86e098791703d9cc0f2d39395ddf175629
MD5 d53db2321d62451991a33dbc0f335c1e
BLAKE2b-256 1d8750c03cf7ceedff04d377f13743c5fd83e609b1ba6048ca7da4b59623a6a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcpz-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: django_mcpz-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 48.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a248e62b55c209d25a640440e6904b0cecf98df7f4832d88b9c41a115e291586
MD5 982e060c1f55216feb8f27606ba94f1b
BLAKE2b-256 ebc8a8b7e5c2834ee9c0da85268b055c2f7e96028c0d0c4bce3f17439dfa9dde

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcpz-1.0.0-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

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

This release

1.0.0 This release

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