Skip to content

Pass numeric limits and array item values of tool schemas to clients - #1470

Merged
helpcodeai merged 2 commits into
mainfrom
fix/schema-bounds-to-clients
Nov 3, 2026
Merged

helpcodeai merged 2 commits into
mainfrom
fix/schema-bounds-to-clients

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

Tool arguments are registered as a Zod shape built from the tool's JSON Schema. Numbers became a plain z.number() and arrays z.array(z.any()), so minimum/maximum and an array's allowed values never reached the client's tool list and were never checked. The model then sent values the vendor refuses or that our own limits cut.

Cloud, 11-02 08:00 to 11-03 08:00 UTC:

  • Telegram get_updates with timeout 30 (schema maximum 25): 4 calls cut by the 30 s call limit.
  • Etsy etsy_get_listing includes with Inventory, which the schema does not allow: 8 errors in 5 workspaces.
  • Apify waitSecs above its maximum of 45: 1.

Changes

  • tool-schema.util.ts: numbers keep minimum, maximum, exclusiveMinimum and exclusiveMaximum (numeric values only); an array whose items lists allowed strings keeps that list. Everything else stays as before.
  • The limits show up in the listed JSON Schema, and a call outside them gets a validation error naming the limit instead of a vendor error or a timeout.

Type

  • Bug fix

Testing

  • Added/updated unit tests: tool-schema.util.spec.ts, 5 new cases (inside the limits, outside each limit, item outside the list, limits in the listed schema, non-numeric limit ignored).
  • cd packages/backend && npx jest src/mcp-server/tool-schema.util.spec.ts: 25 passed. The full suite runs in CI.
  • Production check before the change: every successful catalog tool call of the last 3 days compared with the catalog limits (2,328 tools, 3,776 limited properties). One property would now refuse calls that succeed today: kommo_list_events limit 250 against the adapter's maximum of 100 (64 calls in one workspace). The model gets "at most 100" and calls again within the documented limit.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • All existing tests pass (CI)
  • This PR has a descriptive title

Deployment

Same in Cloud and self-hosted: it applies to every MCP server's tool registration and to the shared endpoint's argument check.

Related Issues

Found in the 2026-11-03 Cloud check.

@helpcodeai
helpcodeai merged commit bbde1ed into main Nov 3, 2026
14 checks passed
@helpcodeai
helpcodeai deleted the fix/schema-bounds-to-clients branch November 3, 2026 10:34
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant