$ show django-control-room/dj-control-room
Django Control Room is a plugin framework for building Django admin tools, called 'panels'. It provides a centralized dashboard that automatically discovers installed panels via Python entry points, renders them with a shared design system, and integrates them into the Django admin sidebar. The hub also exposes a Model Context Protocol (MCP) endpoint that aggregates all panel tools for AI agent integration. Panels are independent packages built on the companion `dj-control-room-base` library. The codebase demonstrates strong architecture: a collision-proof registry key derived from PyPI distribution names, featured panel verification to prevent squatting, dynamic admin proxy model registration, and a production-ready MCP transport implementing the Streamable HTTP specification. It includes comprehensive tests covering registry behaviour, admin integration, MCP endpoints, and utility functions.
The LLM identified 2 files worth highlighting for reuse:
PanelRegistry class that discovers panels via `dj_control_room.panels` entry points. Derives a globally unique registry key from the PyPI distribution name (`dist.name`) rather than a declared panel id, preventing collision between community packages. Stamps `_registry_id`, `app_name`, and `package` onto every panel instance. Features `_verify_featured_identity` which checks that a panel claiming a featured ID actually originates from the expected PyPI package, blocking malicious squatting. Supports manual registration for tests. `get_tools_for_user()` iterates all panels and collects tools accessible to a given user with proper fault isolation. This module is self-contained and could be extracted as a generic entry-point-based registry pattern.
Implements the Model Context Protocol (MCP) Streamable HTTP transport as a single Django POST endpoint at `/admin/dj-control-room/mcp/`. Handles JSON-RPC 2.0 methods: `initialize`, `tools/list`, `tools/call`. Authenticates via Bearer token from `MCP_TOKEN` setting and resolves the configured `MCP_USERNAME` to apply panel permission scopes. Aggregates tools from every registered panel with namespacing (`<panel_id>__<tool_name>`). Includes proper error handling for misconfiguration, parse errors, invalid requests, and method not found. Returns HTTP 202 for notifications. The module is cleanly separated and could be reused as a base for other MCP servers.