From d360b916f98032bff0f4e56521cf2eaf00ea29a6 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 9 Nov 2026 05:05:27 -0800 Subject: [PATCH] fix(mcp): grant list shows the effective end for grants minted before 0028 --- cloud/apps/sandbox-control/src/mcp/oauth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud/apps/sandbox-control/src/mcp/oauth.ts b/cloud/apps/sandbox-control/src/mcp/oauth.ts index 8a2c8078d33..269f0afc7b4 100644 --- a/cloud/apps/sandbox-control/src/mcp/oauth.ts +++ b/cloud/apps/sandbox-control/src/mcp/oauth.ts @@ -648,7 +648,8 @@ export type GrantRow = { export async function listGrants(db: D1Database, accountId: string, now: number, createdBy?: string): Promise { const { results } = await db .prepare( - `SELECT r.family_id, r.client_id, c.client_name, r.created_by, r.scopes, r.family_expires_at, + `SELECT r.family_id, r.client_id, c.client_name, r.created_by, r.scopes, + COALESCE(r.family_expires_at, r.created_at + ${GRANT_TTL_MS}) AS family_expires_at, (SELECT MIN(f.created_at) FROM api_keys f WHERE f.family_id = r.family_id) AS granted_at, (SELECT MAX(f.last_used_at) FROM api_keys f WHERE f.family_id = r.family_id) AS last_used_at, (SELECT k.prefix FROM api_keys k WHERE k.id = r.grantor_key_id) AS via_key