mastra-ai/mastra · error · Error

Failed to fetch servers from ${registry.servers_url}: ${resp

Error message

Failed to fetch servers from ${registry.servers_url}: ${response.statusText}

What it means

After fetching the registry's servers_url, the library checks `response.ok`. Any non-2xx HTTP status (404, 500, 401, etc.) causes this error, with the statusText embedded in the message. It indicates the remote registry endpoint was reachable but rejected or failed the request.

Source

Thrown at packages/mcp-registry-registry/src/registry/fetch-servers.ts:26

  try {
    // Find the registry in our registry data
    const registry = registryData.registries.find(r => r.id === registryId);

    if (!registry) {
      throw new Error(`Registry with ID "${registryId}" not found.`);
    }

    if (!registry.servers_url) {
      throw new Error(`Registry "${registry.name}" does not have a servers endpoint.`);
    }

    console.info(`Fetching servers from ${registry.name} at ${registry.servers_url}`);

    // Fetch the servers from the registry's servers_url
    const response = await fetch(registry.servers_url);

    if (!response.ok) {
      throw new Error(`Failed to fetch servers from ${registry.servers_url}: ${response.statusText}`);
    }

    const data = (await response.json()) as unknown;

    // If the registry has a custom post-processing function, use it
    if (registry.postProcessServers) {
      console.info(`Using custom post-processor for ${registry.name}`);
      return registry.postProcessServers(data);
    }

    throw new Error(`No post-processor found for registry ${registry.name}`);
  } catch (error) {
    console.error('Error fetching servers:', error);
    throw error;
  }
}

/**

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Check response.statusText in the message to identify the HTTP failure (404 = wrong URL, 401/403 = auth, 5xx = server issue)
  2. Verify `servers_url` is correct and reachable (curl it directly)
  3. If the endpoint requires auth, ensure the registry is configured to send credentials/headers
  4. Retry later if the remote registry is temporarily down

Example fix

// before
registry: { name: 'acme', servers_url: 'https://acme.example.com/mcp' }
// after (verify/fix URL and add auth if needed)
registry: { name: 'acme', servers_url: 'https://acme.example.com/api/v1/mcp/servers', headers: { Authorization: `Bearer ${token}` } }
Defensive patterns

Strategy: retry

Validate before calling

const res = await fetch(registry.servers_url, { method: 'HEAD' });
if (!res.ok) console.warn(`Registry endpoint unhealthy: ${res.status} ${res.statusText}`);

Try / catch

try {
  await registryManager.fetchServersFromRegistry({ registryId });
} catch (err) {
  if (err instanceof Error && err.message.includes('Failed to fetch servers')) {
    await new Promise(r => setTimeout(r, backoffMs));
    // retry with exponential backoff, capped attempts
  } else throw err;
}

Prevention

When it happens

Trigger: fetchServersFromRegistry performs `fetch(registry.servers_url)` and the server responds with a non-OK HTTP status — e.g. wrong URL path, registry server down, auth required, rate limiting.

Common situations: Registry endpoint URL is stale or mistyped; remote registry service is down or returning 5xx; endpoint requires authentication headers that are not being sent; corporate proxy/firewall returning error pages.

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 mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/6c362b97db48aa8d. Report an issue: GitHub.