-
-
Notifications
You must be signed in to change notification settings - Fork 494
[Feature Request] Support Exposing Endpoints as MCP Services (Similar to fastapi_mcp) #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@chaofanat that should be relatively easy (especially by coping major part from fastapi-mcp) would like to volunteer to do something wit this like at least write documentation ? |
I took at pass at implementing a ninja version of fastapi-mcp https://github.com/mikeedjones/django-ninja-mcp It was kinda straightforward but depends on #1388 and the EDIT: Got live_server tests passing by using a channels live server client. |
I'm glad you noticed this feature request. I'd be happy to contribute to this project, such as writing documentation. However, I'm not a professional programmer and I'm not very familiar with the open source community participation process. I may need some time to learn about it. I can dedicate about one hour per day to work on this. |
Its a fair criticism - internally fast-mcp (and now ninja-mcp) are making new rest calls using httpx to the original ninja endpoints as opposed to calling the ninja path operation functions directly. It is probably sub-optimal to make those calls directly because ninja expects those functions to be accessed restfully, but to do so requires the mounted MCP server to know where the Ninja endpoints are exposed. You can mount as many MCP servers as you like with |
It looks like MCP changed the protocol a little - modelcontextprotocol/python-sdk#573 looks significantly more robust. I'll take a look at updating my implementaiton. |
Exposing too many tools to an LLM can create context issues. Instead, consider offering a few endpoints that combine multiple functions. Your API descriptions may be more suited for programmers than for LLMs. By presenting tools separately, you can better tailor the tool descriptions for LLM compatibility without altering the API endpoint descriptions. |
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:
@mcp_router
decorator or configuration to mark routes/controllers as MCP endpoints, separate from HTTP endpoints if needed.Reasons & Value
Desired Outcome
Thank you for considering this request! I believe it will make Django-Ninja more versatile for emerging service architectures.
Best regards,
chaofan
The text was updated successfully, but these errors were encountered: