deepseek-ai/deepseek-harness · error

the declared media type is not PNG, JPEG, WebP, or GIF

Error message

the declared media type is not PNG, JPEG, WebP, or GIF

What it means

Image-admission guard for MCP tool results: a content block declared an image media type outside the supported PNG/JPEG/WebP/GIF vocabulary. Untrusted server output is narrowed to the durable image types the attachment store accepts; anything else is refused rather than stored.

Solutions

  1. Convert the image to PNG, JPEG, WebP, or GIF and fix the declared media type.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/mcp/mcp-client/src/tools.ts:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/367b1fb4a6de402e. Report an issue: GitHub.

Appendix: source

Thrown at packages/mcp/mcp-client/src/tools.ts:381

/** Whether an untrusted MCP content array contains a declared image block. */
function containsImage(content: JsonValue[]): boolean {
  return content.some(value => isRecord(value) && value.type === 'image')
}

/** Narrow one JSON value to a string-keyed object. */
function isRecord(value: JsonValue): value is { [key: string]: JsonValue } {
  return typeof value === 'object' && value !== null && !Array.isArray(value)
}

/** Narrow a declared MIME string to the durable image vocabulary. */
function isImageMediaType(value: string): value is ImageMediaType {
  return IMAGE_MEDIA_TYPES.includes(value as ImageMediaType)
}

/** Decode one untrusted MCP image block without accepting base64 aliases. */
function decodeImage(block: McpContentBlock): SaveImageAttachment {
  if (block.mimeType === undefined || !isImageMediaType(block.mimeType)) {
    throw new Error('the declared media type is not PNG, JPEG, WebP, or GIF')
  }
  if (block.data === undefined || !CANONICAL_BASE64.test(block.data)) {
    throw new Error('the image data is not canonical base64')
  }
  const data = Buffer.from(block.data, 'base64')
  if (data.toString('base64') !== block.data) {
    throw new Error('the image data is not canonical base64')
  }
  return { data, mediaType: block.mimeType }
}

/**
 * Resolve the active model route and durable store for an image-bearing result.
 * @param ctx - plugin context with optional services.
 * @param exec - exact tool execution whose agent supplies the latest route.
 * @returns the attachment store after exact positive image-capability proof.
 */
async function resolveImageAdmission(ctx: Context, exec: ToolExecution): Promise<AttachmentStore> {

View on GitHub (pinned to b150a551b8)