can1357/oh-my-pi · error · Error

Smithery authorization failed.

Error message

Smithery authorization failed.

What it means

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.

Source

Thrown at packages/coding-agent/src/modes/controllers/mcp-command-controller.ts:2422

		const startedAt = Date.now();

		while (!signal.aborted) {
			if (Date.now() - startedAt >= timeoutMs) {
				throw new Error("Smithery authorization timed out after 5 minutes.");
			}
			let response: SmitheryCliPollResponse;
			try {
				response = await pollSmitheryCliAuthSession(sessionId, signal);
			} catch (error) {
				// A single hung/slow poll aborts with TimeoutError; retry until the deadline.
				if (isTimeoutError(error)) continue;
				throw error;
			}
			if (response.status === "success" && response.apiKey) {
				return response.apiKey;
			}
			if (response.status === "error") {
				throw new Error(response.message ?? "Smithery authorization failed.");
			}
			await Bun.sleep(pollIntervalMs);
		}

		throw new Error("Smithery authorization cancelled.");
	}

	async #handleSmitheryBrowserLogin(): Promise<boolean> {
		const session = await createSmitheryCliAuthSession();
		const fallbackLoginUrl = getSmitheryLoginUrl();
		this.#showMessage(
			[
				"",
				theme.bold("Smithery Login"),
				theme.fg("muted", "Browser authorization started. Complete auth in your browser."),
				theme.fg("dim", "Authorize URL:"),
				theme.fg("accent", session.authUrl),
				theme.fg("dim", `Fallback: ${fallbackLoginUrl}`),

View on GitHub (pinned to 9690622007)

Solutions

  1. Re-run /mcp smithery-login to start a fresh authorization session and approve it in the browser.
  2. If browser auth keeps failing, use the API-key fallback: run /mcp smithery-login and paste your key from smithery.ai when prompted.
  3. Check your Smithery account state (suspended/billing) at smithery.ai — account problems can surface as auth errors.
  4. If Smithery's service is degraded, retry later.
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate an existing key instead of entering the browser flow
await searchSmitheryRegistry("mcp", { limit: 1, apiKey: storedKey }); // throws on 401/403 → key invalid, re-login needed

Type guard

function isSmitheryAuthError(err: unknown): err is Error {
  return err instanceof Error && err.message === "Smithery authorization failed.";
}

Try / catch

try {
  await smitheryLogin();
} catch (err) {
  if (isSmitheryAuthError(err)) {
    showWarning("Smithery rejected the authorization; falling back to API key entry.");
    return await promptForApiKey();
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/e0f0777167476649. Report an issue: GitHub.