{"record":{"id":"f6803912cd6d7bc4","repo":"different-ai/openwork","slug":"failed-to-discover-mcp-requirements-response-st","errorCode":null,"errorMessage":"Failed to discover MCP requirements (${response.status}).","messagePattern":"Failed to discover MCP requirements \\((.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx","lineNumber":707,"sourceCode":"    },\n  });\n}\n\nexport function useDiscoverMcpConnectionRequirements() {\n  const { orgId } = useOrgDashboard();\n  return useMutation({\n    mutationFn: async (url: string): Promise<McpRequirementsDiscovery> => {\n      const { response, payload } = await requestJson(\n        \"/v1/mcp-connections/discover\",\n        {\n          method: \"POST\",\n          headers: getOrgScopeHeaders(requireOrgId(orgId)),\n          body: JSON.stringify({ url }),\n        },\n        20000,\n      );\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to discover MCP requirements (${response.status}).`);\n      }\n      return payload as McpRequirementsDiscovery;\n    },\n  });\n}\n\nexport type UpdatedMcpConnection = ExternalMcpConnection & {\n  identityChanged: boolean;\n  reconnectionRequired: boolean;\n};\n\nexport function useCreateMcpConnection() {\n  const queryClient = useQueryClient();\n  const { orgId, runReauthableAction } = useOrgDashboard();\n\n  return useMutation({\n    mutationFn: async (input: CreateMcpConnectionInput): Promise<CreatedMcpConnection> => {\n      let created: CreatedMcpConnection | null = null;","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx#L689-L725","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait discoverRequirements({ url: rawUrl });\n// after\nconst url = new URL(rawUrl);\nif (url.protocol !== \"https:\" || isLocalHost(url.hostname)) { setUrlError(\"Enter a public https URL\"); return; }\ntry {\n  await discoverRequirements({ url: url.toString() });\n} catch (err) {\n  if (isReauthRequiredError(err)) startReauth();\n  else setDiscoveryError(err.message);\n}","handlingStrategy":"validation","validationCode":"function isDiscoverableUrl(raw: string): boolean {\n  try {\n    const u = new URL(raw);\n    return u.protocol === \"https:\" && ![\"localhost\", \"127.0.0.1\"].includes(u.hostname) && !/^10\\.|^192\\.168\\./.test(u.hostname);\n  } catch { return false; }\n}","typeGuard":"function isDiscoveryPayload(payload: unknown): payload is McpRequirementsDiscovery {\n  return typeof payload === \"object\" && payload !== null;\n}","tryCatchPattern":"try {\n  const req = await discoverRequirements({ url });\n} catch (err) {\n  if (isReauthRequiredError(err)) startReauth();\n  else if (/\\((502|504)\\)/.test(err.message)) setHint(\"Could not reach the MCP server; verify it is publicly available\");\n  else setHint(err.message);\n}","preventionTips":["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"],"tags":["http","den-api","mcp","discovery"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}