Skip to main content

Zibanu Django MCP — zibanu.django.mcp

Optional Zibanu Django package that exposes a Model Context Protocol (MCP) server for any other installed Zibanu Django package to extend, plus a transport selectable from Django settings.

Read this in other languages: Español.


Table of Contents

  1. Overview
  2. Installation
  3. Quick Start
  4. Features
  5. Usage
  6. Transports
  7. API Reference
  8. Configuration
  9. Testing
  10. Requirements
  11. License

Overview

zibanu.django.mcp is an optional package of the Zibanu Django framework. Besides the exposure/integration layer, it defines one database model, McpApiKeyScope (table zb_mcp_api_key_scope), which stores the tools each zibanu.django.auth API key may call. Its job is to:

  • Provide BaseMcpTool (built with McpToolMetaClass), an abstract base class any other Zibanu Django package subclasses to declare an MCP tool: a Meta with name, description, input_schema (JSON-Schema) and, optionally, permission_required, plus an execute method.
  • Provide McpToolRegistry (and its shared mcp_registry instance), a process-wide registry that lets a package "extend inward" into zibanu.django.mcp without the latter ever importing it back. A package registers its tools from its own AppConfig.init_app(), guarded by apps.is_installed("zibanu.django.mcp").
  • Resolve a configurable transport through get_transport(), selected by the ZB_MCP_TRANSPORT setting: "simple" (default), a JSON-RPC-like contract over this project's own DRF ViewSet, with no extra dependency; or "sdk", backed by the official Anthropic mcp package (installed as the zibanu.django.mcp[sdk] extra), speaking the real MCP wire protocol through POST /mcp/ (see Transports). McpViewSet never imports a concrete transport directly.
  • Expose McpViewSet + urls.py, serving POST mcp/tools/list/ and POST mcp/tools/call/, delegating entirely to the transport resolved by get_transport(). With ZB_MCP_TRANSPORT = "sdk", urls.py also registers McpEndpointView (POST mcp/, the real MCP endpoint); the two REST routes stay active in both modes.

This package connects no model signals: McpAppConfig.signals_factory is left as the no-op inherited from ZbAppConfig.

Package version: see __version__ and __build__ in zibanu/django/mcp/__init__.py.


Installation

1. Install the package

Install it using its installer from the project's installers/ directory:

pip install ./installers/zibanu-django-mcp/

To use the official MCP SDK transport (ZB_MCP_TRANSPORT = "sdk"), install the sdk extra instead:

pip install "./installers/zibanu-django-mcp/[sdk]"

2. Add it to INSTALLED_APPS

INSTALLED_APPS = [
    # ... existing apps ...
    "zibanu.django.mcp",
]

The app registers under the label zb_mcp.

3. Mount its URLs

# mainApp/urls.py
urlpatterns = [
    # ... existing patterns ...
    path(r"mcp/", include("zibanu.django.mcp.urls")),
]

4. Migrations

The package ships its own migrations/ (the McpApiKeyScope table). It requires zibanu-django-auth>=3.2.0 (the ApiKey model that scopes point to). After adding it to INSTALLED_APPS, run:

python manage.py migrate

After migrating, the ApiKey admin shows the McpApiKeyScope inline.

5. Audit the scopes (optional, administrator configuration)

This package contains no code that writes audit records for McpApiKeyScope changes. To audit them, enable zibanu.django.logging auditing from the Django admin: create an AuditEntity row (admin: Audit entities) with model_name = "zb_mcp.McpApiKeyScope" and the events to record (on_create, on_update, on_delete), enabled = True. Equivalent from a shell:

from zibanu.django.logging.models import AuditEntity

AuditEntity.objects.create(model_name="zb_mcp.McpApiKeyScope", on_create=True,
                           on_update=True, on_delete=True, enabled=True)

Every change to a scope is then recorded by zb_logging as a Log row.


Quick Start

  1. Nothing to configure for the default transport: ZB_MCP_TRANSPORT defaults to "simple", a DRF-based contract with no extra dependency.

  2. Contribute a tool from another installed package (see Usage for the full pattern):

    from zibanu.django.mcp.lib.classes import BaseMcpTool
    
    class FileSearchMcpTool(BaseMcpTool):
        class Meta:
            name = "repository_search_files"
            description = "Search files stored in the repository by name or category."
            input_schema = {
                "type": "object",
                "properties": {"query": {"type": "string"}},
                "required": ["query"],
            }
            permission_required = "zb_repository.view_file"
    
        def execute(self, request, **kwargs):
            return {"files": [...]}
    
  3. Call the endpoints:

    curl -X POST https://host/mcp/tools/list/ -H "Authorization: Api-Key <key>"
    curl -X POST https://host/mcp/tools/call/ -H "Authorization: Api-Key <key>" \
         -H "Content-Type: application/json" \
         -d '{"name": "repository_search_files", "arguments": {"query": "invoice"}}'
    

    Only zibanu.django.auth API keys authenticate (Authorization: Api-Key <key>); a JWT or Token credential is answered 401. A key sees and may call only the tools listed in its McpApiKeyScope rows (no rows, no tools). This package ships no tool of its own (see Tool names and permissions).


Features

  • Declarative tool contract — BaseMcpTool, built with McpToolMetaClass, validates every subclass's Meta (name/description required, input_schema defaulting to an empty JSON-Schema object, permission_required defaulting to None) and exposes it as _meta.
  • Process-wide tool registry — McpToolRegistry/mcp_registry lets any installed Zibanu Django package register its own tools, typically from its AppConfig.init_app(), without zibanu.django.mcp ever importing that package back.
  • Configurable transport — ZB_MCP_TRANSPORT selects "simple" (DRF-based, no extra dependency) or "sdk" (official mcp package), both resolved and cached by get_transport().
  • Lazy import and fail-fast validation of the official SDK — SdkMcpTransport imports mcp only inside its own __init__, called from McpAppConfig.init_app() on the after_ready background thread, so a misconfigured ZB_MCP_TRANSPORT = "sdk" (missing SDK, or older than mcp>=2.3) raises ImproperlyConfigured at process start-up, not on the first request.
  • Real MCP endpoint (optional) — with ZB_MCP_TRANSPORT = "sdk", POST mcp/ serves JSON-RPC 2.0 (initialize, ping, tools/list, tools/call) through the official SDK, stateless and with JSON responses, under both WSGI and ASGI. It authenticates only with an API key (a missing or invalid one answers 401 before the SDK sees the message) and reports tool errors in a protocol-aware way: an unknown tool as JSON-RPC -32602, any other 4xx as an isError result keeping its status and code, and anything else as -32603 with no internal detail.
  • Per-API-key scopes and audit — McpApiKeyScope stores the tools each zibanu.django.auth API key may call, editable from the ApiKey admin. A tool outside the key's scope is omitted from tools/list and rejected with 403 in tools/call (without revealing the scopes), before its Django permission is evaluated; rejections (403, 413) and internal errors are recorded in zibanu.django.logging.
  • Per-tool authorization — BaseMcpTool.has_permission defaults to requiring an authenticated user, or delegates to request.user.has_perm(...) when Meta.permission_required is set; subclasses may override it for custom logic.
  • REST exposure — McpViewSet + urls.py serve POST tools/list/ and POST tools/call/, built on zibanu.django.rest_framework.viewsets.ViewSet but authenticating only with ApiKeyAuthentication.
  • Dedicated exceptions — McpToolNotFound (404) and McpPermissionDenied (403), both extending this project's own zibanu.django.rest_framework.exceptions.APIException.

Usage

Basic Usage

Contribute a tool from another Zibanu Django package. Declare the tool:

# <package>/lib/mcp_tools.py
from zibanu.django.mcp.lib.classes import BaseMcpTool


class FileSearchMcpTool(BaseMcpTool):
    class Meta:
        name = "repository_search_files"
        description = "Search files stored in the repository by name or category."
        input_schema = {
            "type": "object",
            "properties": {
                "query": {"type": "string"},
                "category": {"type": "string"},
            },
            "required": ["query"],
        }
        permission_required = "zb_repository.view_file"

    def execute(self, request, **kwargs):
        return {"files": [...]}

Register it from the owning package's own AppConfig.init_app(), guarded by apps.is_installed(...) so the package stays usable without zibanu.django.mcp installed:

# <package>/apps.py
from django.apps import apps


def init_app(self) -> None:
    if apps.is_installed("zibanu.django.mcp"):
        from zibanu.django.mcp.lib.classes import mcp_registry
        from <package>.lib.mcp_tools import FileSearchMcpTool
        mcp_registry.register(FileSearchMcpTool)

Advanced Usage

Switching to the official SDK transport. Set ZB_MCP_TRANSPORT = "sdk" and install the sdk extra (pip install zibanu-django-mcp[sdk]), which requires mcp>=2.3 (tested with mcp 2.3.0, no upper bound). The installed version is also checked at start-up (see Transports):

# settings.py
ZB_MCP_TRANSPORT = "sdk"

Custom authorization logic. Override has_permission instead of (or in addition to) using Meta.permission_required:

class FileSearchMcpTool(BaseMcpTool):
    class Meta:
        name = "repository_search_files"
        description = "Search files stored in the repository."

    def has_permission(self, request) -> bool:
        return request.user.is_authenticated and request.user.groups.filter(name="Reviewers").exists()

    def execute(self, request, **kwargs):
        return {"files": [...]}

Resetting the registry (test seam). McpToolRegistry.clear() removes every registered tool; intended for tests, which must not leak registrations across cases:

def tearDown(self):
    from zibanu.django.mcp.lib.classes import mcp_registry
    mcp_registry.clear()

Transports

ZB_MCP_TRANSPORT selects how the tool registry is served. Tool visibility and authorization are identical in both: they are decided by McpToolGatewayService, never by the transport.

Simple transport (ZB_MCP_TRANSPORT = "simple", default)

  • No extra dependency. A simplified, synchronous contract over DRF (not the MCP wire protocol).
  • POST mcp/tools/list/ -> 200 {"tools": [{"name", "description", "input_schema"}]}.
  • POST mcp/tools/call/ with {"name": <str>, "arguments": <dict, optional>} -> 200 {"result": <dict>}; 403 (out of the key's scope, or missing Django permission), 404 (unknown tool), any other 4xx raised by the tool with its own status and code.
  • POST mcp/ does not exist (it answers 404).

SDK transport (ZB_MCP_TRANSPORT = "sdk")

  • Route. POST /mcp/ (McpEndpointView, route name mcp-endpoint). The route is mcp/ relative to wherever zibanu.django.mcp.urls is included: with the path("mcp/", include(...)) mount shown in Installation the full URL is /mcp/mcp/; include the URLs at the root (path("", include(...))) to publish exactly POST /mcp/. The REST routes stay active.
  • Extra and version. Install zibanu.django.mcp[sdk], which requires mcp>=2.3 with no upper bound; the version tested is mcp 2.3.0. init_app() imports mcp lazily on the after_ready thread and raises ImproperlyConfigured (with the pip install zibanu.django.mcp[sdk] instruction) if it is missing, older than 2.3 or lacks mcp.server.Server; it never falls back to simple. The sdk extra is declared in the pyproject.toml of the package installer (installers/zibanu-django-mcp/), not in this source tree.
  • Authentication. Checked over HTTP before the SDK sees the message: only Authorization: Api-Key <key> authenticates; a missing, invalid, inactive or expired key, or a JWT/Token credential (with DEBUG on or off), answers 401 with WWW-Authenticate: Api-Key.
  • Protocol. JSON-RPC 2.0, stateless Streamable HTTP with JSON responses; POST only. The client must send Accept: application/json, text/event-stream (otherwise the SDK answers 406). Supported methods: initialize, notifications/initialized (202), ping, tools/list, tools/call. Any other method answers -32601.
  • tools/call errors. Unknown tool: JSON-RPC -32602 with data = {"status": 404, "code"}. Any other 4xx (403, 413, 400, 409, 422...): a result with isError: true whose text is the JSON {"status", "code", "detail"}. Anything else (including 5xx): audited, and -32603 "Internal error" with no exception text.
  • Implementation. McpSdkBridge creates, per request, a new low-level Server and a StreamableHTTPSessionManager(stateless=True, json_response=True), runs it inside async with manager.run() and discards it, so no SDK task outlives the request. McpSdkServerFactory registers tools/list and tools/call; McpSdkErrorMapper translates errors. DNS-rebinding protection of the SDK is disabled (host validation is Django's ALLOWED_HOSTS).

Deployment: WSGI and ASGI

McpEndpointView is a synchronous DRF view and the bridge runs the SDK with async_to_sync, so the same code serves both hosts; no change to the project is needed.

  • WSGI (gunicorn sync/gthread, mod_wsgi, runserver without ASGI): async_to_sync runs a short-lived event loop per request. Stateless by design: there is no session to pin to a worker.
  • ASGI (uvicorn, daphne): Django runs the sync view in a thread, and async_to_sync hands the coroutine to the server's event loop.

Measured overhead of the WSGI bridge (NFR threshold: 2x). Method (tests/perf/measure_mcp_wsgi.py, versioned in this package and not collected by test discovery): tools/list through POST mcp/ (the McpSdkBridge, with ZB_MCP_TRANSPORT = "sdk") is compared with POST mcp/tools/list/ (the REST route of the simple transport), on the same machine (remote server: Python 3.11.13, Django 5.2.13, mcp 2.3.0), both through the real Django WSGI stack (get_wsgi_application() invoked with a wsgiref environ, in process, no HTTP socket) and through the same authentication and permission classes. To write nothing to a real database, the API key authentication and McpToolGatewayService.list_visible_tools are replaced identically on both routes by stubs returning the same fixed list of 3 tools; Django boots on an in-memory SQLite defined only inside the script. 50 warm-up requests and 1000 sequential requests per route; statistic: median; ratio = MCP median / REST median.

Route n Median (ms) p95 (ms)
POST mcp/ (MCP, tools/list) 1000 7.306 11.886
POST mcp/tools/list/ (REST) 1000 0.595 0.986

Ratio = 12.29x, above the 2x threshold: the requirement is not met under WSGI. Another run of the same script gave 12.70x (7.549 ms vs 0.594 ms), so the order of magnitude is stable. The absolute cost is a few milliseconds per request. The ASGI path was not measured.

Consequence (BR-18 / REQ-NF-201). Since the ratio exceeds 2x, ASGI is the recommended deployment for ZB_MCP_TRANSPORT = "sdk", and WSGI remains supported but degraded: it works with the same code and the same responses, with the overhead measured above. WSGI support is not withdrawn and the overhead does not block it.

Known limitation: SDK debug logs and the database log handler

When the manager closes, the SDK emits debug-level log records from its asynchronous loop. If the project configures the zibanu.django.logging database handler (db_handler), that handler cannot write from the async context (SynchronousOnlyOperation); the error is swallowed by the logging machinery (Handler.handleError) and those records are lost. It applies under both WSGI and ASGI and does not affect the response. No workaround is provided by this package.

Out of scope

  • No stateful MCP sessions, server-initiated messages/SSE streams, GET/DELETE on /mcp/, nor resumability: every request is independent.
  • No resources, prompts, logging, completion or sampling methods (-32601).
  • No JWT, Token or session authentication on the MCP endpoints.
  • No tool of its own: tools are contributed by other packages.
  • No change of the sdk extra in this source tree (it lives in the installer's pyproject.toml).

Tool names and permissions

This package ships no concrete tool: the registry is empty until another installed package registers one. The names decided for the zibanu.django.repository tools are repository_search_files (permission zb_repository.view_file) and repository_get_file_detail; those are the names used in this document. As of this source tree zibanu.django.repository does not register them yet, so with only these packages installed tools/list returns an empty list.

  • A tool Meta.name must be lowercase; the same name is stored (lowercased) in McpApiKeyScope.tool_name.
  • A tool is visible in tools/list, and callable, only if its name is in the API key's scope and has_permission passes (request.user.has_perm(Meta.permission_required), or just an authenticated user when it is None). A tool outside the scope is answered as 403, not hidden as 404.

API Reference

BaseMcpTool

zibanu.django.mcp.lib.classes.BaseMcpTool (built with McpToolMetaClass)

Abstract base class for an MCP tool.

  • name / description / input_schema — properties reading from Meta (via the normalized _meta the metaclass attaches).
  • has_permission(request) -> bool — default authorization check: requires only an authenticated user when Meta.permission_required is None, otherwise delegates to request.user.has_perm(...).
  • execute(request, **kwargs) -> dict — runs the tool; raises NotImplementedError on the base class. Subclasses must override it.

McpToolMetaClass

zibanu.django.mcp.lib.metaclasses.McpToolMetaClass

Metaclass building and validating BaseMcpTool.Meta. Raises ImproperlyConfigured if Meta is missing, or if it doesn't declare name/description; defaults input_schema to {"type": "object", "properties": {}} and permission_required to None.

McpToolRegistry / mcp_registry

zibanu.django.mcp.lib.classes.McpToolRegistry

Process-wide registry of BaseMcpTool subclasses, indexed by Meta.name.

  • register(tool_class) — registers a tool class, indexed by its name. Registering the same name twice silently overwrites the previous registration.
  • get(name) -> Type[BaseMcpTool] | None — looks up a registered tool class by name.
  • all() -> list[Type[BaseMcpTool]] — lists every registered tool class, in registration order.
  • clear() — removes every registered tool class (tests only).

Callers import the shared mcp_registry instance rather than instantiating McpToolRegistry themselves.

BaseMcpTransport / get_transport

zibanu.django.mcp.lib.classes.BaseMcpTransport (abstract) / zibanu.django.mcp.lib.classes.get_transport

  • BaseMcpTransport.list_tools(tool_classes) -> list[dict] — builds the public descriptor (name, description, input_schema) of the tool classes already filtered as visible.
  • BaseMcpTransport.call_tool(request, tool, arguments) -> dict — executes an already resolved and authorized tool class. Existence, scope and permission are decided upstream by McpToolGatewayService, which raises McpToolNotFound / McpPermissionDenied.
  • get_transport() -> BaseMcpTransport — resolves and instantiates the transport configured in settings.ZB_MCP_TRANSPORT (lru_cache-backed singleton, one instance per process). Lazily imports only the selected transport's module. Raises ImproperlyConfigured for an unknown transport name, or if the resolved transport's own constructor raises it.

SimpleMcpTransport / SdkMcpTransport

zibanu.django.mcp.lib.classes.transports.SimpleMcpTransport / zibanu.django.mcp.lib.classes.transports.SdkMcpTransport

Concrete BaseMcpTransport implementations resolved by get_transport(), never imported directly by callers:

  • SimpleMcpTransport (ZB_MCP_TRANSPORT = "simple", default) — serves the registry directly over DRF, with no extra dependency. Not the real MCP wire protocol; a simplified, synchronous subset meant to be called from a regular WSGI request/response cycle.
  • SdkMcpTransport (ZB_MCP_TRANSPORT = "sdk") — backed by the official Anthropic mcp package (mcp.server.Server), speaking the real MCP wire protocol (JSON-RPC 2.0) through POST /mcp/. Its __init__ lazily imports mcp and raises ImproperlyConfigured if the package is missing or older than mcp>=2.3.

McpViewSet

zibanu.django.mcp.rest_framework.viewsets.McpViewSet

View set exposing REST services to list and call MCP tools, delegating entirely to get_transport().

  • list_tools(request) -> Response — 200: {"tools": [...]} (only the tools visible to the API key). 401: authentication required (Authorization: Api-Key <key>).
  • call_tool(request) -> Response — body {"name": <str>, "arguments": <dict, optional>}. 200: {"result": <dict>}. 401: authentication required. 403: McpPermissionDenied. 404: McpToolNotFound.

McpEndpointView

zibanu.django.mcp.rest_framework.views.McpEndpointView — registered only with ZB_MCP_TRANSPORT = "sdk".

POST only. Authenticates with ApiKeyAuthentication and answers 401 (WWW-Authenticate: Api-Key) before the SDK is involved, then hands the request to McpSdkBridge.handle, which returns the SDK's JSON-RPC answer as a Django HttpResponse. See Transports.

McpAppConfig (application config)

zibanu.django.mcp.apps.McpAppConfig — name = "zibanu.django.mcp", label = "zb_mcp".

  • ready() — sets the ZB_MCP_TRANSPORT default (only if not already set) and delegates to ZbAppConfig.ready() via super().ready(), which starts the background thread waiting for the app registry.
  • init_app() — called from the after_ready background thread; resolves and validates the configured transport via get_transport(), so a misconfigured "sdk" transport fails fast at start-up. signals_factory is left as the inherited no-op: this package connects no model signals.

Exceptions

zibanu.django.mcp.lib.exceptions

  • McpToolNotFound(name) — 404, raised by a transport's call_tool when name is not registered.
  • McpPermissionDenied(name) — 403, raised by a transport's call_tool when tool.has_permission fails.

Configuration

Setting Default Description
ZB_MCP_TRANSPORT "simple" Transport implementation: "simple" (DRF-based, no extra dependency) or "sdk" (official mcp>=2.3 package; also registers POST mcp/).

Tool names are lowercase: McpToolRegistry requires every registered tool's Meta.name to be lowercase, and McpApiKeyScope.tool_name is stored lowercased (spaces are left untouched).

Both defaults are applied by McpAppConfig.ready() only when the project has not already set them.


Testing

The package's suite lives in zibanu/django/mcp/tests/: app config, tool contract, registry, transport factory, both transports, the view set and the SDK endpoint.

# Run the whole package suite
python manage.py test zibanu.django.mcp.tests

# Run a single module or test
python manage.py test zibanu.django.mcp.tests.test_apps
python manage.py test zibanu.django.mcp.tests.test_apps.McpAppConfigTest

# Verbose output
python manage.py test zibanu.django.mcp.tests --verbosity=2

Requirements

  • Python 3.9+
  • Django 3.2+
  • djangorestframework
  • zibanu-django>=3.0.0
  • zibanu-django-auth>=3.2.0

Optional

Feature Library Purpose
ZB_MCP_TRANSPORT = "sdk" mcp>=2.3 (tested with 2.3.0, no upper bound) Official Anthropic MCP SDK, installed as the zibanu.django.mcp[sdk] extra. mcp 2.3.0 itself requires Python 3.10+.

License

Developed by CQ Inversiones SAS. Copyright © 2019–2026. All rights reserved.

Changelog

All notable changes to this package are documented here, one section per principal version (x.y.z). Pre-releases of the same version (-dev.N, etc.) are folded into its section.

[1.0.0] — 2026-11-30

Added

  • First release of the package: McpAppConfig (settings default for ZB_MCP_TRANSPORT, transport validation in init_app, no model signals). With ZB_MCP_TRANSPORT="sdk", init_app imports mcp lazily and verifies it (mcp>=2.3, mcp.server.Server); otherwise it raises ImproperlyConfigured with pip install zibanu.django.mcp[sdk] and never degrades to simple.
  • BaseMcpTool + McpToolMetaClass: declarative contract (name, description, input_schema, permission_required) for any Zibanu Django package to expose an MCP tool.
  • McpToolRegistry (mcp_registry): process-wide registry letting optional packages register tools from their own AppConfig.init_app() without zibanu.django.mcp importing them back.
  • Configurable transport via ZB_MCP_TRANSPORT: SimpleMcpTransport (default, DRF-based, no extra dependency) and SdkMcpTransport (lazy-imports and validates the official mcp package, installed as the [sdk] extra), both resolved through get_transport().
  • McpViewSet + urls.py: POST mcp/tools/list/ and POST mcp/tools/call/, delegating to the configured transport.
  • McpToolNotFound/McpPermissionDenied exceptions (404/403), extending this project's own APIException.
  • McpApiKeyScope model (table zb_mcp_api_key_scope, lower-case tool_name, custom manager) with migration 0001, which depends on the zibanu-django-auth migration that creates ApiKey (zibanu-django-auth>=3.2.0); McpApiKeyScopeInline in the ApiKey admin, validating tool names against McpToolRegistry with server-side permission checks; McpApiKeyScopeService.replace_scopes.
  • McpToolGatewayService: a tool outside the API key's scope is omitted from tools/list and rejected with 403 McpPermissionDenied in tools/call without revealing the scopes, with the scope checked before the tool's Django permission; every 4xx raised by a tool propagates with its own status and code instead of becoming a 500.
  • McpAuditService: records in zibanu.django.logging the 403 and 413 rejections and the internal errors raised by a tool's has_permission during tools/list.
  • McpViewSet authenticates only with ApiKeyAuthentication, with DEBUG on or off (no JWT, no Token).
  • Real MCP endpoint, only with ZB_MCP_TRANSPORT="sdk": McpEndpointView (POST mcp/, route name mcp-endpoint) serves JSON-RPC 2.0 over stateless Streamable HTTP with the official mcp SDK (initialize, notifications/initialized, ping, tools/list, tools/call; any other method answers -32601). The API key is checked over HTTP before the SDK sees the message (401 with WWW-Authenticate: Api-Key). McpSdkBridge builds, per request, a Server and a StreamableHTTPSessionManager(stateless=True, json_response=True); McpSdkServerFactory registers tools/list and tools/call over McpToolGatewayService; McpSdkErrorMapper maps an unknown tool to -32602 (with data = {"status": 404, "code"}), any other 4xx to an isError result and anything else to -32603 without internal detail; the authenticated request reaches the handlers through the current_mcp_request context variable. The REST routes stay active. The SDK's DNS-rebinding protection is disabled (host validation is Django's ALLOWED_HOSTS). OpenAPI: openapi/paths/mcp.{en,es}.yaml.
  • README.md / README.es.md document both transports (simple and sdk), POST /mcp/ (only with ZB_MCP_TRANSPORT="sdk"; the REST routes stay active), the sdk extra (mcp>=2.3, no upper bound, tested with 2.3.0), ASGI and WSGI deployment, the known SDK debug-log limitation with the database log handler and what is out of scope.
  • tests/perf/measure_mcp_wsgi.py (not a test, not collected by discovery): measures tools/list through POST mcp/ against POST mcp/tools/list/ under the real WSGI stack (50 warm-up and 1000 sequential requests per route, median, threshold 2x). Measured ratio 12.29x (7.306 ms vs 0.595 ms), above the threshold: per BR-18/REQ-NF-201 the READMEs declare ASGI as the recommended deployment and WSGI as supported but degraded (WSGI support is not withdrawn).

Changed

  • The tool name of McpApiKeyScopeInline is now a combo of the tools registered in McpToolRegistry (built on every form instantiation, labelled name - description); a stored name no longer registered is still listed, flagged as not registered. Validation is unchanged.
  • Spanish catalog (locale/es): the package ships its first translation, 20 messages (registry and transport errors, tool permission and not-found errors, and the ApiKey scope admin labels).
  • OpenAPI specs (openapi/, EN and ES) corrected against the code and info.version set to 1.0.0: POST to the SDK endpoint is /mcp/mcp/ (the project mounts the package under mcp/); the only accepted authentication is the Api-Key header (the global bearerAuth is gone); the two 401 codes (unauthorized without credentials, not_authenticated for an invalid key); tools/list is filtered by scope and permission; the 500 of the REST routes is not JSON; invalid tools/call input; structuredContent and the 500/405 of POST /mcp/mcp/. Documentation only, no behavior change.
  • SimpleMcpTransport and SdkMcpTransport are now pure executors of an already-authorized tool: scope, permission and audit live in McpToolGatewayService, and any 4xx of the tool propagates unchanged.
  • SdkMcpTransport validates the SDK once, in its own __init__ (mcp>=2.3, mcp.server.Server); McpAppConfig.init_app triggers it at start-up through get_transport(), so a missing or too old SDK raises ImproperlyConfigured there and never at the first request (see Added).

Metadata

Release files for zibanu-django-mcp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zibanu-django-mcp 1.0.0
File Size Uploaded Provenance Actions
zibanu_django_mcp-1.0.0.tar.gz 94.8 kB Without provenance Details for zibanu_django_mcp-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zibanu-django-mcp 1.0.0
File Interpreter ABI Platform Actions
zibanu_django_mcp-1.0.0-py3-none-any.whl Python 3 none any Details for zibanu_django_mcp-1.0.0-py3-none-any.whl

Total release size: 192.1 kB

Release files / zibanu_django_mcp-1.0.0.tar.gz

Download URL zibanu_django_mcp-1.0.0.tar.gz
Size 94.8 kB
Tags Source
SHA-256 checksum
How to use checksums
49c777f6895c6b5b8b4c75240d503954d8f0683e2be2b6d72d47fc1c0e1925c5
BLAKE2b-256 checksum
How to use checksums
8137c0f6b907dc36a59a9073c45c04f2ac45799833c2fe0dfd0dce29864d4395
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / zibanu_django_mcp-1.0.0-py3-none-any.whl

Download URL zibanu_django_mcp-1.0.0-py3-none-any.whl
Size 97.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf08ce49f3e4c6ec8c43aaa2f46c5b7547a8ae0fc6e8c8f768a53040439f39e5
BLAKE2b-256 checksum
How to use checksums
2c90c9ad150dbf19522f56fb3b019dd9c01580d9b046d431bf5fb177a777f619
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for zibanu-django-mcp 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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