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.1.tar.gz (35.0 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.1-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

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

Hashes for django_mcpz-1.0.1.tar.gz
Algorithm Hash digest
SHA256 155ac888c715dc614cb1e5a9c3f8b0bf70d49a3eee797f7fbb33597287c76cd8
MD5 aac5b4dc56741f380d162e9687e36fb0
BLAKE2b-256 0977af17a26b22135ce3fa90016eb6f79413462ae37d4a20deea4b5fa99c4db7

See more details on using hashes here.

Provenance

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

Hashes for django_mcpz-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26cb564526cac47f5e5774f36a4bf545f0ca667e385f90d194c1f1c5b4060766
MD5 7b356e23be1a7e698850cdfd718845f4
BLAKE2b-256 97df63b287feb3834c174d56c93d4b2b97ef60d7552de1680b5116c286602953

See more details on using hashes here.

Provenance

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

This release

1.0.1 This release

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