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.2.tar.gz (35.1 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.2-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_mcpz-1.0.2.tar.gz
  • Upload date:
  • Size: 35.1 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.2.tar.gz
Algorithm Hash digest
SHA256 e35c094959a52292685f24361b060b11def6377d00998e703be4abfdd2b56342
MD5 cf9e268ba86aa34027881de8818ef15d
BLAKE2b-256 7cac577d0e9ea7934f6eee2615fa09be29039f569061f3c66ebeb44807b0863b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: django_mcpz-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 49.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa0b55af0ede86f2d3ac068e0bb94127a022195855140c2fee42dd0ab7a60782
MD5 d7e853a8baf5b738afd9bcd294927eff
BLAKE2b-256 e535d5488df75bfb106c3f2ea3f867965b96f4ef5d62bea5bce155eeb9fa95ec

See more details on using hashes here.

Provenance

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

This release

1.0.2 This release

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