{"record":{"id":"7b1b08962daad097","repo":"different-ai/openwork","slug":"failed-to-look-up-the-mcp-server-response-statu","errorCode":null,"errorMessage":"Failed to look up the MCP server (${response.status}).","messagePattern":"Failed to look up the MCP server \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx","lineNumber":686,"sourceCode":" * Smart resolution for the add-connection flow: sends whatever the admin\n * typed (URL, bare host, or product name) and gets back a matched preset or\n * a probed endpoint with its requirements discovery inline.\n */\nexport function useResolveMcpConnection() {\n  const { orgId } = useOrgDashboard();\n  return useMutation({\n    mutationFn: async (query: string): Promise<McpConnectionResolution> => {\n      const { response, payload } = await requestJson(\n        \"/v1/mcp-connections/resolve\",\n        {\n          method: \"POST\",\n          headers: getOrgScopeHeaders(requireOrgId(orgId)),\n          body: JSON.stringify({ query }),\n        },\n        30000,\n      );\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to look up the MCP server (${response.status}).`);\n      }\n      return payload as McpConnectionResolution;\n    },\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,","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx#L668-L704","documentation":"Thrown by useResolveMcpConnection when the resolve endpoint (POST with a { query } body, 30000ms timeout) returns a non-ok status. getRequestError reports the server's error message or the fallback 'Failed to look up the MCP server (<status>)'. Callers resolveSmartBarConnection and resolveConnection receive a rejected mutation instead of an McpConnectionResolution.","triggerScenarios":"Non-ok response resolving a user-typed MCP server query (URL or registry name): 400 when the query string is not a valid URL/identifier, 404 when no matching MCP server is registered, 401/403 for session or org-scope problems (requireOrgId), 504/502 when Den cannot reach the remote server to resolve it, 5xx server faults.","commonSituations":"User pastes a malformed or private URL into the smart bar; the target MCP server is offline or behind a firewall; org restrictions block the target server; session expiry mid-flow.","solutions":["Validate the query client-side (must be a well-formed http(s) URL or known registry identifier) before calling resolve, to avoid 400s.","For 404, inform the user the server is not registered in the org catalog.","For 401/403, re-authenticate and ensure a valid org id is set; handle isReauthRequiredError.","For 502/504, check the target MCP server's reachability and retry; for 5xx, retry with backoff and inspect Den logs."],"exampleFix":"// before\nawait resolveSmartBarConnection({ query: rawInput });\n// after\nconst query = normalizeMcpQuery(rawInput);\nif (!isHttpUrl(query) && !isRegistryId(query)) { setInputError(\"Enter a valid https URL or server id\"); return; }\ntry {\n  await resolveSmartBarConnection({ query });\n} catch (err) {\n  if (isReauthRequiredError(err)) startReauth();\n  else setResolveError(err.message);\n}","handlingStrategy":"validation","validationCode":"function isResolvableQuery(query: string): boolean {\n  if (!query.trim()) return false;\n  try { const u = new URL(query); return u.protocol === \"https:\"; }\n  catch { return /^[a-z0-9][a-z0-9-.\\/]*$/i.test(query.trim()); }\n}","typeGuard":"function isResolutionPayload(payload: unknown): payload is McpConnectionResolution {\n  return typeof payload === \"object\" && payload !== null;\n}","tryCatchPattern":"try {\n  const resolution = await resolveConnection({ query });\n} catch (err) {\n  if (isReauthRequiredError(err)) startReauth();\n  else if (/\\(404\\)/.test(err.message)) setHint(\"Server not found in your organization's catalog\");\n  else setHint(err.message);\n}","preventionTips":["Normalize and validate user input (https URLs or known registry ids) before resolve","Debounce/avoid duplicate resolve mutations for the same query","Check target MCP server reachability when resolution times out (502/504)","Always run resolution inside a valid org context"],"tags":["http","den-api","mcp","resolution"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}