mastra-ai/mastra · error · HTTPException

Version with id ${to} not found for MCP client ${mcpClientId

Error message

Version with id ${to} not found for MCP client ${mcpClientId}

What it means

The 'to' version exists but belongs to a different MCP client than the one in the path, so the handler throws a 404 scoped to the client. Cross-client comparisons are rejected.

Source

Thrown at packages/server/src/server/handlers/mcp-client-versions.ts:478

      const mcpClient = await mcpClientStore.getById(mcpClientId);
      assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));

      const fromVersion = await mcpClientStore.getVersion(from);
      if (!fromVersion) {
        throw new HTTPException(404, { message: `Version with id ${from} not found` });
      }
      if (fromVersion.mcpClientId !== mcpClientId) {
        throw new HTTPException(404, {
          message: `Version with id ${from} not found for MCP client ${mcpClientId}`,
        });
      }

      const toVersion = await mcpClientStore.getVersion(to);
      if (!toVersion) {
        throw new HTTPException(404, { message: `Version with id ${to} not found` });
      }
      if (toVersion.mcpClientId !== mcpClientId) {
        throw new HTTPException(404, {
          message: `Version with id ${to} not found for MCP client ${mcpClientId}`,
        });
      }

      const fromConfig = extractConfigFromVersion(
        fromVersion as unknown as Record<string, unknown>,
        MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,
      );
      const toConfig = extractConfigFromVersion(
        toVersion as unknown as Record<string, unknown>,
        MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,
      );

      const diffs = computeVersionDiffs(fromConfig, toConfig);

      return {
        diffs,
        fromVersion,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Use a to id owned by the path's mcpClientId.
  2. Refetch version lists per client before building compare requests.
  3. If cross-client comparison is truly needed, fetch both clients' configs and diff them client-side.
Defensive patterns

Strategy: validation

Validate before calling

const to = versions.find(v => v.id === toId);
if (to?.mcpClientId !== clientId) throw new Error('to version belongs to a different MCP client');

Try / catch

try { await compare(from, to); } catch (e) { if (e.status === 404 && /not found for MCP client/.test(e.message)) { /* correct client scope */ } else throw e; }

Prevention

When it happens

Trigger: GET /stored/mcp-clients/:mcpClientId/versions/compare?from=<id>&to=<id> where to belongs to another MCP client (from matched correctly).

Common situations: Aggregate scripts comparing 'latest of client A' vs 'latest of client B'; dashboard widgets caching to-ids from other clients; partially edited URL query strings.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/eca0b5472f454cfc. Report an issue: GitHub.