can1357/oh-my-pi · error · SmitheryConnectError
${context}: ${response.status} ${response.statusText}${suffi
Error message
${context}: ${response.status} ${response.statusText}${suffix} What it means
SmitheryConnectError thrown by the expectOk helper whenever any Smithery Connect API call (namespace or connection CRUD) returns a non-OK response. The message carries the caller-provided context string, HTTP status, statusText, and up to the full response body, so it identifies both which operation failed and why the server rejected it.
Source
Thrown at packages/coding-agent/src/mcp/smithery-connect.ts:58
nextCursor?: string | null;
};
function buildAuthHeaders(apiKey: string): Headers {
const headers = new Headers();
headers.set("Authorization", `Bearer ${apiKey}`);
headers.set("Content-Type", "application/json");
return headers;
}
function toApiUrl(path: string): string {
return `${SMITHERY_API_BASE_URL}${path}`;
}
async function expectOk(response: Response, context: string): Promise<void> {
if (response.ok) return;
const responseText = await response.text().catch(() => "");
const suffix = responseText ? `: ${responseText}` : "";
throw new SmitheryConnectError(`${context}: ${response.status} ${response.statusText}${suffix}`, response.status);
}
export function getSmitheryApiBaseUrl(): string {
return SMITHERY_API_BASE_URL;
}
export async function listSmitheryNamespaces(apiKey: string): Promise<SmitheryNamespace[]> {
const response = await fetch(toApiUrl("/namespaces"), {
headers: buildAuthHeaders(apiKey),
signal: withTimeoutSignal(SMITHERY_CONNECT_TIMEOUT_MS),
});
await expectOk(response, "Failed to list Smithery namespaces");
const payload = (await response.json()) as SmitheryNamespacesResponse;
return payload.namespaces ?? [];
}
export async function createSmitheryNamespace(apiKey: string): Promise<SmitheryNamespace> {
const response = await fetch(toApiUrl("/namespaces"), {View on GitHub (pinned to 9690622007)
Solutions
- Read the context and response body in the message — 401/403 means fix the API key, 404 means the resource doesn't exist
- Refresh the Smithery API key via login or the dashboard if you got 401
- For 404, list existing connections/namespaces first to get a valid id/URL
- For 409/422, correct the payload or check for an existing resource before creating
Example fix
// before: assuming the connection exists
const conn = await getSmitheryConnection(url);
// after: handle 404 by creating instead
try {
conn = await getSmitheryConnection(url);
} catch (e) {
if (e instanceof SmitheryConnectError && e.status === 404) conn = await createSmitheryConnection(url);
else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// validate inputs the API would reject with 4xx
if (!connUrl.startsWith("https://")) throw new Error("Connection URL must be https");
if (!apiKey?.trim()) throw new Error("Smithery API key required before Connect API calls"); Type guard
function isSmitheryConnectError(err: unknown): err is SmitheryConnectError {
return err instanceof SmitheryConnectError && typeof err.status === "number";
} Try / catch
try {
await createSmitheryNamespace(name);
} catch (err) {
if (isSmitheryConnectError(err)) {
if (err.status === 401) await reauthenticateSmithery();
else if (err.status === 409) logger.info("Namespace already exists");
else throw err;
} else throw err;
} Prevention
- Check the response body included in the message — it carries the server's reason
- Handle 401 by refreshing credentials before surfacing the error
- Look up existing resources (list*) before create* calls to avoid 409/404
- Validate URL/namespace formats client-side to prevent 422s
When it happens
Trigger: Any of listSmitheryNamespaces, createSmitheryNamespace, listSmitheryConnectionsByUrl, createSmitheryConnection, getSmitheryConnection, or deleteSmitheryConnection receiving 4xx/5xx — e.g. 401 for missing/invalid API key, 404 for unknown connection/namespace id, 409 for duplicate creation, 422 for invalid payload.
Common situations: Expired or wrong Smithery API key in the auth file (401), referencing a deleted connection by URL (404), creating a namespace that already exists (409), malformed request body (400/422).
Related errors
- Devin AssignModel error ${response.status} ${response.status
- GitLab Duo Workflow create failed with HTTP ${response.statu
- ${response.status} ${response.statusText}: ${text}
- Failed to create Smithery auth session: ${response.status} $
- Smithery auth polling failed: ${response.status} ${response.
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/33e648ae5e3bd071.
Report an issue: GitHub.