upstash/context7 · error
HTTP from /api/auth/mcp
Error message
HTTP ${response.status} from ${deployment.baseUrl}/api/auth/mcp What it means
Thrown by getOnPremMcpAuthStatus when the auth discovery endpoint `${deployment.baseUrl}/api/auth/mcp` returns a non-OK, non-redirect status. It surfaces the raw HTTP status so the user can tell whether the endpoint is missing, unauthorized, or the server is failing.
Solutions
- Verify the base URL points at the actual Context7 deployment root, not a proxy or unrelated app.
- Confirm the on-prem deployment version includes the MCP auth endpoint (/api/auth/mcp).
- Check server logs for the corresponding error; retry if the status was 5xx/transient.
- If an auth gateway blocks the probe, allow unauthenticated access to the discovery path.
Example fix
// before (wrong host, 404) ctx7 setup --url https://unrelated-app.internal // after (actual Context7 deployment) ctx7 setup --url https://context7-onprem.internal
Defensive patterns
Strategy: retry
Validate before calling
const res = await fetch(`${base}/api/auth/mcp`, { redirect: 'manual' });
if (res.status === 404) console.error('Endpoint missing — check deployment version/base URL');
if (res.status >= 500) console.error('Server error — retry later'); Try / catch
try {
const enabled = await getOnPremMcpAuthStatus(deployment);
} catch (e) {
const m = (e as Error).message.match(/^HTTP (\d+)/);
if (m && Number(m[1]) >= 500) await retryWithBackoff(() => getOnPremMcpAuthStatus(deployment));
else console.error('Verify base URL and deployment version:', (e as Error).message);
} Prevention
- Point the base URL at the real Context7 deployment root, not a proxy or unrelated app.
- Confirm your on-prem version exposes /api/auth/mcp.
- Retry 5xx; investigate 4xx (proxy auth blocking the probe).
When it happens
Trigger: getOnPremMcpAuthStatus(deployment) is called and the fetch to /api/auth/mcp responds with status >= 400 (e.g. 401, 404, 500) or < 300 but not OK — after the 3xx check has passed.
Common situations: The base URL points to an app that doesn't expose /api/auth/mcp (404); an auth proxy rejects the unauthenticated probe (401/403); the on-prem deployment is an older/newer version without the MCP auth endpoint; server-side crash (500).
Related errors
- Authentication discovery was redirected. Pass the final…
- Failed to fetch user info
- errorBody.error || errorBody.message || res.statusText
- errorBody.error ?? "http_error"
- Failed to fetch
AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16).
Data as JSON: /api/errors/9a81417b90aed30f.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/setup/deployment.ts:69
}
return `${deployment.baseUrl}/mcp`;
}
export async function getOnPremMcpAuthStatus(deployment: CustomSetupDeployment): Promise<boolean> {
const response = await fetch(`${deployment.baseUrl}/api/auth/mcp`, {
headers: { Accept: "application/json" },
redirect: "manual",
signal: AbortSignal.timeout(10_000),
});
if (response.status >= 300 && response.status < 400) {
throw new Error(
`Authentication discovery was redirected. Pass the final deployment URL instead of ${deployment.baseUrl}.`
);
}
if (!response.ok) {
throw new Error(`HTTP ${response.status} from ${deployment.baseUrl}/api/auth/mcp`);
}
const body = (await response.json()) as { enabled?: unknown };
if (typeof body.enabled !== "boolean") {
throw new Error(`Invalid response from ${deployment.baseUrl}/api/auth/mcp`);
}
return body.enabled;
}
View on GitHub (pinned to 4416fb855b)