different-ai/openwork · error · Error

Failed to look up the MCP server (${response.status}).

Error message

Failed to look up the MCP server (${response.status}).

What it means

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.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx:686

 * Smart resolution for the add-connection flow: sends whatever the admin
 * typed (URL, bare host, or product name) and gets back a matched preset or
 * a probed endpoint with its requirements discovery inline.
 */
export function useResolveMcpConnection() {
  const { orgId } = useOrgDashboard();
  return useMutation({
    mutationFn: async (query: string): Promise<McpConnectionResolution> => {
      const { response, payload } = await requestJson(
        "/v1/mcp-connections/resolve",
        {
          method: "POST",
          headers: getOrgScopeHeaders(requireOrgId(orgId)),
          body: JSON.stringify({ query }),
        },
        30000,
      );
      if (!response.ok) {
        throw getRequestError(payload, response, `Failed to look up the MCP server (${response.status}).`);
      }
      return payload as McpConnectionResolution;
    },
  });
}

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,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Validate the query client-side (must be a well-formed http(s) URL or known registry identifier) before calling resolve, to avoid 400s.
  2. For 404, inform the user the server is not registered in the org catalog.
  3. For 401/403, re-authenticate and ensure a valid org id is set; handle isReauthRequiredError.
  4. For 502/504, check the target MCP server's reachability and retry; for 5xx, retry with backoff and inspect Den logs.

Example fix

// before
await resolveSmartBarConnection({ query: rawInput });
// after
const query = normalizeMcpQuery(rawInput);
if (!isHttpUrl(query) && !isRegistryId(query)) { setInputError("Enter a valid https URL or server id"); return; }
try {
  await resolveSmartBarConnection({ query });
} catch (err) {
  if (isReauthRequiredError(err)) startReauth();
  else setResolveError(err.message);
}
Defensive patterns

Strategy: validation

Validate before calling

function isResolvableQuery(query: string): boolean {
  if (!query.trim()) return false;
  try { const u = new URL(query); return u.protocol === "https:"; }
  catch { return /^[a-z0-9][a-z0-9-.\/]*$/i.test(query.trim()); }
}

Type guard

function isResolutionPayload(payload: unknown): payload is McpConnectionResolution {
  return typeof payload === "object" && payload !== null;
}

Try / catch

try {
  const resolution = await resolveConnection({ query });
} catch (err) {
  if (isReauthRequiredError(err)) startReauth();
  else if (/\(404\)/.test(err.message)) setHint("Server not found in your organization's catalog");
  else setHint(err.message);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/7b1b08962daad097. Report an issue: GitHub.