-
-
Notifications
You must be signed in to change notification settings - Fork 545
Description
Background & Use Case
As a long-time user of Django-Ninja, I deeply value the completeness of the Django ecosystem and its clear architecture, as well as the efficient API development experience that Django-Ninja provides. I am currently building a project with Django-Ninja and have a critical need: I want to expose API endpoints as MCP services (similar to how fastapi_mcp does for FastAPI), to integrate with agent-based systems and remote service protocols.
While FastAPI has existing support for such protocols, I prefer to stay within the Django ecosystem to leverage its mature features (middleware, ORM, admin panel, etc.) and avoid fragmenting my tech stack.
Feature Request
I propose adding native support in Django-Ninja to expose endpoints as MCP services.
Key requirements:
- Dedicated Router/Decorator: Introduce a
@mcp_routerdecorator or configuration to mark routes/controllers as MCP endpoints, separate from HTTP endpoints if needed. - Protocol Parsing: Support MCP-specific request/response parsing (message format, authentication, streaming, etc.), compatible with Django’s request lifecycle.
- Asynchronous & Middleware Compatibility: Work with Django’s async views (if MCP supports async) and integrate seamlessly with existing middleware.
Reasons & Value
- Tech Stack Consistency: Keep the project within the Django ecosystem, reducing maintenance costs from adopting additional frameworks.
- Future-Proofing: With the rise of agent systems and distributed services, protocols like MCP (e.g., for remote procedure calls, multi-channel communication) are becoming essential. Supporting them will make Django-Ninja more competitive for modern use cases.
- Developer Experience: The fastapi_mcp implementation proves this is feasible. Bringing this capability to Django-Ninja will benefit developers who prefer Django’s architecture but need MCP-compatible services.
Desired Outcome
- Documentation: Clear guides on how to define and configure MCP endpoints in the Django-Ninja docs.
- Examples: Sample code snippets for basic MCP endpoint definitions, authentication setup, and error handling.
- Coexistence: MCP services should work alongside existing HTTP endpoints without conflicts.
Thank you for considering this request! I believe it will make Django-Ninja more versatile for emerging service architectures.
Best regards,
chaofan