modelcontextprotocol/servers · error · Error

Error processing file ${dataUri}: ${error instanceof Error ?

Error message

Error processing file ${dataUri}: ${error instanceof Error ? error.message : String(error)}

What it means

A wrapper error thrown by the `catch` block of `validateDataURI`. Any inner error (unsupported protocol, disallowed domain, or a URL-parse failure inside the try) is re-thrown with this prefixed message that includes the original `dataUri` and the inner error's message. It exists to give a single, consistent error shape for all data-URI validation failures.

Source

Thrown at src/everything/tools/gzip-file-as-resource.ts:161

    ) {
      throw new Error(
        `Unsupported URL protocol for ${dataUri}. Only http, https, and data URLs are supported.`
      );
    }
    if (
      GZIP_ALLOWED_DOMAINS.length > 0 &&
      (url.protocol === "http:" || url.protocol === "https:")
    ) {
      const domain = url.hostname;
      const domainAllowed = GZIP_ALLOWED_DOMAINS.some((allowedDomain) => {
        return domain === allowedDomain || domain.endsWith(`.${allowedDomain}`);
      });
      if (!domainAllowed) {
        throw new Error(`Domain ${domain} is not in the allowed domains list.`);
      }
    }
  } catch (error) {
    throw new Error(
      `Error processing file ${dataUri}: ${
        error instanceof Error ? error.message : String(error)
      }`
    );
  }
  return url;
}

/**
 * Fetches data safely from a given URL while ensuring constraints on maximum byte size and timeout duration.
 *
 * @param {URL} url The URL to fetch data from.
 * @param {Object} options An object containing options for the fetch operation.
 * @param {number} options.maxBytes The maximum allowed size (in bytes) of the response. If the response exceeds this size, the operation will be aborted.
 * @param {number} options.timeoutMillis The timeout duration (in milliseconds) for the fetch operation. If the fetch takes longer, it will be aborted.
 * @return {Promise<ArrayBuffer>} A promise that resolves with the response as an ArrayBuffer if successful.
 * @throws {Error} Throws an error if the response size exceeds the defined limit, the fetch times out, or the response is otherwise invalid.
 */

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Read the inner message embedded in the wrapper text — it identifies the actual cause (protocol or domain).
  2. Fix the underlying issue per errors 7 or 8 (use a supported protocol; allowlist the domain).
  3. If your URL is malformed, ensure it parses with `new URL()` under a supported scheme before calling the tool.

Example fix

// the wrapper surfaces the real cause; fix the root issue
// before: data uses 'file://'  -> wrapper: "Error processing file file:///x: Unsupported URL protocol..."
// after:  data uses 'https://' -> no error
Defensive patterns

Strategy: try-catch

Validate before calling

function validateDataUriClient(s: string): URL | Error {
  try {
    const u = new URL(s);
    if (!['http:','https:','data:'].includes(u.protocol)) return new Error('protocol');
    // domain check mirroring server rules omitted for brevity
    return u;
  } catch (e) { return e as Error; }
}

Try / catch

try {
  await callGzipTool({ data: url });
} catch (e) {
  const msg = e instanceof Error ? e.message : String(e);
  if (msg.startsWith('Error processing file')) {
    // inner cause is embedded in the message text
    const cause = msg.split(':').slice(2).join(':').trim();
    // branch on cause: protocol vs domain vs parse
  }
}

Prevention

When it happens

Trigger: Any failure inside `validateDataURI`'s try block: unsupported protocol (error 7), disallowed domain (error 8), or a thrown `TypeError` from `new URL()` — although note `new URL()` runs before the try, so the most common inner causes are the protocol and domain throws.

Common situations: Operators see this wrapper instead of the specific cause when reading logs; the inner message is preserved in the text. Common when chaining multiple validation rules and the first to fail is wrapped generically.

Related errors


AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12). Data as JSON: /api/errors/a787831735594ad8. Report an issue: GitHub.