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
- Overview
- Installation
- Quick Start
- Features
- Usage
- Transports
- API Reference
- Configuration
- Testing
- Requirements
- 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 withMcpToolMetaClass), an abstract base class any other Zibanu Django package subclasses to declare an MCP tool: aMetawithname,description,input_schema(JSON-Schema) and, optionally,permission_required, plus anexecutemethod. - Provide
McpToolRegistry(and its sharedmcp_registryinstance), a process-wide registry that lets a package "extend inward" intozibanu.django.mcpwithout the latter ever importing it back. A package registers its tools from its ownAppConfig.init_app(), guarded byapps.is_installed("zibanu.django.mcp"). - Resolve a configurable transport through
get_transport(), selected by theZB_MCP_TRANSPORTsetting:"simple"(default), a JSON-RPC-like contract over this project's own DRFViewSet, with no extra dependency; or"sdk", backed by the official Anthropicmcppackage (installed as thezibanu.django.mcp[sdk]extra), speaking the real MCP wire protocol throughPOST /mcp/(see Transports).McpViewSetnever imports a concrete transport directly. - Expose
McpViewSet+urls.py, servingPOST mcp/tools/list/andPOST mcp/tools/call/, delegating entirely to the transport resolved byget_transport(). WithZB_MCP_TRANSPORT = "sdk",urls.pyalso registersMcpEndpointView(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
-
Nothing to configure for the default transport:
ZB_MCP_TRANSPORTdefaults to"simple", a DRF-based contract with no extra dependency. -
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": [...]}
-
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.authAPI keys authenticate (Authorization: Api-Key <key>); a JWT orTokencredential is answered401. A key sees and may call only the tools listed in itsMcpApiKeyScoperows (no rows, no tools). This package ships no tool of its own (see Tool names and permissions).
Features
- Declarative tool contract —
BaseMcpTool, built withMcpToolMetaClass, validates every subclass'sMeta(name/descriptionrequired,input_schemadefaulting to an empty JSON-Schema object,permission_requireddefaulting toNone) and exposes it as_meta. - Process-wide tool registry —
McpToolRegistry/mcp_registrylets any installed Zibanu Django package register its own tools, typically from itsAppConfig.init_app(), withoutzibanu.django.mcpever importing that package back. - Configurable transport —
ZB_MCP_TRANSPORTselects"simple"(DRF-based, no extra dependency) or"sdk"(officialmcppackage), both resolved and cached byget_transport(). - Lazy import and fail-fast validation of the official SDK —
SdkMcpTransportimportsmcponly inside its own__init__, called fromMcpAppConfig.init_app()on theafter_readybackground thread, so a misconfiguredZB_MCP_TRANSPORT = "sdk"(missing SDK, or older thanmcp>=2.3) raisesImproperlyConfiguredat 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 answers401before 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 anisErrorresult keeping its status and code, and anything else as-32603with no internal detail. - Per-API-key scopes and audit —
McpApiKeyScopestores the tools eachzibanu.django.authAPI key may call, editable from theApiKeyadmin. A tool outside the key's scope is omitted fromtools/listand rejected with403intools/call(without revealing the scopes), before its Django permission is evaluated; rejections (403,413) and internal errors are recorded inzibanu.django.logging. - Per-tool authorization —
BaseMcpTool.has_permissiondefaults to requiring an authenticated user, or delegates torequest.user.has_perm(...)whenMeta.permission_requiredis set; subclasses may override it for custom logic. - REST exposure —
McpViewSet+urls.pyservePOST tools/list/andPOST tools/call/, built onzibanu.django.rest_framework.viewsets.ViewSetbut authenticating only withApiKeyAuthentication. - Dedicated exceptions —
McpToolNotFound(404) andMcpPermissionDenied(403), both extending this project's ownzibanu.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 andcode.POST mcp/does not exist (it answers404).
SDK transport (ZB_MCP_TRANSPORT = "sdk")
- Route.
POST /mcp/(McpEndpointView, route namemcp-endpoint). The route ismcp/relative to whereverzibanu.django.mcp.urlsis included: with thepath("mcp/", include(...))mount shown in Installation the full URL is/mcp/mcp/; include the URLs at the root (path("", include(...))) to publish exactlyPOST /mcp/. The REST routes stay active. - Extra and version. Install
zibanu.django.mcp[sdk], which requiresmcp>=2.3with no upper bound; the version tested ismcp2.3.0.init_app()importsmcplazily on theafter_readythread and raisesImproperlyConfigured(with thepip install zibanu.django.mcp[sdk]instruction) if it is missing, older than 2.3 or lacksmcp.server.Server; it never falls back tosimple. Thesdkextra is declared in thepyproject.tomlof 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/Tokencredential (withDEBUGon or off), answers401withWWW-Authenticate: Api-Key. - Protocol. JSON-RPC 2.0, stateless Streamable HTTP with JSON responses;
POSTonly. The client must sendAccept: application/json, text/event-stream(otherwise the SDK answers406). Supported methods:initialize,notifications/initialized(202),ping,tools/list,tools/call. Any other method answers-32601. tools/callerrors. Unknown tool: JSON-RPC-32602withdata = {"status": 404, "code"}. Any other 4xx (403, 413, 400, 409, 422...): a result withisError: truewhose text is the JSON{"status", "code", "detail"}. Anything else (including 5xx): audited, and-32603"Internal error"with no exception text.- Implementation.
McpSdkBridgecreates, per request, a new low-levelServerand aStreamableHTTPSessionManager(stateless=True, json_response=True), runs it insideasync with manager.run()and discards it, so no SDK task outlives the request.McpSdkServerFactoryregisterstools/listandtools/call;McpSdkErrorMappertranslates errors. DNS-rebinding protection of the SDK is disabled (host validation is Django'sALLOWED_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,
runserverwithout ASGI):async_to_syncruns 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_synchands 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/DELETEon/mcp/, nor resumability: every request is independent. - No
resources,prompts,logging,completionorsamplingmethods (-32601). - No JWT,
Tokenor session authentication on the MCP endpoints. - No tool of its own: tools are contributed by other packages.
- No change of the
sdkextra in this source tree (it lives in the installer'spyproject.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.namemust be lowercase; the same name is stored (lowercased) inMcpApiKeyScope.tool_name. - A tool is visible in
tools/list, and callable, only if its name is in the API key's scope andhas_permissionpasses (request.user.has_perm(Meta.permission_required), or just an authenticated user when it isNone). A tool outside the scope is answered as403, not hidden as404.
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 fromMeta(via the normalized_metathe metaclass attaches).has_permission(request) -> bool— default authorization check: requires only an authenticated user whenMeta.permission_requiredisNone, otherwise delegates torequest.user.has_perm(...).execute(request, **kwargs) -> dict— runs the tool; raisesNotImplementedErroron 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 itsname. Registering the samenametwice 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 byMcpToolGatewayService, which raisesMcpToolNotFound/McpPermissionDenied.get_transport() -> BaseMcpTransport— resolves and instantiates the transport configured insettings.ZB_MCP_TRANSPORT(lru_cache-backed singleton, one instance per process). Lazily imports only the selected transport's module. RaisesImproperlyConfiguredfor 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 Anthropicmcppackage (mcp.server.Server), speaking the real MCP wire protocol (JSON-RPC 2.0) throughPOST /mcp/. Its__init__lazily importsmcpand raisesImproperlyConfiguredif the package is missing or older thanmcp>=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 theZB_MCP_TRANSPORTdefault (only if not already set) and delegates toZbAppConfig.ready()viasuper().ready(), which starts the background thread waiting for the app registry.init_app()— called from theafter_readybackground thread; resolves and validates the configured transport viaget_transport(), so a misconfigured"sdk"transport fails fast at start-up.signals_factoryis 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'scall_toolwhennameis not registered.McpPermissionDenied(name)— 403, raised by a transport'scall_toolwhentool.has_permissionfails.
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+
djangorestframeworkzibanu-django>=3.0.0zibanu-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 forZB_MCP_TRANSPORT, transport validation ininit_app, no model signals). WithZB_MCP_TRANSPORT="sdk",init_appimportsmcplazily and verifies it (mcp>=2.3,mcp.server.Server); otherwise it raisesImproperlyConfiguredwithpip install zibanu.django.mcp[sdk]and never degrades tosimple. 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 ownAppConfig.init_app()withoutzibanu.django.mcpimporting them back.- Configurable transport via
ZB_MCP_TRANSPORT:SimpleMcpTransport(default, DRF-based, no extra dependency) andSdkMcpTransport(lazy-imports and validates the officialmcppackage, installed as the[sdk]extra), both resolved throughget_transport(). McpViewSet+urls.py:POST mcp/tools/list/andPOST mcp/tools/call/, delegating to the configured transport.McpToolNotFound/McpPermissionDeniedexceptions (404/403), extending this project's ownAPIException.McpApiKeyScopemodel (tablezb_mcp_api_key_scope, lower-casetool_name, custom manager) with migration0001, which depends on thezibanu-django-authmigration that createsApiKey(zibanu-django-auth>=3.2.0);McpApiKeyScopeInlinein theApiKeyadmin, validating tool names againstMcpToolRegistrywith server-side permission checks;McpApiKeyScopeService.replace_scopes.McpToolGatewayService: a tool outside the API key's scope is omitted fromtools/listand rejected with403McpPermissionDeniedintools/callwithout 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 a500.McpAuditService: records inzibanu.django.loggingthe403and413rejections and the internal errors raised by a tool'shas_permissionduringtools/list.McpViewSetauthenticates only withApiKeyAuthentication, withDEBUGon or off (no JWT, noToken).- Real MCP endpoint, only with
ZB_MCP_TRANSPORT="sdk":McpEndpointView(POST mcp/, route namemcp-endpoint) serves JSON-RPC 2.0 over stateless Streamable HTTP with the officialmcpSDK (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 (401withWWW-Authenticate: Api-Key).McpSdkBridgebuilds, per request, aServerand aStreamableHTTPSessionManager(stateless=True, json_response=True);McpSdkServerFactoryregisterstools/listandtools/calloverMcpToolGatewayService;McpSdkErrorMappermaps an unknown tool to-32602(withdata = {"status": 404, "code"}), any other 4xx to anisErrorresult and anything else to-32603without internal detail; the authenticated request reaches the handlers through thecurrent_mcp_requestcontext variable. The REST routes stay active. The SDK's DNS-rebinding protection is disabled (host validation is Django'sALLOWED_HOSTS). OpenAPI:openapi/paths/mcp.{en,es}.yaml. README.md/README.es.mddocument both transports (simpleandsdk),POST /mcp/(only withZB_MCP_TRANSPORT="sdk"; the REST routes stay active), thesdkextra (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): measurestools/listthroughPOST mcp/againstPOST 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
McpApiKeyScopeInlineis now a combo of the tools registered inMcpToolRegistry(built on every form instantiation, labelledname - 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 theApiKeyscope admin labels). - OpenAPI specs (
openapi/, EN and ES) corrected against the code andinfo.versionset to1.0.0:POSTto the SDK endpoint is/mcp/mcp/(the project mounts the package undermcp/); the only accepted authentication is theApi-Keyheader (the globalbearerAuthis gone); the two 401 codes (unauthorizedwithout credentials,not_authenticatedfor an invalid key);tools/listis filtered by scope and permission; the 500 of the REST routes is not JSON; invalidtools/callinput;structuredContentand the 500/405 ofPOST /mcp/mcp/. Documentation only, no behavior change. SimpleMcpTransportandSdkMcpTransportare now pure executors of an already-authorized tool: scope, permission and audit live inMcpToolGatewayService, and any 4xx of the tool propagates unchanged.SdkMcpTransportvalidates the SDK once, in its own__init__(mcp>=2.3,mcp.server.Server);McpAppConfig.init_apptriggers it at start-up throughget_transport(), so a missing or too old SDK raisesImproperlyConfiguredthere 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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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.