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.4.tar.gz (11.3 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.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_mcp_integration-1.0.4.tar.gz
  • Upload date:
  • Size: 11.3 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.4.tar.gz
Algorithm Hash digest
SHA256 270624a39073a91ef39e1a67c37423cc4956b15aabdf4c50d3ddf8775b3ee373
MD5 37f57a42e0dd38e5e5b3699a0b63b312
BLAKE2b-256 7d78279bdf70a067e611934fdf721fcd57c1f3093414cdaa2c224cd2d0ee9260

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcp_integration-1.0.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_mcp_integration-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fc2f68d4223295b23ea42fe55b1a59eca702abd21db60b1086238a0690936741
MD5 cf67ae604447ae8d16f449e5ecfa774c
BLAKE2b-256 35db866a001ba207c01b13caeb3e6e4f98962b47fa81123fac35718dc04fbb7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_mcp_integration-1.0.4-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