We want to attach a an ASGI app, like FastAPI, to an existing Django app, without any performance downsides.
In our example we are attaching an MCP server, including auto-loading.
You have an existing Django app, you serve via WSGI on a server like guinicorn. That's it!
You will only need a two dependencies, Starlette (the package behind FastAPI), and a2wsgi.
python3 -m pip install starlette a2wsgi
# optional for our example: mcp
python3 -m pip install mcp
Create asgi.py file as shown below.
Optionally, create an CMP app, that has no expernal depencies, so you can safely import anywhere in your stack.
If you are coming from guinicorn, uvinicorn should be the safest transition.
python3 -m pip install mcp
Finally, you can run your compbine server via:
uvicorn my_mapp.asgi:app
Enjoy!