[PR #12815] fix(mcp): strip non-standard JSON Schema formats to suppress AJV warnings #14381

Open
opened 2026-02-16 18:19:10 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12815

State: open
Merged: No


Summary

Fixes #8581unknown format "uint64" ignored in schema warnings that spam the terminal on every startup when MCP servers (e.g. BigQuery) return schemas with non-standard JSON Schema formats.

Problem

MCP tool schemas from providers like Google BigQuery include "format": "uint64", "format": "google-datetime", etc. These are valid for the provider but not recognized by AJV (JSON Schema validator used by Vercel AI SDK's jsonSchema()), causing noisy console warnings on every tool conversion.

Call chain: MCP Server → convertMcpTool()jsonSchema() (Vercel AI SDK) → AJV v8 → warning

Solution

Added stripUnknownFormats() in packages/opencode/src/mcp/index.ts that:

  1. Defines a KNOWN_FORMATS Set with all standard JSON Schema formats (date-time, email, uri, etc.)
  2. Recursively walks the schema tree and removes format fields not in the known set
  3. Wraps inputSchema in convertMcpTool() before passing to jsonSchema()

This is a non-breaking change — it only strips format metadata that AJV cannot validate anyway, preserving all other schema properties.

Testing

  • Typecheck: tsgo --noEmit passes clean
  • Build: bun run build --single succeeds
  • Runtime: Patched binary produces zero AJV warnings with BigQuery MCP server

Related

  • Issue: Footer may have been accidentally removed? (#8581)
  • Root cause: AJV v8.17.1 warns on unregistered formats when validateFormats: false is not set
  • Alternative considered: Registering custom formats with AJV — rejected because the format values are arbitrary and provider-dependent
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12815 **State:** open **Merged:** No --- ## Summary Fixes #8581 — `unknown format "uint64" ignored in schema` warnings that spam the terminal on every startup when MCP servers (e.g. BigQuery) return schemas with non-standard JSON Schema formats. ## Problem MCP tool schemas from providers like Google BigQuery include `"format": "uint64"`, `"format": "google-datetime"`, etc. These are valid for the provider but not recognized by AJV (JSON Schema validator used by Vercel AI SDK's `jsonSchema()`), causing noisy console warnings on every tool conversion. **Call chain**: MCP Server → `convertMcpTool()` → `jsonSchema()` (Vercel AI SDK) → AJV v8 → warning ## Solution Added `stripUnknownFormats()` in `packages/opencode/src/mcp/index.ts` that: 1. Defines a `KNOWN_FORMATS` Set with all standard JSON Schema formats (`date-time`, `email`, `uri`, etc.) 2. Recursively walks the schema tree and removes `format` fields not in the known set 3. Wraps `inputSchema` in `convertMcpTool()` before passing to `jsonSchema()` This is a **non-breaking** change — it only strips format metadata that AJV cannot validate anyway, preserving all other schema properties. ## Testing - Typecheck: `tsgo --noEmit` passes clean - Build: `bun run build --single` succeeds - Runtime: Patched binary produces zero AJV warnings with BigQuery MCP server ## Related - Issue: #8581 - Root cause: AJV v8.17.1 warns on unregistered formats when `validateFormats: false` is not set - Alternative considered: Registering custom formats with AJV — rejected because the format values are arbitrary and provider-dependent
yindo added the pull-request label 2026-02-16 18:19:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14381