Skip to content

fix(opencode): sanitize unknown MCP schema formats before jsonSchema() - #20747

Closed
sureshpatel66 wants to merge 1 commit into
anomalyco:devfrom
sureshpatel66:fix/mcp-schema-unknown-formats
Closed

sureshpatel66 wants to merge 1 commit into
anomalyco:devfrom
sureshpatel66:fix/mcp-schema-unknown-formats

Conversation

@sureshpatel66

@sureshpatel66 sureshpatel66 commented Apr 2, 2026 •

Copy link
Copy Markdown

Summary

Strip nonstandard JSON Schema format values from MCP tool input schemas before passing them to ai/jsonSchema().

What changed

  • add stripUnknownFormats() helper for MCP schemas
  • sanitize unknown format values before jsonSchema(...)
  • add regression tests for unknown and standard formats

Why

Some MCP providers return nonstandard schema formats such as uint64, google-datetime, and path, which trigger AJV warnings. This keeps standard format validation while removing unsupported provider-specific format annotations.

Testing

  • bun test test/mcp/schema.test.ts
  • bun run typecheck
  • bun run build

Fixes #20749

@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title sanitize unknown MCP schema formats before jsonSchema() doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@sureshpatel66 sureshpatel66 changed the title sanitize unknown MCP schema formats before jsonSchema() fix(opencode): sanitize unknown MCP schema formats before jsonSchema() Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@sureshpatel66

Copy link
Copy Markdown
Author

Linked issue added: Fixes #20749.

For CI context: the remaining failing check is unit (linux), and its log points to test/memory/abort-leak.test.ts (memory: abort controller leak > webfetch does not leak memory over many invocations). This appears unrelated to the MCP schema-format sanitizer changes in this PR.

I ran the targeted checks locally on this branch:

  • bun test test/mcp/schema.test.ts
  • bun run typecheck
  • bun run build
  • bun test test/memory/abort-leak.test.ts (passes locally)

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 2, 2026
@github-actions github-actions Bot closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode warns on nonstandard MCP schema formats before jsonSchema()

1 participant