Skip to content

MCP tool attachments missing id/sessionID/messageID fields causes Zod validation failure #14355

@NatChung

Description

@NatChung

Description

MCP tool results (e.g., Playwright take_screenshot) return attachments without id, sessionID, and messageID fields, causing downstream Zod validation failure on MessageV2.FilePart.

Steps to Reproduce

  1. Configure an MCP server (e.g., Playwright MCP)
  2. Use a tool that returns file attachments (e.g., take_screenshot)
  3. The attachment is missing id, sessionID, and messageID fields
  4. Zod parse error occurs and the tool result is lost

Expected Behavior

MCP tool attachments should include id, sessionID, and messageID fields, consistent with built-in tool attachments.

Actual Behavior

The MCP tool path in prompt.ts explicitly omits these fields (Omit<MessageV2.FilePart, "id" | "sessionID" | "messageID"> at L874), while built-in tools correctly map them (L808-814).

Additional Context

Built-in tools already have the correct mapping at packages/opencode/src/session/prompt.ts lines 808-814. The fix is to apply the same .map() to MCP tool attachments.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions