Skip to main content

Intégration MCP pour Django via FastMCP

Project description

Django MCP Integration

Intégration transparente de MCP (Model Context Protocol) dans Django via FastMCP.

Installation

pip install django-mcp-integration

Configuration Django

  • Modifier le fichier settings.py
# settings.py

INSTALLED_APPS = [
    # ...
    'django_mcp_integration',
]


# Optionnel

MCP_SERVER_NAME = "Mon Serveur MCP"
MCP_HOST = "localhost"
MCP_PORT = 8000
MCP_HTTP_PATH = "/mcp/"
MCP_ENABLED  = True
MCP_SERVER_INSTRUCTIONS = None
MCP_SERVER_VERSION = "1.0.0"
  • Modifier le fichier asgi.py
# asgi.py


import os

# from django.core.asgi import get_asgi_application
from django_mcp_integration.handlers.asgi import get_mcp_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_project.settings')

application = get_mcp_asgi_application()

Utiliser dans un outil

# blog/tools.py or blog/mcp_tools.py
from django_mcp_integration import mcp_tool


@mcp_tool(
    name="add",
    description="make a + b",
)
async def add(a: int, b: int) -> int:
    return a + b


@mcp_tool(
    name="create_post",
    description="create post by IA"
)
class CreatePostTool:

    # optional
    def check_permission(self, obj):
        pass

    # required method
    async def execute(self, title: str, content: str):
        pass

lancerment du server

uvicorn django_mcp_test.asgi:application

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_integration-1.0.5.tar.gz (16.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_integration-1.0.5-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file django_mcp_integration-1.0.5.tar.gz.

File metadata

  • Download URL: django_mcp_integration-1.0.5.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_mcp_integration-1.0.5.tar.gz
Algorithm Hash digest
SHA256 b5042ef30f94d7ab5de52033f8409b305feb4ecee8ae97b2c544a8960b13558d
MD5 ec385f64db875fa81687744d769b340c
BLAKE2b-256 2341906755107abd002eb4d0ec20f6c3972bf6b25182fddbd74275d63473cc4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcp_integration-1.0.5.tar.gz:

Publisher: release.yml on mosco23/django-mcp-integration

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_mcp_integration-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_mcp_integration-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 334de90a2afe2f959d7b37c68ba724ea7429e00aa053717f7ed614eca29445b5
MD5 66232638d113c74cb4637f31a11919f9
BLAKE2b-256 ef15ac61694f42f8c3cab045ed742ead5667c29703cd07f073ee66a4d5464788

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcp_integration-1.0.5-py3-none-any.whl:

Publisher: release.yml on mosco23/django-mcp-integration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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