
zacharypodbela/django-rest-framework-mcp
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
zacharypodbela/django-rest-framework-mcp - кандидат на сервер MCP, импортированный из https://github.com/zacharypodbela/django-rest-framework-mcp.
Обзор
zacharypodbela/django-rest-framework-mcp - кандидат на сервер MCP, импортированный из https://github.com/zacharypodbela/django-rest-framework-mcp.
Обзор (машинный перевод)
django-rest-framework-mcp позволяет раскручивать MCP-серверы, которые выставляют ваши API Django Rest Framework в качестве инструментов MCP всего с несколькими строками кода.
Загрузите рабочие процессы администратора (и сделайте разработку интерфейсов администратора делом прошлого):
- “Деактивировать аккаунт [email protected]” - фактически деактивировать его Расширьте бесплатную пробную версию [email protected] на 1 неделю
- «Сколько новых пользователей присоединилось за неделю?» → Возвращает реальные данные → LLM могут быстро создавать графики (не нужны более сложные библиотеки FE-графирования)
Или преобразуйте свой традиционный, скучный SaaS UX с помощью разговорных взаимодействий:
- Старый способ: Пользователь Кликает «Управление», Кликает «Мои сообщения», Кликает сообщение из списка, Кликает «Редактировать», меняет название, Кликает «Сохранить» С Django Rest Framework MCP: «Можете ли вы переименовать мой пост из «Руководства для начинающих» в «Django 101»?»
Быстрый старт
1.Установить пакет:
-
Добавить к [[Т1]]:
-
Добавьте конечную точку MCP к
urls.py:
4.Преобразуйте любой DRF ViewSet в MCP-инструменты с одним декоратором:
Эта страница переведена автоматически. Технические детали смотрите в оригинале.
README
Показан фрагмент оригинального README. Открыть оригинал.
Django REST Framework MCP
django-rest-framework-mcp allows you to spin up MCP servers that expose your Django Rest Framework APIs as MCP tools with just a few lines of code.
Supercharge your admin workflows (and make developing Admin interfaces a thing of the past):
- “Deactivate [email protected]’s account” → Actually deactivates it
- “Extend [email protected]’s free trial by 1 week” → Updates their plan
- “How many new users joined week-over-week?” → Returns real data → LLMs can quickly create graphs (no more complex FE graphing libraries needed)
Or transform your traditional, boring SaaS UX with conversational interactions:
- Old way: User Clicks “Manage”, Clicks “My Posts”, Clicks a post from the list, Clicks “Edit”, changes the title, Clicks “Save”
- With Django Rest Framework MCP: “Can you rename my post from ‘Beginners Guide to Django’ to ‘Django 101’?”
Quick Start
- Install the package:
pip install django-rest-framework-mcp
- Add to your
INSTALLED_APPS:
INSTALLED_APPS = [
# ... your other apps
'djangorestframework_mcp',
]
- Add the MCP endpoint to your
urls.py:
urlpatterns = [
# ... your other URL patterns
path('mcp/', include('djangorestframework_mcp.urls')),
]
- Transform any DRF ViewSet into MCP tools with a single decorator:
from djangorestframework_mcp.decorators import mcp_viewset
@mcp_viewset()
class CustomerViewSet(ModelViewSet):
queryset = Customer.objects.all()
serializer_class = CustomerSerializer
When @mcp_viewset is applied to a ViewSet class that inherits from GenericViewSet (such as ModelViewSet or ReadOnlyModelViewSet), any of the following methods that are defined will be automatically exposed as MCP tools:
list-> List customers withcustomers_listtool.retrieve-> Retrieve a customer withcustomers_retrievetool.create-> Create new customers withcustomers_createtool.update-> Update customers withcustomers_updatetool. (All fields must be passed in)partial_update-> Update customers withcustomers_partial_updatetool. (A subset of fields can be passed in)destroy-> Delete customers withcustomers_destroytool.
For each tool the library automatically:
- Generates tool schemas from your DRF serializers
- Preserves your existing permissions, authentication, and filtering
- Returns context rich error messages to guide LLMs
(See: Custom Actions below for more info on how to expose additional endpoints you created using the @action decorator as tools).
- Connect any MCP client to
http://localhost:8000/mcp/and try it out!
Important Differences between MCP Requests and API Requests
Установка
This server does not publish a one-line install command.
Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →Конфигурация
{
"mcpServers": {
"my-django-mcp": {
"command": "node",
"args": [
"path/to/mcp-remote",
"http://localhost:8000/mcp/",
"--transport",
"http-only"
]
}
}
}