Skip to content

fix(mcp): fix caret misalignment and tool schema contract validation#5566

Merged
waleedlatif1 merged 7 commits into
stagingfrom
worktree-fix-mcp-modal-caret
Jul 10, 2026
Merged

fix(mcp): fix caret misalignment and tool schema contract validation#5566
waleedlatif1 merged 7 commits into
stagingfrom
worktree-fix-mcp-modal-caret

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Fix MCP server form modal caret drifting from typed text in the Server URL and Header fields (font-weight mismatch between the ghost input and its formatted overlay)
  • Fix "Response failed contract validation" crash on the MCP tools page when a real MCP server returns a tool schema with array-form items (tuple validation) or non-primitive enum values — the contract's property schema was stricter than valid JSON Schema

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The Server URL and Header fields render a transparent input under a
formatted overlay div for env-var highlighting. The overlay used
font-medium/font-sans but the real input didn't, so glyph widths
diverged and the native caret drifted from the visible text as you
typed.
discoverMcpToolsContract's property schema rejected legal JSON Schema
that real MCP servers can return: array-form `items` (tuple
validation) and non-primitive `enum` values. Any server exercising
either shape failed contract validation client-side and blanked the
entire MCP tools list.
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 10, 2026 7:42pm

Request Review

@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI typography fix and looser schema validation plus safer parameter editing; no auth, persistence, or execution-path changes.

Overview
Fixes caret drift in the MCP server form URL/header fields by giving the transparent ChipInput the same font-medium font-sans styling as the formatted overlay, so typed text and the caret line up with the visible env-var highlighting.

Stops “Response failed contract validation” on MCP tool discovery when servers return valid but richer JSON Schema: Zod/types now allow items as a single schema or an array (tuple form) and enum members as arbitrary JSON values, not only primitives.

In workflow MCP tool args, non-primitive enum values no longer use the dropdown (which would show [object Object]); they use the long JSON editor instead, with stringify/parse so object/array parameters and complex enums store real JSON values.

Reviewed by Cursor Bugbot for commit a6d48f8. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes MCP form input rendering and broadens MCP tool schema handling.

  • Aligns the MCP server form caret with formatted overlay text.
  • Accepts tuple-style array items in MCP tool schemas.
  • Accepts arbitrary JSON values in MCP schema enum entries.
  • Routes non-primitive enum and JSON-shaped arguments through the long JSON editor.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/mcp/components/mcp-server-form-modal/mcp-server-form-modal.tsx Aligns the transparent input font with the formatted overlay used in the MCP server form.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-dynamic-args/mcp-dynamic-args.tsx Adds enum shape detection and parses JSON-backed long-input values before storing them.
apps/sim/lib/api/contracts/mcp.ts Widens MCP tool property validation for tuple items and arbitrary JSON enum members.
apps/sim/lib/mcp/types.ts Updates MCP schema property types to match the widened API contract.

Reviews (5): Last reviewed commit: "fix(mcp): parse JSON-typed long-input ed..." | Re-trigger Greptile

Comment thread apps/sim/lib/api/contracts/mcp.ts
The MCP dynamic-args dropdown stringifies enum members for its
labels/values. Now that the tool schema contract accepts
non-primitive enum members (object/array), routing those through the
dropdown would collapse distinct values to "[object Object]" and
submit that string as the tool argument. Gate the dropdown on
primitive-only enums; non-primitive enums fall through to the
existing type-based branching (the JSON long-input editor for
object/array types), which round-trips arbitrary JSON correctly.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 54f7326. Configure here.

…type

isPrimitiveEnum() correctly excluded object/array enum members from
the dropdown, but the fallback only reached the long-input JSON
editor when paramSchema.type was 'array'. An object-typed (or
untyped) param with a non-primitive enum fell through to the default
short-input, which stringifies via toString() and drops the
enum-membership guarantee entirely. Any non-primitive enum now routes
straight to long-input, independent of the declared type.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

…nput editor

The long-input JSON editor received value={value || ''} unconditionally,
so an argument already holding a parsed object/array (loaded from the
block's JSON arguments field) rendered as "[object Object]" or a
comma-joined list instead of valid JSON, and saving would overwrite the
real value with that mangled text. Serialize non-string values with
JSON.stringify before display; onChange still stores the raw text the
user edits, unchanged.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8822d45. Configure here.

The long-input editor's onChange always stored the raw typed text, so
a param whose schema requires an object/array/non-primitive-enum value
(e.g. entering {"mode":"strict"}) was persisted as a string, not the
actual JSON value — the MCP tool call could receive the wrong type.
requiresJsonValue() identifies these schemas; onChange now parses the
edited text back into the real value once it's valid JSON, falling
back to the raw string mid-edit so the controlled textarea keeps
reflecting in-progress keystrokes.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a6d48f8. Configure here.

@waleedlatif1 waleedlatif1 merged commit f0d85cb into staging Jul 10, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-fix-mcp-modal-caret branch July 10, 2026 19:54
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.

1 participant