Number parameters fail validation - need z.coerce.number() instead of z.number() #879
Replies: 9 comments
-
|
Actually now that I dig deeper it looks like this affects other areas in the code too? |
Beta Was this translation helpful? Give feedback.
-
|
We can take a look, but we have not had anyone else report an issue. Can you post the toolname and the json of the request that LLM is making so we can try and reproduce? |
Beta Was this translation helpful? Give feedback.
-
|
Reproduction - tool name + JSON request: Tool: Request JSON sent by LLM: {
"project": "MyProject",
"buildId": "12345"
}Error: The issue is that MCP transports frequently serialize parameter values as strings. When the LLM calls a tool with Comparison - dates already handle this correctly: Full list of affected parameters across the codebase:
All of these should be Sources describing this:
|
Beta Was this translation helpful? Give feedback.
-
|
We will keep an eye on this. So far, we have not had anyone else report this as an issue. So, we are hesitant on just making a change. If we get others reporting the same problem, we can take a deeper look. I will keep the Issue open for a while. |
Beta Was this translation helpful? Give feedback.
-
|
Understandable, running a local modified version for now anyways. Thanks for your consideration. |
Beta Was this translation helpful? Give feedback.
-
|
Bah. Now it's back. I do see this, I somewhat corrected it with these rules I can't figure out why it needs to spell it out 🤷 Azure devops Server MCP (ado)
Note despite rule 1, claude still gets confused by the requirement and I still see stuff like this mixed, I don't know that it's really your problem claude seems to be SUPER dumb in this way, but it'd be nice if it accepted the string version ado - wit_link_work_item_to_pull_request (MCP)(project: "", workItemId: "1522", pullRequestId: "79898", |
Beta Was this translation helpful? Give feedback.
-
|
Example of claude failing, thinking and then getting it right: ● ado - wit_update_work_item (MCP)(id: "1557", project: "Sandbox", title: "[AI-CO45] - Thing3: [COG-2092-NetworkMap] epic:[COG-2092] - Create Network Map") ● ado - wit_update_work_item (MCP)(id: 1557, updates: [{"path":"/fields/System.Title","value":"[AI-CO45] - Thing3: |
Beta Was this translation helpful? Give feedback.
-
|
4.6 is better at this, but still has the odd issue 🤷 |
Beta Was this translation helpful? Give feedback.
-
|
I had this issue with Claude Code. All tool invocations failed with the error re: a number being expected but a string being passed. I repeatedly asked Claude to pass the parameter as a number rather than a string but it told me that it was passing a number and there was a problem in the MCP layer converting it to a string. The above feedback indicates this can't be true if it sometimes works. Regardless, Claude proposed making a fix to the MCP package locally - the one described in the original issue - which it did and I've had no issues since that's been done. It added this note to my prompt, so the change can be re-applied if a new version of the package is retrieved: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Tools with numeric parameters fail with "Expected number, received string" because Zod schemas use z.number() instead of z.coerce.number(). MCP protocol
serializes all values as strings.
Root Cause
In src/tools/pipelines.ts, numeric parameters use strict validation:
buildId: z.number() // ❌ fails on string input
But date parameters correctly use coercion:
minMetricsTime: z.coerce.date() // ✅ handles string input
Fix
Replace z.number() with z.coerce.number() for all numeric parameters.
Affected Tools
All pipeline tools with buildId, logId, pipelineId, runId, etc.
Beta Was this translation helpful? Give feedback.
All reactions