Django MCP Server
@omarbenhamid
关于 Django MCP Server
Django MCP Server is a Django extensions to easily enable AI Agents to interact with Django Apps through the Model Context Protocol it works equally well on WSGI and ASGI
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"django-mcp-server": {
"command": "python",
"args": [
"manage.py",
"mcp_inspect"
]
}
}
}工具
未检测到工具
工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。
概览
What is Django MCP Server?
Django MCP Server is an implementation of the Model Context Protocol (MCP) for Django. It enables MCP clients and AI agents to interact with any Django application by exposing Django models and custom logic as MCP tools through a declarative, Django-style interface.
How to use Django MCP Server?
Install via pip (pip install django-mcp-server), add mcp_server to INSTALLED_APPS, include its URLs in your project’s urls.py, then define tools by subclassing ModelQueryToolset or MCPToolset in a mcp.py file. The MCP endpoint is served at /mcp by default. Use python manage.py mcp_inspect to verify tool declarations.
Key features of Django MCP Server
- Expose Django models as MCP tools in two lines of code.
- Publish custom Python methods as MCP tools via
MCPToolset. - Convert Django Rest Framework views to MCP tools with one annotation.
- Works on both WSGI and ASGI without infrastructure changes.
- Supports session management via Django sessions (stateless option available).
- Integrates with Claude AI, Google ADK, and any MCP client.
Use cases of Django MCP Server
- Allow AI agents to query or update Django models through natural language.
- Add MCP endpoints to an existing Django app without rewriting logic.
- Expose DRF CRUD operations to MCP clients for automated data management.
- Enable chatbots to send emails or perform custom business logic via Django.
FAQ from Django MCP Server
What are the runtime requirements?
Python 3.x, Django (version supported shown on PyPI), and optionally Django Rest Framework for DRF tool integration. No additional infrastructure changes needed.
How do I secure the MCP endpoint?
Set DJANGO_MCP_AUTHENTICATION_CLASSES in settings.py to use DRF authentication classes. For production or public data, consider OAuth2 integration with django-oauth-toolkit and its DCR add-on.
Does Django MCP Server work with both WSGI and ASGI?
Yes, it works on both WSGI and ASGI without any infrastructure changes. The server manages state independently of the deployment model.
Can I expose existing DRF views as MCP tools?
Yes, use drf_publish_create_mcp_tool, drf_publish_update_mcp_tool, drf_publish_delete_mcp_tool, or drf_publish_list_mcp_tool annotations or method calls on your DRF views. Note that built-in authentication and pagination are disabled when used this way.
How do I test the MCP tools during development?
Use the management command python manage.py mcp_inspect to list declared tools. You can also connect with the MCP Python SDK via streamablehttp_client or test in Claude Desktop using a stdio configuration.
开发工具 分类下的更多 MCP 服务器
test
cloudwegoThe ultimate LLM/AI application development framework in Go.
nuxt-mcp / vite-plugin-mcp
antfuMCP server helping models to understand your Vite/Nuxt app better.
MCP Inspector
modelcontextprotocolVisual testing tool for MCP servers
MCP Containers
metorialConnect any AI model to 1200+ integrations (MCP, CLI, API)
test
harlancA simple,high performance and secure live media server in pure Rust (RTMP[cluster]/RTSP/WebRTC[whip/whep]/HTTP-FLV/HLS).🦀
评论