{"record":{"id":"19a700c5dea778cb","repo":"can1357/oh-my-pi","slug":"smithery-login-cancelled-run-mcp-smithery-login","errorCode":null,"errorMessage":"Smithery login cancelled. Run /mcp smithery-login, then retry /mcp smithery-search.","messagePattern":"Smithery login cancelled\\. Run /mcp smithery-login, then retry /mcp smithery-search\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/modes/controllers/mcp-command-controller.ts","lineNumber":2493,"sourceCode":"\n\t#getSmitheryErrorStatus(error: unknown): number | undefined {\n\t\tif (error instanceof SmitheryRegistryError || error instanceof SmitheryConnectError) {\n\t\t\treturn error.status;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t#toSmitheryAuthReason(status: number): string {\n\t\treturn status === 429 ? \"rate limited by Smithery\" : \"forbidden/unauthorized with Smithery\";\n\t}\n\n\tasync #requireSmitheryApiKey(reason: string): Promise<string> {\n\t\tlet apiKey = await getSmitheryApiKey();\n\t\tif (apiKey) return apiKey;\n\n\t\tconst loggedIn = await this.#promptSmitheryLogin(reason);\n\t\tif (!loggedIn) {\n\t\t\tthrow new Error(\"Smithery login cancelled. Run /mcp smithery-login, then retry /mcp smithery-search.\");\n\t\t}\n\n\t\tapiKey = await getSmitheryApiKey();\n\t\tif (!apiKey) {\n\t\t\tthrow new Error(\"Smithery API key not found after login.\");\n\t\t}\n\t\treturn apiKey;\n\t}\n\n\tasync #runSmitheryOperationWithAuthRetry<T>(operation: (apiKey: string) => Promise<T>, reason: string): Promise<T> {\n\t\tconst apiKey = await this.#requireSmitheryApiKey(reason);\n\t\ttry {\n\t\t\treturn await operation(apiKey);\n\t\t} catch (error) {\n\t\t\tconst status = this.#getSmitheryErrorStatus(error);\n\t\t\tif (status === undefined || ![401, 403, 429].includes(status)) {\n\t\t\t\tthrow error;\n\t\t\t}","sourceCodeStart":2475,"sourceCodeEnd":2511,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts#L2475-L2511","documentation":"Thrown by #requireSmitheryApiKey when no stored Smithery API key exists, the interactive login prompt (#promptSmitheryLogin) returns false (the browser login failed and the API-key fallback was also declined), and therefore no key can be supplied for the pending Smithery operation (search/install). It is the user-facing 'you must authenticate to proceed' error, with instructions embedded in the message.","triggerScenarios":"Running /mcp smithery-search (or any Smithery operation via #runSmitheryOperationWithAuthRetry) with no API key saved, then cancelling the login prompt — either by pressing Esc at the API-key input, or the browser auth failing and the key entry being aborted.","commonSituations":"User has no Smithery account/key yet; popup blocked so browser auth never opens and the user Escapes out of the fallback prompt; headless environment with no browser and the user not ready to paste a key.","solutions":["Run /mcp smithery-login and complete it (browser auth or paste your API key from smithery.ai), then retry the original command.","If the browser never opens, copy the 'Authorize URL' printed in the message panel and open it manually.","Get an API key at smithery.ai (account settings) if you don't have one, then paste it at the prompt."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const apiKey = await getSmitheryApiKey();\nif (!apiKey) {\n  console.log(\"No Smithery key stored. Run /mcp smithery-login first (browser auth or paste your key from smithery.ai).\");\n}","typeGuard":"function isLoginCancelledError(err: unknown): err is Error {\n  return err instanceof Error && err.message.startsWith(\"Smithery login cancelled\");\n}","tryCatchPattern":"try {\n  await smitherySearch(query);\n} catch (err) {\n  if (isLoginCancelledError(err)) {\n    // user declined login: surface the retry instruction instead of a stack\n    showHint(\"Run /mcp smithery-login, then retry /mcp smithery-search.\");\n  } else throw err;\n}","preventionTips":["Run /mcp smithery-login once up front so a key is stored before search/install commands.","Keep your Smithery API key from smithery.ai ready for the fallback prompt.","On headless machines, plan to paste the key — the browser flow will not be completable.","Don't Esc out of the key prompt if you want the operation to proceed."],"tags":["smithery","authentication","api-key","cancelled"],"backgroundTag":"missing-api-key","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}