different-ai/openwork · error
Failed to discover MCP requirements (${response.status}).
Error message
Failed to discover MCP requirements (${response.status}). What it means
Thrown by useDiscoverMcpConnectionRequirements when the requirements-discovery endpoint (POST with a { url } body, 20000ms timeout) returns a non-ok status. getRequestError reports the server's error message or the fallback 'Failed to discover MCP requirements (<status>)'. No McpRequirementsDiscovery is returned, so the connect flow cannot show what OAuth/scopes the server needs.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx:707
},
});
}
export function useDiscoverMcpConnectionRequirements() {
const { orgId } = useOrgDashboard();
return useMutation({
mutationFn: async (url: string): Promise<McpRequirementsDiscovery> => {
const { response, payload } = await requestJson(
"/v1/mcp-connections/discover",
{
method: "POST",
headers: getOrgScopeHeaders(requireOrgId(orgId)),
body: JSON.stringify({ url }),
},
20000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to discover MCP requirements (${response.status}).`);
}
return payload as McpRequirementsDiscovery;
},
});
}
export type UpdatedMcpConnection = ExternalMcpConnection & {
identityChanged: boolean;
reconnectionRequired: boolean;
};
export function useCreateMcpConnection() {
const queryClient = useQueryClient();
const { orgId, runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (input: CreateMcpConnectionInput): Promise<CreatedMcpConnection> => {
let created: CreatedMcpConnection | null = null;View on GitHub (pinned to 2b7df46e8a)
Solutions
- Validate the URL client-side (absolute https URL, no localhost/private hosts) before invoking discovery to avoid 400s.
- For 502/504, verify the target server is publicly reachable and retry; consider a longer timeout if the server is known slow.
- For 401/403, re-authenticate and confirm the org scope; branch on isReauthRequiredError.
- For 5xx, retry with backoff and check Den server/egress logs; confirm Den is allowed outbound network access to the target.
Example fix
// before
await discoverRequirements({ url: rawUrl });
// after
const url = new URL(rawUrl);
if (url.protocol !== "https:" || isLocalHost(url.hostname)) { setUrlError("Enter a public https URL"); return; }
try {
await discoverRequirements({ url: url.toString() });
} catch (err) {
if (isReauthRequiredError(err)) startReauth();
else setDiscoveryError(err.message);
} Defensive patterns
Strategy: validation
Validate before calling
function isDiscoverableUrl(raw: string): boolean {
try {
const u = new URL(raw);
return u.protocol === "https:" && !["localhost", "127.0.0.1"].includes(u.hostname) && !/^10\.|^192\.168\./.test(u.hostname);
} catch { return false; }
} Type guard
function isDiscoveryPayload(payload: unknown): payload is McpRequirementsDiscovery {
return typeof payload === "object" && payload !== null;
} Try / catch
try {
const req = await discoverRequirements({ url });
} catch (err) {
if (isReauthRequiredError(err)) startReauth();
else if (/\((502|504)\)/.test(err.message)) setHint("Could not reach the MCP server; verify it is publicly available");
else setHint(err.message);
} Prevention
- Validate the URL is absolute https and publicly reachable before discovery
- Ensure Den's egress allows outbound calls to third-party MCP servers
- Apply timeouts and single-flight so slow servers do not pile up requests
- Retry 5xx/timeout responses once with backoff before surfacing an error
When it happens
Trigger: Non-ok response discovering requirements for a user-supplied MCP server URL: 400 when the url is malformed or uses an unsupported scheme, 502/504 when Den cannot reach the remote server within the window, 401/403 for session/org-scope issues, 5xx server faults.
Common situations: Discovering against a server that is down, behind a VPN, or rate-limiting Den; user enters an http:// or localhost URL the server rejects; expired Den session; Den egress blocked in a locked-down network.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to configure plugin connection (${response.status}).
- Failed to inspect MCP tools (${response.status}).
- Failed to update MCP tool policy (${response.status}).
- Failed to load MCP connectors (${response.status}).
- Failed to load MCP presets (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/f6803912cd6d7bc4.
Report an issue: GitHub.