django-mcp-server
by gts360·★ 332·综合分 50
Django MCP Server 让 AI 代理通过模型上下文协议与 Django 应用程序进行交互。
developer-toolsai-llmdatabase
51
Forks
15
活跃 Issue
2 个月前
最近提交
2 天前
收录于
概述
Django MCP Server 是一个 Django 扩展,为任何 Django 应用程序提供 MCP(模型上下文协议)功能,无论使用 WSGI 还是 ASGI。它允许以最少的代码将 Django 模型暴露为 MCP 工具,使 AI 代理能够安全地查询和与应用程序数据进行交互。服务器支持异步和同步操作,并能与 Django Rest Framework API 无缝集成。
试试问 AI
装完之后,这里有 3 个你可以让 AI 做的事:
你:允许 Claude AI 或其他 LLM 代理查询和操作 Django 应用程序数据
你:将现有的 Django Rest Framework API 转换为供 AI 代理使用的 MCP 工具
你:为 Django 应用程序构建带有自定义工具集的 AI 界面
什么时候选它
如果你在使用 Django 应用并希望启用 AI 代理通过 MCP 与你的模型和 API 交互,请选择此工具。
什么时候不要选它
如果你需要复杂的写操作或不使用 Django,请避免使用此工具,因为它专门为 Django 应用程序设计。
此 server 暴露的工具
从 README 抽取出 9 个工具BirdQueryToolQuery Bird models with location information
LocationToolQuery Location models
CityToolQuery City models
addAdd two numbers together
send_emailSend an email with specified subject and body
get_species_countGet count of a bird species by name
increment_speciesIncrement the count of a bird species
get_foo_barGet first FooBar instance
MyModelViewCreate instances of MyModel
可对比工具
django-ninja-mcpfastapi-mcpllamaindex-django
安装
安装
- 安装包:
pip install django-mcp-server- 添加到 Django 设置:
INSTALLED_APPS = [
# 你的应用...
'mcp_server',
]- 添加 URL 模式:
from django.urls import path, include
urlpatterns = [
# 你的 URL...
path("", include('mcp_server.urls')),
]- 在
mcp.py中定义 MCP 工具:
from mcp_server import ModelQueryToolset
from .models import *
class BirdQueryTool(ModelQueryToolset):
model = BirdClaude Desktop 配置
添加到 claude_desktop_config.json:
{
"mcpServers": {
"django_mcp": {
"command": "/path/to/interpreter/python",
"args": [
"/path/to/your/project/manage.py",
"stdio_server"
]
}
}
}django-mcp-server 对比
最后更新于 · 由 README + GitHub 公开数据自动生成。