Skip to main content
Glama
xelaxela13

django-native-mcp

by xelaxela13

django-native-mcp

Celery에서 영감을 받은 작은 Django 네이티브 MCP 애플리케이션 및 도구 등록 프레임워크입니다. 프로토콜 처리, 스키마, 검증, 직렬화, stdio, Streamable HTTP를 공식 mcp Python SDK에 위임합니다.

이것은 FastMCP를 감싸는 또 다른 래퍼가 아닙니다. 의존성은 오직 네이티브 Python SDK뿐입니다.

Installation

pip install django-native-mcp

애플리케이션과 해당 구성을 추가합니다:

# settings.py

INSTALLED_APPS = [
    # ...
    "django_native_mcp",
]

DJANGO_NATIVE_MCP = {
    "APP": "config.mcp:app",
}

애플리케이션을 생성합니다:

# config/mcp.py

from django_native_mcp import MCP

app = MCP("backend")
app.autodiscover_tools()

설치된 Django 앱에서 도구를 명시적으로 선언합니다:

# orders/mcp.py

from django_native_mcp import shared_tool

from .models import Order


@shared_tool
async def get_order(order_id: int) -> dict:
    """Get an order."""
    order = await Order.objects.aget(pk=order_id)
    return {"id": order.pk, "status": order.status}

등록된 이름은 orders.get_order이며, Django 애플리케이션 레이블을 사용합니다.

python manage.py mcp_list
python manage.py mcp_inspect orders.get_order
python manage.py mcp_call orders.get_order '{"order_id": 1}'
python manage.py mcp_serve --transport stdio

도구는 async def를 사용해야 합니다. 프레임워크는 암시적 스레드나 sync_to_async를 추가하지 않습니다.

Related MCP server: django-mcp

Direct application tools

from django_native_mcp import MCP

app = MCP("backend")


@app.tool(name="system.health")
async def health() -> dict:
    return {"ok": True}

@app.tool은 즉시 하나의 애플리케이션에 바인딩됩니다. @shared_tool은 자동 발견(autodiscovery)이 바인딩할 때까지 애플리케이션 독립적으로 유지됩니다.

Streamable HTTP with Django

공식 SDK ASGI 앱은 단독으로 서비스할 수 있습니다:

application = app.asgi_app()

또는 /mcp는 MCP로 라우팅하고 나머지는 모두 Django로 라우팅합니다:

# config/asgi.py

import os

from django.core.asgi import get_asgi_application

from django_native_mcp.asgi import MCPApplication

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
django_application = get_asgi_application()

# Import the MCP app only after Django's application registry is ready.
from config.mcp import app as mcp_app

application = MCPApplication(
    django=django_application,
    mcp=mcp_app,
    mcp_path="/mcp",
)

디스패처는 ASGI lifespan을 공식 MCP 애플리케이션으로 전달하므로, 해당 전송 수명 주기는 외부 ASGI 서버에 의해 시작되고 중지됩니다.

Testing

공식 in-process 클라이언트를 감싸는 얇은 래퍼를 사용합니다:

from django_native_mcp.testing import MCPTestClient


async with MCPTestClient(app) as client:
    result = await client.call_tool("orders.get_order", {"order_id": 1})

End-to-end example

example/ 디렉터리에는 내장 인증 User를 사용하는 실행 가능한 Django 프로젝트, Streamable HTTP MCP 엔드포인트, 그리고 MCP를 통해 Django 도구를 발견하고 호출하는 독립형 OpenAI Responses API 클라이언트가 포함되어 있습니다.

Architecture

Django apps / mcp.py
        ↓
shared_tool → ToolDefinition → ToolRegistry → MCP
                                              ↓
                                      official MCPServer
                                      ↙              ↘
                                   stdio       Streamable HTTP

레지스트리는 프로세스 로컬이며 공식 서버가 생성되면 읽기 전용이 됩니다. 각 워커는 시작 중에 소스에서 동일한 레지스트리를 빌드합니다.

Non-goals

이 패키지는 MCP 프로토콜 구현체, ORM-to-MCP 생성기, REST/DRF 어댑터, Celery 대체재, 백그라운드 큐, 또는 AI 에이전트 프레임워크가 아닙니다. Django 모델을 자동으로 노출하지 않으며 모델로부터 권한을 추론하지도 않습니다.

License

MIT

A
license - permissive license
Not graded
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
2Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Django MCP server that exposes tools and resources to AI agents using simple decorators, with auto-discovery, type safety, and custom authentication.
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    Integrates MCP tool hosting into Django applications, enabling easy definition and serving of MCP tools, resources, and prompts via ASGI with support for URL path parameters and logging.
    72
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A Model Context Protocol (MCP) server for developing Django applications. It exposes Django project information through MCP tools, enabling AI assistants to better understand and interact with Django codebases.
    109
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Exposes Django REST Framework APIs as MCP tools for AI agents via the Model Context Protocol, with automatic discovery and security.
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform

  • Your DRF API as MCP tools — 1,800 endpoints become 16 dispatchers, permissioned by Django.

  • Official Sevalla MCP — full PaaS API access through just 2 tools.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xelaxela13/django-native-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server