t3code icon indicating copy to clipboard operation
t3code copied to clipboard

fix(mcp): unblock Kimi models in OpenCode with preview tools

Open hwanseoc opened this issue 4 months ago • 3 comments

I ran into OpenCode failing every turn with Kimi K3 when T3 Code exposed the preview_navigate MCP tool.

It was caused by the shared URL validator and the concrete field each adding a different description. Effect emitted both in allOf, and Kimi rejects them when flattening the schema.

The fix is to keep BoundedUrl validation-only and merge the shared URL guidance into each concrete field description. Effect changes the generated schema from:

{
  "type": "string",
  "allOf": [
    {
      "pattern": "^\\S[\\s\\S]*\\S$|^\\S$|^$"
    },
    {
      "minLength": 1,
      "description": "Absolute http(s) URL or a schemeless host such as t3.chat or localhost:5173. Schemeless public hosts use https; loopback hosts use http."
    },
    {
      "maxLength": 2048,
      "description": "Direct website URL."
    }
  ]
}

to:

{
  "type": "string",
  "allOf": [
    {
      "pattern": "^\\S[\\s\\S]*\\S$|^\\S$|^$"
    },
    {
      "minLength": 1
    },
    {
      "maxLength": 2048,
      "description": "Direct website URL. Absolute http(s) URL or a schemeless host such as t3.chat or localhost:5173. Schemeless public hosts use https; loopback hosts use http."
    }
  ]
}

minLength, maxLength, and URL validation are unchanged. Only the descriptions are consolidated. Tested with vp test run apps/server/src/mcp/toolkits/preview/tools.test.ts.


Open in Devin Review

[!NOTE] Low Risk Contract/schema annotation only; URL validation is unchanged and coverage is added for preview_navigate schema shape.

Overview Fixes OpenCode failures with Kimi K3 when preview_navigate (and related preview MCP tools) expose URL fields whose Effect JSON schema had more than one description inside allOf. Kimi rejects that shape when flattening tool schemas.

BoundedUrl is now validation-only (trim, non-empty, max length) with no description on the shared isNonEmpty() check. Shared URL format guidance lives in URL_GUIDANCE and is inlined into each concrete field description on PreviewAutomationOpenInput, PreviewAutomationNavigateInput, and BrowserNavigationTarget URL fields.

A regression test in tools.test.ts asserts preview_navigate never emits schemas with multiple described allOf members. URL validation rules are unchanged; only how descriptions are attached to the generated JSON schema.

Reviewed by Cursor Bugbot for commit 63628e64d89c113ae14b92ae5884ac1d9dd6639c. Bugbot is set up for automated code reviews on this repo. Configure here.

[!NOTE]

Fix Kimi model compatibility by removing multiple allOf descriptions from preview_navigate schema

  • Moves URL format guidance into a shared URL_GUIDANCE constant and inlines it into the url field descriptions for PreviewAutomationNavigateInput, PreviewAutomationOpenInput, and BrowserNavigationTarget in previewAutomation.ts.
  • Removes the description from the BoundedUrl isNonEmpty() check to avoid generating multiple described allOf members in the compiled JSON schema, which Kimi models reject.
  • Adds a schemaHasMultipleAllOfDescriptions helper in tools.test.ts and asserts that preview_navigate never produces such a schema.

Macroscope summarized 63628e6.

hwanseoc avatar Jul 31 '26 15:07 hwanseoc

[!IMPORTANT]

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 521f0b75-0959-4bfa-8d0c-ecc0b553fb33

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jul 31 '26 15:07 coderabbitai[bot]

Approvability

Verdict: Approved a9be6ba

This PR restructures schema descriptions to avoid duplicate descriptions in allOf arrays, fixing compatibility with certain AI model providers. The changes are purely metadata/documentation with no impact on runtime validation logic.

You can customize Macroscope's approvability policy. Learn more.

macroscopeapp[bot] avatar Jul 31 '26 15:07 macroscopeapp[bot]

confirmed: keeping both descriptions is semantically reasonable, but Effect emits them as separate described members inside allOf, which Kimi rejects. consolidating the shared guidance into each concrete field description is the right fix here; validation and guidance are preserved. no change requested.

t3-code-bot[bot] avatar Aug 05 '26 00:08 t3-code-bot[bot]