{"record":{"id":"e0f0777167476649","repo":"can1357/oh-my-pi","slug":"smithery-authorization-failed","errorCode":null,"errorMessage":"Smithery authorization failed.","messagePattern":"Smithery authorization failed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/controllers/mcp-command-controller.ts","lineNumber":2422,"sourceCode":"\t\tconst startedAt = Date.now();\n\n\t\twhile (!signal.aborted) {\n\t\t\tif (Date.now() - startedAt >= timeoutMs) {\n\t\t\t\tthrow new Error(\"Smithery authorization timed out after 5 minutes.\");\n\t\t\t}\n\t\t\tlet response: SmitheryCliPollResponse;\n\t\t\ttry {\n\t\t\t\tresponse = await pollSmitheryCliAuthSession(sessionId, signal);\n\t\t\t} catch (error) {\n\t\t\t\t// A single hung/slow poll aborts with TimeoutError; retry until the deadline.\n\t\t\t\tif (isTimeoutError(error)) continue;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (response.status === \"success\" && response.apiKey) {\n\t\t\t\treturn response.apiKey;\n\t\t\t}\n\t\t\tif (response.status === \"error\") {\n\t\t\t\tthrow new Error(response.message ?? \"Smithery authorization failed.\");\n\t\t\t}\n\t\t\tawait Bun.sleep(pollIntervalMs);\n\t\t}\n\n\t\tthrow new Error(\"Smithery authorization cancelled.\");\n\t}\n\n\tasync #handleSmitheryBrowserLogin(): Promise<boolean> {\n\t\tconst session = await createSmitheryCliAuthSession();\n\t\tconst fallbackLoginUrl = getSmitheryLoginUrl();\n\t\tthis.#showMessage(\n\t\t\t[\n\t\t\t\t\"\",\n\t\t\t\ttheme.bold(\"Smithery Login\"),\n\t\t\t\ttheme.fg(\"muted\", \"Browser authorization started. Complete auth in your browser.\"),\n\t\t\t\ttheme.fg(\"dim\", \"Authorize URL:\"),\n\t\t\t\ttheme.fg(\"accent\", session.authUrl),\n\t\t\t\ttheme.fg(\"dim\", `Fallback: ${fallbackLoginUrl}`),","sourceCodeStart":2404,"sourceCodeEnd":2440,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts#L2404-L2440","documentation":"Thrown by #waitForSmitheryCliApiKey when the Smithery authorization poll returns status \"error\". If the poll response carries a message it is used as the error text; this literal string is the fallback when the server reports failure without a message. It means Smithery itself rejected or failed the CLI auth session.","triggerScenarios":"Polling a Smithery CLI auth session (created by /mcp smithery-login) whose server-side status became \"error\" with no accompanying message — e.g. the auth request was denied, the session expired server-side, or Smithery's auth service reported an internal failure.","commonSituations":"User clicked 'Deny' or abandoned the consent flow in a way Smithery marks as error; the session expired before approval; a Smithery-side outage marking sessions as failed.","solutions":["Re-run /mcp smithery-login to start a fresh authorization session and approve it in the browser.","If browser auth keeps failing, use the API-key fallback: run /mcp smithery-login and paste your key from smithery.ai when prompted.","Check your Smithery account state (suspended/billing) at smithery.ai — account problems can surface as auth errors.","If Smithery's service is degraded, retry later."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate an existing key instead of entering the browser flow\nawait searchSmitheryRegistry(\"mcp\", { limit: 1, apiKey: storedKey }); // throws on 401/403 → key invalid, re-login needed","typeGuard":"function isSmitheryAuthError(err: unknown): err is Error {\n  return err instanceof Error && err.message === \"Smithery authorization failed.\";\n}","tryCatchPattern":"try {\n  await smitheryLogin();\n} catch (err) {\n  if (isSmitheryAuthError(err)) {\n    showWarning(\"Smithery rejected the authorization; falling back to API key entry.\");\n    return await promptForApiKey();\n  }\n  throw err;\n}","preventionTips":["Approve (don't deny) the consent screen when the browser flow opens.","Start a fresh session promptly — server-side sessions can expire while pending.","Keep an API key from smithery.ai handy as the fallback path.","Verify your Smithery account is in good standing (not suspended, billing current)."],"tags":["smithery","authentication","api"],"backgroundTag":"smithery-authorization-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}