django-mcp发现
暴露 /.well-known/mcp-server 在你的Django项目上,让AI代理 可以通过以下方式发现它 mcp://.实施 制图-勘误表-mcp-discovery-uri-03.
安装
pip install django-mcp-discovery设置
1.添加到INSTALLED_APPS:
INSTALLED_APPS = [
...
'mcp_discovery',
]2.包括网址:
urlpatterns = [
...
path('', include('mcp_discovery.urls')),
]3.完成。 访问 https://yoursite.com/.well-known/mcp-server.
配置(可选)
MCP_DISCOVERY = {
'NAME': 'My Site MCP Server',
'ENDPOINT': 'https://mysite.com/mcp/',
'DESCRIPTION': 'Natural language description of the server',
'AUTH': 'none', # none | apikey | oauth2
'CAPABILITIES': ['tools', 'resources'],
'CATEGORIES': ['e-commerce', 'fashion'],
'LANGUAGES': ['it', 'en'],
'CONTACT': 'api@mysite.com',
'DOCS': 'https://mysite.com/mcp/docs/',
'EXPIRES_DAYS': 90, # manifest expiry in days
'CRAWL': True, # False to opt out of indexing
# Optional — primitive previews (draft-03 Section 6.10)
# Use a list for static tools, or 'dynamic' for dynamic ones
'TOOLS_PREVIEW': [
{'name': 'search_products', 'description': 'Search by category'},
{'name': 'check_stock', 'description': 'Real-time availability'},
],
'RESOURCES_PREVIEW': 'dynamic',
'PROMPTS_PREVIEW': 'dynamic',
}如果未设置,则自动检测:
- 名字 --从
django.contrib.sites或SITE_NAME设置 - 端点 --从
SITE_URL或第一个非本地主机ALLOWED_HOSTS - 语言 --从
LANGUAGE_CODE设置
输出示例
最小(无配置):
{
"mcp_version": "2025-06-18",
"name": "My Shop MCP Server",
"endpoint": "https://myshop.com/mcp/",
"transport": "http",
"auth": { "type": "none" },
"capabilities": ["tools", "resources"],
"languages": ["it"],
"last_updated": "2026-03-25T00:00:00+00:00",
"expires": "2026-09-23T00:00:00+00:00",
"crawl": true
}随着 tools_preview (草案-03第6.10节):
{
"mcp_version": "2025-06-18",
"name": "My Shop MCP Server",
"endpoint": "https://myshop.com/mcp/",
"transport": "http",
"auth": { "type": "none" },
"capabilities": ["tools", "resources"],
"categories": ["e-commerce"],
"languages": ["it"],
"expires": "2026-09-23T00:00:00+00:00",
"crawl": true,
"tools_preview": [
{
"name": "search_products",
"description": "Search products by category and material"
},
{
"name": "check_stock",
"description": "Check real-time warehouse availability"
}
],
"resources_preview": "dynamic",
"prompts_preview": "dynamic"
}安全
- 端点域验证 --自定义端点必须位于同一位置
域或子域。无效的终结点将恢复为默认值。 (草案-03第6.8节)
- 过期字段 --舱单声明了自己的到期日。
(草案-03第6.9节)
更新日志
v0.3.0
- 添加
tools_preview,resources_preview,prompts_preview字段(草案-03第6.10节) - 使用列表进行静态预览,或使用“动态”进行动态预览
v0.2.0版本
- 安全性:端点域验证(第6.8节)
- 安全:
expires田野EXPIRES_DAYS设置(第6.9节)
v0.1.0
- 初始版本
链接
作者
孟买集团——意大利米兰——support@mumble.group
