import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"; import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; const AUTH_ERROR_MESSAGE = "TickTick authentication failed (401). Regenerate your API Token in TickTick web: Settings → Account → API Token."; export function isTickTickAuthError(error: unknown): boolean { if (error instanceof UnauthorizedError) { return true; } if (error instanceof StreamableHTTPError && error.code === 401) { return true; } return false; } export function toTickTickAuthError(error: unknown): Error { if (isTickTickAuthError(error)) { return new Error(AUTH_ERROR_MESSAGE); } return error instanceof Error ? error : new Error(String(error)); }