| 52 | // just-written DCR row) so the approval screen reads "Connect Codex?" not a |
| 53 | // random id. Self-declared at open DCR — a label, not a trust signal. |
| 54 | const lookupClientName = async (clientId: string): Promise<string | null> => { |
| 55 | const ctx = await betterAuth.auth.$context; |
| 56 | const app = await ctx.adapter.findOne<{ name?: string | null }>({ |
| 57 | model: "oauthApplication", |
| 58 | where: [{ field: "clientId", value: clientId }], |
| 59 | }); |
| 60 | return app?.name ?? null; |
| 61 | }; |
| 62 | |
| 63 | // Force the MCP approval screen: inject `prompt=consent` on every MCP |
| 64 | // authorize so a connecting client is gated on /mcp-consent rather than |