Skip to main content

Exposes /.well-known/mcp-server on Django projects for MCP agent discovery. Implements draft-serra-mcp-discovery-uri.

Project description

django-mcp-discovery

Exposes /.well-known/mcp-server on your Django project so AI agents can discover it via mcp://. Implements draft-serra-mcp-discovery-uri-04.

Installation

pip install django-mcp-discovery

Setup

1. Add to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'mcp_discovery',
]

2. Include URLs:

urlpatterns = [
    ...
    path('', include('mcp_discovery.urls')),
]

3. Done. Visit https://yoursite.com/.well-known/mcp-server.

Configuration (optional)

MCP_DISCOVERY = {
    # Required
    'NAME':         'My Site MCP Server',
    'ENDPOINT':     'https://mysite.com/mcp/',

    # SHOULD fields
    'DESCRIPTION':  'Natural language description of the server',

    # Auth — draft-04 structured format
    'AUTH': {
        'required': True,
        'methods': ['bearer'],          # none | bearer | mtls | apikey | oauth2 | x-*
        'endpoint': 'https://auth.mysite.com/token',
    },
    # Retrocompatible shorthand still works: 'AUTH': 'none'

    # trust_class — draft-04 new field
    # Values: public | sandbox | enterprise | regulated
    'TRUST_CLASS': 'public',

    # If TRUST_CLASS = 'regulated' — these are REQUIRED
    'COMPLIANCE': {
        'jurisdiction': 'EU',
        'frameworks': ['GDPR', 'ISO27001'],
        'certification_url': 'https://mysite.com/compliance',
    },
    'LOGGING': {
        'required': True,
        'retention_days': 90,
    },
    'CACHE_TTL': 300,                   # seconds — also available for all trust classes

    # If TRUST_CLASS = 'sandbox' — expires generated automatically
    'EXPIRES_DAYS': 30,                 # default: 30

    # MAY fields — unchanged from v0.3.0
    'CAPABILITIES':     ['tools', 'resources'],
    'CATEGORIES':       ['e-commerce', 'fashion'],
    'LANGUAGES':        ['it', 'en'],
    'CONTACT':          'api@mysite.com',
    'DOCS':             'https://mysite.com/mcp/docs/',
    'CRAWL':            True,           # False to opt out of indexing

    # Primitive previews (draft-04 Section 6.10)
    'TOOLS_PREVIEW': [
        {'name': 'search_products', 'description': 'Search by category'},
        {'name': 'check_stock',     'description': 'Real-time availability'},
    ],
    'RESOURCES_PREVIEW': 'dynamic',
    'PROMPTS_PREVIEW':   'dynamic',
}

Auto-detected if not set:

  • Name — from django.contrib.sites or SITE_NAME setting
  • Endpoint — from SITE_URL or first non-localhost ALLOWED_HOSTS
  • Language — from LANGUAGE_CODE setting

Example output

Minimal (no configuration):

{
  "mcp_version": "2025-06-18",
  "name": "My Shop MCP Server",
  "endpoint": "https://myshop.com/mcp/",
  "transport": "http",
  "auth": { "required": false, "methods": ["none"] },
  "capabilities": ["tools", "resources"],
  "languages": ["it"],
  "last_updated": "2026-03-26T00:00:00+00:00",
  "crawl": true
}

With trust_class = 'enterprise' and bearer auth:

{
  "mcp_version": "2025-06-18",
  "name": "My Shop MCP Server",
  "endpoint": "https://myshop.com/mcp/",
  "transport": "http",
  "auth": {
    "required": true,
    "methods": ["bearer"],
    "endpoint": "https://auth.myshop.com/token"
  },
  "capabilities": ["tools", "resources"],
  "trust_class": "enterprise",
  "categories": ["e-commerce"],
  "languages": ["it"],
  "last_updated": "2026-03-26T00:00:00+00:00",
  "crawl": true
}

Security

  • Endpoint domain validation — custom endpoint MUST be on same domain or subdomain. Invalid endpoints fall back to default. (draft-04 Section 6.8)
  • trust_class validationregulated requires COMPLIANCE.jurisdiction; sandbox auto-generates expires field. (draft-04)

Changelog

v0.4.0

  • Implements draft-serra-mcp-discovery-uri-04
  • auth field restructured: {'required': bool, 'methods': [...]} with optional endpoint and scopes
  • Retrocompatible: AUTH = 'none' string shorthand still works
  • New trust_class field: public | sandbox | enterprise | regulated
  • sandbox: auto-generates expires from EXPIRES_DAYS
  • regulated: requires COMPLIANCE.jurisdiction, adds compliance, logging, cache_ttl
  • New cache_ttl field (MAY) for all trust classes

v0.3.0

  • Added tools_preview, resources_preview, prompts_preview fields (draft-03 Section 6.10)
  • Use a list for static previews, or 'dynamic' for dynamic ones

v0.2.0

  • Security: endpoint domain validation (Section 6.8)
  • Security: expires field with EXPIRES_DAYS setting (Section 6.9)

v0.1.0

  • Initial release

Links

Author

Mumble Group — Milan, Italy — support@mumble.group

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_mcp_discovery-0.4.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mcp_discovery-0.4.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file django_mcp_discovery-0.4.1.tar.gz.

File metadata

  • Download URL: django_mcp_discovery-0.4.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for django_mcp_discovery-0.4.1.tar.gz
Algorithm Hash digest
SHA256 3d1017905f187e65988c620df49a09a8e22b3683b20f5f0c3f4312273b8059b8
MD5 ff1315020d8bc30c96a83d1ff6d64124
BLAKE2b-256 f0c89c928fce1a2a44ec41bf79cf971ff73e414684ca94899bd2d5a7861d5f51

See more details on using hashes here.

File details

Details for the file django_mcp_discovery-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_mcp_discovery-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1eda5cb26869bc80df76ce02682ecd663a171eaca306c55f1249ffb6ae471dc4
MD5 f242bdd662dfb1d1b0e1eac03525e5b0
BLAKE2b-256 1e3d4332c3edd85e85e70de9a5b4119c7c4305272e7f7d9397e48b09ca31d6de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page