Let people connect Claude, ChatGPT, Claude Code, Codex, Cursor and VS Code to your project MCP server by URL and a sign-in, with no key to paste. This is the application-facing integration: mount it in your project’s authenticated frontend, not in Django Admin Overview. The built-in accounts key and OAuth paths remain supported.
1. Backend: one line
mcp.enable_public_profile(
# No custom validator needed for django-cfg personal UserAPIKey.
oauth=True, # approval page = <site_url>/#settings/mcp
oauth_issuer="https://mcp.example.com", # public origin of the MCP host
)oauth=True is all a project with the widget’s Settings dialog needs: the approval page is the site_url of the site the request belongs to (site_for(request)) + /#settings/mcp. Pass oauth_consent_url="https://…" only to send people somewhere else (the frontend lives on another origin than site_url); an explicit URL always wins, and passing it alone also turns OAuth on.
On a hand-written profile use ProfileBuilder.enable_oauth(consent_url=None, issuer=None, access_ttl=..., refresh_ttl=...). issuer defaults to the request origin, subject to the issuer rule below; set it when a proxy hides the public host. Defaults: access token 30 days, refresh token 180 days.
Issuer rule
Breaking in 2.3.367. The server no longer trusts any request host as its issuer. Without oauth_issuer, the request host must be the api_url host of a configured site (in development any host is accepted). Any other host gets 400 invalid_request (“This host is not an issuer of this server.”) on the OAuth endpoints, and the refusal is logged. A project whose MCP lives on its own host (for example mcp.example.com, which is not a site api_url) must set oauth_issuer, or discovery and authorization stop working.
It is stateless: client ids, consent requests, codes and tokens are signed with SECRET_KEY. No tables, no migration. Rotating SECRET_KEY signs everyone out.
What the server then serves:
| Route | Purpose |
|---|---|
/.well-known/oauth-protected-resource[/<path>/] | Which authorization server protects the resource |
/.well-known/oauth-authorization-server | Endpoints, PKCE S256 only |
<path>oauth/register/ | Dynamic client registration (RFC 7591) |
<path>oauth/authorize/ | Validates the request, redirects to your consent page |
<path>oauth/approve/ | Your page posts the user’s decision here |
<path>oauth/token/ | Code for tokens, and refresh |
Redirects are accepted only for the clients’ own callbacks (claude.ai, chatgpt.com, platform.openai.com, cursor://anysphere.cursor-mcp, vscode.dev, and the exact Notion and Perplexity callbacks listed below) and for loopback addresses (Claude Code, Codex, Gemini CLI, Goose, VS Code desktop). Anything else is refused at registration.
X-MCP-Access-Key keeps working beside it. The operator profile never accepts OAuth tokens: the profile name is inside the token.
Personal keys and user identity
With neither a custom validator nor static public keys, the public profile resolves the user’s own django-cfg UserAPIKey to an active Django account. The accounts API exposes POST /cfg/accounts/api-key/reveal/ and POST /cfg/accounts/api-key/regenerate/ for the signed-in user under its existing authorization policy. Regeneration invalidates the previous key. The project frontend owns the Settings UI; the removed Overview key routes must not be used.
An operator credential is separate. A key not bound to an account represents a machine caller, not a signed-in staff member. Review profile permissions and model policies before granting access.
2. Frontend: the Settings dialog
The person approves inside the host’s Settings dialog; there is no consent page to build. Add the widget’s section once:
import { SettingsDialog } from '@djangocfg/layouts';
import { mcpSettingsSection } from '@djangocfg/widget-mcp';
<SettingsDialog sections={[mcpSettingsSection()]} />To give the person a way in from the sidebar, add the ready group (it shows only while the section is registered; see Settings launchers):
import { mcpSidebarGroup } from '@djangocfg/layouts';
const sidebar = { groups: [...mainGroups, mcpSidebarGroup({ label: 'Connect' })] };What happens:
authorizeredirects the browser to<site_url>/#settings/mcp?request=<signed>&client=<name>. The fragment never reaches a server, so the signed request stays out of server and CDN logs.- A guest is sent to sign-in and brought back to the same link (
@djangocfg/layouts≥ 2.1.598). - A signed-in user is approved at once: the dialog posts the
requestwith the user’s JWT toPOST <api><path>oauth/approve/, shows one status line above the connect list (“Connecting Claude…”, then “Claude is connected. Returning to your assistant…”) and follows the returnedredirect_to. There is no Allow or Cancel step; the person already pressed Connect in their assistant. - A
400means the request expired (10 minutes) or is invalid: the line says to start again from the assistant.
The signed request is base64url(json):timestamp:signature; approve verifies the signature and uses its own copy, so nothing the page displays can ride on a real grant. Authorization codes are single use (the guard is one Django cache entry per code, so the cache must be shared across workers, e.g. Redis, and a cache outage refuses rather than allows). Refresh tokens are not rotated: renewing the key (Renew access) is the revocation. Never put a key or token in a URL.
site_url must be the public origin of the frontend that mounts the dialog. When that frontend lives elsewhere, set oauth_consent_url="https://app.example.com/#settings/mcp"; the flow is the same.
After Allow: what each client does
Your page only navigates to redirect_to. The client’s own screen finishes the job, so there is nothing to build for the last step.
| Client | redirect_to points at | Then |
|---|---|---|
| Claude (web, Desktop) | https://claude.ai/api/mcp/auth_callback | Claude exchanges the code, shows the connector as connected and returns to the chat |
| ChatGPT | https://chatgpt.com/connector_platform_oauth_redirect (or /connector/oauth/<id>) | ChatGPT completes the connector itself |
| Claude Code | http://localhost:<port>/callback | Its local listener takes the code; the terminal reports the sign-in and the tab can be closed |
| Codex | http://127.0.0.1:<port>/callback/<id> | Same: the local listener finishes codex mcp login |
| Cursor | cursor://anysphere.cursor-mcp/oauth/callback | The browser hands control back to the Cursor app |
| VS Code | https://vscode.dev/redirect or http://127.0.0.1:33418 | Hands control back to VS Code |
Cancel takes the same road with error=access_denied; the client shows its own “not connected” state.
Show your own message only when the page cannot navigate: no request in the URL (send the visitor to where the install buttons are) or a 400 from approve (the request expired after 10 minutes: “start again from your assistant”).
The browser briefly shows the authorize address. It is public anyway (it is in the discovery document); set oauth_issuer to a dedicated MCP host such as https://mcp.example.com so the main API host is not the one in the address bar. No key or token is ever in a URL: only the signed request (10 minutes) and the code (2 minutes, useless without the client’s PKCE verifier).
3. Frontend: install buttons
<McpConnect server={{ url, alias, name }} loadKey={...} /> from @djangocfg/widget-mcp renders all of these, grouped by app: the first screen is one tile per app (Claude, ChatGPT, Codex, Gemini, Notion, Perplexity, Cursor, VS Code, LM Studio, Goose, and “Other app”), and opening an app lists each documented way to connect it (Claude: the web and desktop connector, and Claude Code in a terminal). Claude, ChatGPT, Notion, Perplexity and Goose go through OAuth as below; Claude Code, Codex, Gemini CLI, Cursor, VS Code and LM Studio get the signed-in user’s own key in the command or deeplink, which works in bearer-only clients too. A hand-built page can use either path.
Each assistant gets one action, built from the endpoint URL (E) and a short alias (A):
| Assistant | Action |
|---|---|
| Claude (web, Desktop) | Link https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=<A>&connectorUrl=<E>; the user confirms and signs in |
| ChatGPT | Copy E, open https://chatgpt.com/: Settings, Connectors, Create, paste URL, auth OAuth (no prefill link exists) |
| Claude Code | Copy claude mcp add --transport http <A> <E>; sign in on first use with /mcp |
| Codex | Copy codex mcp add <A> --url <E> && codex mcp login <A> |
| Cursor | cursor://anysphere.cursor-deeplink/mcp/install?name=<A>&config=<base64 of {"url":E}> |
| VS Code | https://vscode.dev/redirect/mcp/install?name=<A>&config=<url-encoded {"type":"http","url":E}> |
| Gemini CLI | gemini mcp add --scope user --transport http --header "X-MCP-Access-Key: <key>" <A> <E> (docs ) |
| LM Studio | lmstudio://add_mcp?name=<A>&config=<base64 of {"url":E,"headers":{...}}> (docs ) |
| Goose | goose://extension?url=<E>&type=streamable_http&id=<A>&name=<N>; signs in with OAuth (docs ) |
| Notion | Copy E; in an agent: Tools & Access, Add connection, Custom MCP server; auth OAuth (Business and Enterprise plans) |
| Perplexity | Copy E, open https://www.perplexity.ai/computer/plugins: Add custom, MCP connector, Remote; auth OAuth |
Install script and agent skill
Every profile serves two files beside info/, to anyone (an installer has no
credential yet):
| URL | What it is |
|---|---|
<endpoint>/install.sh | POSIX sh that registers the server in Claude Code, Codex and Gemini CLI, whichever are in PATH, and installs the skill |
<endpoint>/SKILL.md | An agent skill generated from the live server |
curl -fsSL https://api.example.com/mcp/install.sh | sh
curl -fsSL https://api.example.com/mcp/install.sh | MCP_API_KEY=<key> sh # key profile
curl -fsSL https://api.example.com/mcp/install.sh | sh -s -- --dry-run # --uninstall, --no-skill, --forceAn OAuth profile (enable_oauth) registers by URL and signs in on first use. A key
profile reads your API key from MCP_API_KEY (not a bare API_KEY, which a shell often holds for something else), else asks on the terminal without echo;
with neither it stops before writing anything. Your API key is never in the script.
Say what the skill is for (an agent decides from the description alone whether to
load it; mcp_doctor warns while it is missing):
mcp.skill(
description="Use when the user asks about Acme listings, prices or agents.",
sections={"Rules": "Prices are in EUR. Never invent a listing id."},
# alias="acme", # registration name; default: the server name, slugged
# file="mcp/SKILL.md", # replaces the generated text entirely
)ProfileBuilder.skill(...) does the same for one profile. The public and default
profiles use the bare alias, any other profile <alias>-<profile>.
The tool table and the server’s instructions appear in SKILL.md only on a request
that carries a credential the profile accepts (the rule of /info/; there is no
anonymous profile). An anonymous reader gets “call tools/list after connecting”. The
skill the installer fetches is the anonymous one.
Skill locations (vendor documentation, checked 2026-11-14): Claude Code
~/.claude/skills/<alias>/SKILL.md; Codex ~/.agents/skills/ (its user scope);
Gemini CLI ~/.gemini/skills/ or the same ~/.agents/skills/, so one copy serves both.
Clients that add a server in a form (Notion, Perplexity, Mistral, Copilot Studio, n8n, Zapier, Make)
Some apps have no config file and no link: the person fills a form. Two ways in, both already served:
- OAuth by URL. The app registers itself (RFC 7591) and signs in. It works only if its callback is on the allowlist above. Added after checking each vendor’s page: Notion
https://app.notion.com/workflows/mcp/oauth/callback(printed in the form’s Advanced settings), Perplexityhttps://www.perplexity.ai/rest/connections/oauth_callbackand the Enterprise formhttps://enterprise.perplexity.ai/rest/connections/oauth_callback. Matching is exact on scheme, host and path: no wildcard, soapp.notion.com.evil.exampleandnotion.comare refused. A client whose callback is not published (Mistral Le Chat, Make) is not on the list; use the key options below. - A header with the user’s key. Notion’s “Bearer token” option sends
Authorization: Bearer <key>and “API Key” sends the header you name; useX-MCP-Access-Keyas the Key and the user’s API key as the Value. Both reach the same check. “Basic” is not supported.
<McpConnect> shows these values field by field under “Manual setup”, each with its own Copy button.
Checked against real clients
A local server was driven with Claude Code 2.1 and Codex 0.146. Their registrations:
- Claude Code:
redirect_uris: ["http://localhost:<port>/callback"]. - Codex:
redirect_uris: ["http://127.0.0.1:<port>/callback/<id>"],application_type: "native". It completed the whole sign-in.
The authorization-server metadata does not advertise authorization_response_iss_parameter_supported. The iss parameter is still sent on every redirect, but Codex insists on iss when told it is supported and then drops it from its own callback (“response missing required issuer”). Advertising the flag would only lock it out.