{"record":{"id":"a50ed6857c099915","repo":"different-ai/openwork","slug":"failed-to-load-mcp-presets-response-status","errorCode":null,"errorMessage":"Failed to load MCP presets (${response.status}).","messagePattern":"Failed to load MCP presets \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx","lineNumber":599,"sourceCode":"  }));\n}\n\nexport function useMcpConnections(scope: ExternalMcpConnectionScope = \"manageable\") {\n  const { orgId } = useOrgDashboard();\n  return useQuery({\n    enabled: Boolean(orgId),\n    queryKey: mcpConnectionQueryKeys.list(orgId, scope),\n    queryFn: () => fetchConnections(scope, requireOrgId(orgId)),\n  });\n}\n\nexport function useMcpConnectionPresets() {\n  return useQuery({\n    queryKey: mcpConnectionQueryKeys.presets(),\n    queryFn: async (): Promise<ExternalMcpPreset[]> => {\n      const { response, payload } = await requestJson(\"/v1/mcp-connections/presets\", {}, 15000);\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to load MCP presets (${response.status}).`);\n      }\n      const record = payload as { presets?: ExternalMcpPreset[] };\n      return record.presets ?? [];\n    },\n  });\n}\n\nexport type McpConnectionAccessInput = {\n  orgWide: boolean;\n  memberIds: string[];\n  teamIds: string[];\n};\n\nexport type CreateMcpConnectionInput = {\n  name: string;\n  url: string;\n  authType: ExternalMcpAuthType;\n  credentialMode: ExternalMcpCredentialMode;","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx#L581-L617","documentation":"Thrown by useMcpConnectionPresets when GET /v1/mcp-connections/presets returns a non-ok status (15000ms timeout). getRequestError reports the server's error message or the fallback 'Failed to load MCP presets (<status>)'. The presets query then errors and consumers fall back to the default empty array (data ?? []).","triggerScenarios":"Non-ok response fetching the preset catalog: 401 for an expired session, 403 when the user cannot read org marketplace presets, 404/501 when the server version predates the presets endpoint (API mismatch), 5xx during server faults or deploys.","commonSituations":"A Den server older than the web client calling a not-yet-deployed endpoint; expired session; transient 5xx during a deploy; restricted role without preset read access.","solutions":["For 404/501, align client and server versions — the deployed Den server must support the presets endpoint.","For 401/403, re-authenticate and check read permissions.","For 5xx, rely on TanStack Query retry/backoff and check Den server health.","Because consumers default to [], decide deliberately whether silently showing zero presets is acceptable or the error should surface; use isReauthRequiredError for the re-auth flow."],"exampleFix":"// before\nconst { data: presets = [] } = useMcpConnectionPresets();\n// after\nconst { data: presets = [], error } = useMcpConnectionPresets();\nif (error && !/\\((404|501)\\)/.test(error.message)) {\n  if (isReauthRequiredError(error)) startReauth();\n  else showError(error.message);\n}","handlingStrategy":"fallback","validationCode":"// cheap pre-flight\nif (!sessionValid()) throw new Error(\"Sign in to load MCP presets\");","typeGuard":"function isEndpointMissing(err: unknown): boolean {\n  return err instanceof Error && /\\((404|501)\\)/.test(err.message);\n}","tryCatchPattern":"const { data: presets = [], error } = useMcpConnectionPresets();\nconst effectivePresets = error && isEndpointMissing(error) ? BUNDLED_FALLBACK_PRESETS : presets;\nif (error && !isEndpointMissing(error) && !isReauthRequiredError(error)) showError(error.message);","preventionTips":["Deploy Den server and web client together so the presets endpoint always exists","Ship a bundled fallback preset list for older servers","Refresh sessions before entering setup flows","Distinguish missing-endpoint (404/501) from transient 5xx when deciding to fall back"],"tags":["http","den-api","mcp","presets"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}