djcrud_mcp¶
Django host package for MCP profile registration. Ships inside the djcrud
wheel (requires djcrud_drf). Stdio MCP / FastMCP lives in the
separate djcrud-client package — not here.
pip install --pre "djcrud[drf,mcp]"
djcrud[mcp] also pulls djcrud-client for agent subprocesses. See
Agents (MCP bridge).
Design spec: djcrud_mcp design.
Server setup¶
pip install --pre "djcrud[drf,mcp]"Enable
djcrud_drf,djcrud_api, Bearer middleware, API URLs (DRF API)Register
ModelViewSetsubclasses ondjcrud_drf.siteRegister permissions in
djcrud.pyRegister one
McpProfileondjcrud_mcp.site(see Agents (MCP bridge))Add
djcrud_mcptoINSTALLED_APPSand includedjcrud_drf.siteURLs
INSTALLED_APPS = [
# ...
"djcrud_drf",
"djcrud_mcp",
"djcrud_example.mcp_example",
]
urlpatterns = (
djcrud.site.build().urlpatterns
+ djcrud_drf.site.build().urlpatterns
)
MCP profile¶
Tutorial: djcrud_example.mcp_example (see Agents (MCP bridge)).
import djcrud_mcp
from djcrud_example.drf_example.djcrud import ArticleViewSet, ProductViewSet
class ExampleMcp(djcrud_mcp.McpProfile):
viewsets = (ArticleViewSet, ProductViewSet)
djcrud_mcp.site.register(ExampleMcp)
build() instantiates the registered class and
resolves api_prefixes. server_name, instructions, and
info_tool_name are @property defaults from the ViewSet models unless you
override class attributes.
Host profile API¶
Endpoint |
Purpose |
|---|---|
|
Host MCP profile key (single registered profile) |
|
Profile JSON (instructions, |
|
Registered ViewSet |
Public API¶
djcrud_mcp.site—register(McpProfile),build(),get_profile(key)McpProfile— declare on the host; built onsite.build()discover_viewsets(),api_path_for(),model_name_for()
Client (djcrud-client)¶
Remote stdio MCP subprocesses install djcrud-client only (mcp + httpx,
no Django). FastMCP, schema tool building, and HTTP proxying live in
djcrud_client.
pip install djcrud-client
export DJCRUD_TOKEN=<raw_key>
djcrud-client -mcp
djcrud-client --call article_list --json '{}'