A customer wants to ask their AI assistant which projects are overdue. Your Django application already has the projects, the permissions and a report that answers the question. Adding an AI connection should build on that work.
Model Context Protocol, or MCP, gives the assistant a standard way to discover and call tools you expose. For a Django product, the useful work is deciding which application functions those tools can reach and under whose authority.
Here is how we would approach it, using an illustrative project-management application.
Start with one useful request
Take a request such as “Show overdue projects owned by my team, with their next milestone.” It has a clear result that someone can check against the application.
Before building the tool, settle what “overdue” means. A project may have a missed milestone while its final delivery date remains in the future. Completed and archived projects may need excluding. “My team” must resolve from the signed-in user's access, including any restrictions on individual projects.
Write those decisions into the tool's contract: accepted filters, returned fields, date rules and expected errors. Start with read access. A report is enough to test whether the assistant can find the right tool, supply valid filters and give a useful answer.
An administrator with access to every project is a poor first test account. Include someone who can see only part of the organisation's work. That exposes mistakes which a successful demo can hide.
Put the application rules in one place
The MCP tool should call a small application service that also supplies the existing report. That service receives the authenticated actor, the permitted organisation context and validated filters. It applies the access checks and returns the allowed results.
If the report's logic currently lives inside a Django view, extract the relevant part carefully. Calling the view directly can skip checks normally supplied by middleware or the request pipeline. Copying its query into a second implementation creates two places to maintain the meaning of “overdue”.
Authentication establishes who is calling. The application must still check that person's current role and access to each requested object. In a product serving multiple organisations, resolve the organisation from the authorised context. A model-supplied project ID must never be enough to select another organisation's data.
The adapter then turns the service result into a useful tool response. Return the fields needed for the question, with a bounded page size and a way to request the next page. Say when results are incomplete. Include the report's effective date or refresh time where it changes how someone should interpret the answer.
This boundary is useful beyond MCP. A web view, scheduled report and assistant can use the same rules while presenting the result differently.
Choose a deployment that fits the application
The official Python SDK can expose an MCP server as an ASGI application. ASGI is the interface used by asynchronous Python web servers. The SDK documents how its HTTP app can sit inside a larger application, including the startup and shutdown work the host must manage. Python SDK integration guide
Django also supports ASGI deployment. An existing Django product can therefore share a deployment with an SDK-based MCP app, provided routing, application startup, middleware and database access are handled deliberately. This needs an integration test; adding a route alone does not establish that the two applications work together. Django ASGI deployment
For a product currently served through WSGI, there is a choice. Moving the web deployment to ASGI may be reasonable. Running a small MCP process alongside the existing web process can keep the change narrower. The latter adds another process to monitor and deploy. Sharing a release and application services can help limit that overhead.
Review synchronous database and third-party calls before putting them inside async handlers. A deployment change does not automatically make those calls safe or non-blocking. Keep transaction-heavy work together in an appropriate service function and use the framework's supported sync/async boundary.
Hand-writing the protocol is another maintenance commitment. The July 2026 MCP revision removed the older initialization handshake and transport-level sessions. A short handler copied from an older example can implement the wrong contract for the clients you intend to support. Choose and document compatible protocol and SDK versions, then test the actual hosts your customers use. MCP July 2026 release
Test the boundary before expanding it
The first useful test set follows the user's request all the way through:
- The assistant and report return the same projects for the same person, filters and effective date.
- A project outside that person's access cannot be retrieved by supplying its ID, and the response does not reveal whether a hidden project exists.
- Removing access affects subsequent calls, and revoking the connection stops it working.
- Missing filters, invalid dates and very large page requests produce helpful, bounded errors.
- A partial result is clearly marked, and the assistant explains that more pages remain rather than presenting it as the whole report.
Run the connection flow against staging from the intended assistant. Test sign-in, consent, expiry and reconnection as well as a successful tool call. Keep enough operational information to diagnose a failure without storing credentials or entire customer responses in logs.
A release flag can limit access to the new endpoint. Shared service changes still affect the existing website, so its report and permission tests need to pass too.
That first report gives the team something concrete to evaluate. If people use it and trust the result, add the next workflow. For an existing Django product, the starting point is an application review and a narrow integration that preserves the rules users already rely on.