caspel26/django-ninja-aio-crud
View on GitHub ↗Async dynamic CRUD framework for Django Ninja — built-in auth, filtering, pagination, automatic serialization, and MCP tools for AI agents.
50 ★1 forksPythonUpdated 21d ago
What you need to know
Async CRUD framework for Django Ninja with automatic schema generation, filtering, pagination, per-method auth, and M2M management, which can also expose every registered ViewSet to any MCP client as callable tools.
Install
pip install "django-ninja-aio-crud[mcp]"
Usage
- •Add ninja_aio to INSTALLED_APPS and run python manage.py mcp_server myproject.api.api (or set NINJA_AIO_MCP_API in settings).
- •ViewSets and Views are auto-picked-up as tools named <model>_<operation> (e.g. book_create) and <viewclass>_<function>_<method>.
- •MCP tool calls bypass django-ninja's router-layer auth wiring — attach a request_factory to provide request.user/auth context.
- •Per-method auth via auth, get_auth, post_auth; enable opt-in bulk endpoints with bulk_operations.
Key features
- ✓Type-safe generic classes (ModelUtil, Serializer, APIViewSet) with full IDE autocomplete.
- ✓Meta-driven serializers generate CRUD schemas for existing Django models without changing base classes.
- ✓Async CRUD ViewSets with automatic read/create/update schemas, dynamic query-param schemas, and async pagination.
- ✓M2M relation endpoints (add/remove/list via M2MRelationSchema), reverse FK handling, bulk operations, @action decorators, and lifecycle hooks.
- ✓MCP integration exposes CRUD, bulk, and custom endpoints as MCP stdio tools.
Best for
Django developers who want near-boilerplate-free async CRUD APIs whose endpoints automatically become MCP tools for AI agents.
Caveats
- ⚠MCP tool calls bypass django-ninja auth wiring (it lives at the router layer, not inside handlers) — enforce authorization via request_factory and viewset hooks.
- ⚠MCP integration is an optional extra (pip install "django-ninja-aio-crud[mcp]").
Platforms: Local
Reviewed 2026-08-18
Topics
ai-agentsapiasyncauthenticationcruddjangodjango-ninjamcpmodel-context-protocolormpythonrest-apiweb-framework
- Stars
- 50★
- Forks
- 1
- Language
- Python
- License
- MIT
- Created
- 2024-09-16
- Last push
- 2026-08-14