modelcontextprotocol/servers · error · Error

Unknown outputType: ${outputType}

Error message

Unknown outputType: ${outputType}

What it means

Thrown by the `gzip-file-as-resource` tool when `outputType` is neither `"resource"` nor `"resourceLink"`. The zod schema (`z.enum(["resourceLink","resource"]).default("resourceLink")`) makes this effectively unreachable for SDK-routed calls; the branch is a defensive exhaustiveness check.

Source

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

      blob
    );

    // Return the resource or a resource link that can be used to access this resource later
    if (outputType === "resource") {
      return {
        content: [
          {
            type: "resource",
            resource: { uri, mimeType, blob },
          },
        ],
      };
    } else if (outputType === "resourceLink") {
      return {
        content: [resourceLink],
      };
    } else {
      throw new Error(`Unknown outputType: ${outputType}`);
    }
  });
};

/**
 * Validates a given data URI to ensure it follows the appropriate protocols and rules.
 *
 * @param {string} dataUri - The data URI to validate. Must be an HTTP, HTTPS, or data protocol URL. If a domain is provided, it must match the allowed domains list if applicable.
 * @return {URL} The validated and parsed URL object.
 * @throws {Error} If the data URI does not use a supported protocol or does not meet allowed domains criteria.
 */
function validateDataURI(dataUri: string): URL {
  // Validate Inputs
  const url = new URL(dataUri);
  try {
    if (
      url.protocol !== "http:" &&
      url.protocol !== "https:" &&

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Omit `outputType` (defaults to `"resourceLink"`) or pass one of the two enum values.
  2. If extending output types, update the zod enum AND the if/else chain together.
  3. In tests, construct args via `GZipFileAsResourceSchema.parse(...)` to mirror real routing.

Example fix

// before
toolHandler({ outputType: 'json' });
// after
toolHandler({ outputType: 'resource' });
Defensive patterns

Strategy: type-guard

Validate before calling

// schema already constrains to the enum; rely on routing
const args = GZipFileAsResourceSchema.parse(rawArgs);

Type guard

function isOutputType(v: unknown): v is 'resource' | 'resourceLink' {
  return v === 'resource' || v === 'resourceLink';
}

Prevention

When it happens

Trigger: Directly invoking the tool handler with a manually-crafted args object whose `outputType` is a third value, or a future schema change that adds an enum member without updating the if/else chain.

Common situations: Unit tests bypassing zod, refactors that widen the enum without updating the conditional, or downstream forks adding new output shapes.

Related errors


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