Skip to content

fix: reorder variation variable union types and improve MCP descriptions for correct JSON typing#559

Open
jonathannorris wants to merge 1 commit intomainfrom
fix-mcp-variation-variable-types
Open

fix: reorder variation variable union types and improve MCP descriptions for correct JSON typing#559
jonathannorris wants to merge 1 commit intomainfrom
fix-mcp-variation-variable-types

Conversation

@jonathannorris
Copy link
Member

Summary

  • Reorder Zod union types for variation variables to put boolean and number before string across all 5 variation schemas
  • Add explicit descriptions to MCP tool schemas telling AI models to use native JSON types for variable values

Motivation

Users reported that creating/updating features with boolean variation variables via MCP fails with:

Expected type of value for variable to be Boolean, but received String

The root cause is that AI models send "true" (string) instead of true (boolean) when calling the MCP tools. No serialization bug exists in our code — the issue is AI model behavior. Our Zod validation accepts "true" because z.string() matches before z.boolean() is tried, so the error only surfaces when the DevCycle API rejects the request.

Changes

src/api/zodSchemas.ts — Reordered union from [string, number, boolean, ...] to [boolean, number, string, ...] in CreateVariationDto, Variation, UpdateVariationDto, FeatureVariationDto, and UpdateFeatureVariationDto. This changes the anyOf order in the advertised JSON Schema. It's a loose theory that having string first in anyOf influences models to default to string encoding — worth trying but not guaranteed to fix the issue on its own.

src/mcp/types.ts — Enhanced descriptions on CreateFeatureArgsSchema.variations, UpdateFeatureArgsSchema.variations, and the shared variablesDescription used by standalone variation tools. Descriptions now explicitly state to use native JSON types with examples. This is likely the more impactful change since models tend to follow explicit instructions in tool descriptions.

@jonathannorris jonathannorris requested a review from a team as a code owner March 12, 2026 19:45
Copilot AI review requested due to automatic review settings March 12, 2026 19:45
@jonathannorris jonathannorris force-pushed the fix-mcp-variation-variable-types branch from 8c880e9 to 90ad2e5 Compare March 12, 2026 19:45
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 12, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
devcycle-mcp-server 33c2e65 Mar 12 2026, 07:53 PM

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the advertised JSON Schema / MCP tool documentation for variation variables to better steer MCP tool callers toward using native JSON booleans/numbers (instead of string-encoding), addressing user-reported failures when the DevCycle API expects typed variable values.

Changes:

  • Reorders the Zod union member ordering for variation variables across multiple variation DTOs (to change anyOf ordering in generated JSON Schema).
  • Expands MCP tool argument descriptions to explicitly instruct using native JSON types (with examples) when populating variation variables.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/mcp/types.ts Updates tool argument descriptions for variations/variables to explicitly request native JSON typing and provide examples.
src/api/zodSchemas.ts Reorders union type members for variation variables to prioritize boolean/number before string in generated schema output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jonathannorris jonathannorris force-pushed the fix-mcp-variation-variable-types branch from 90ad2e5 to 33c2e65 Compare March 12, 2026 19:51
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.

3 participants