-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Zodios Validation Errors in MCP Tools #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Zodios Validation Errors in MCP Tools #465
Conversation
There was a problem hiding this 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 fixes Zodios validation errors in MCP tools by implementing error handling for cases where HTTP requests succeed (200 OK) but schema validation fails. The solution adds a new utility function to extract response data from validation errors and enhances Zod schemas with missing properties and comparators.
- Introduces
handleZodiosValidationErrorsutility to gracefully handle validation failures - Updates Zod schemas to include missing properties (
_audiences,filters,bucketingKey) and new comparators (startWith,endWith) - Adds environment variables to control output schema behavior and debug logging
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mcp/utils/api.ts | Adds handleZodiosValidationErrors utility and removes debug logging |
| src/ui/targetingTree.ts | Adds missing string comparators to support new filter types |
| src/api/zodClient.ts | Enhances Zod schemas with missing properties and comparators |
| src/mcp/server.ts | Adds environment controls for output schemas and debug logging |
| src/api/apiClient.ts | Fixes TypeScript type inference issues with explicit type annotations |
| src/mcp/tools/*.ts | Wraps API calls with validation error handling across all tool files |
Comments suppressed due to low confidence (1)
src/api/apiClient.ts:114
- [nitpick] The variable name '_createApiClient' with underscore prefix suggests it's private, but it's just an alias. Consider a more descriptive name like 'createApiClientFn' or 'apiClientFactory'.
const _createApiClient = createApiClient
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
Fix Zodios Validation Errors in MCP Tools
Problem
MCP tools were failing with "Zodios: Invalid response from endpoint" errors despite successful HTTP 200 API responses. Schema validation failed due to missing properties, type mismatches, and incomplete comparator enums in Zod schemas.
Solution
Core Changes
handleZodiosValidationErrorsutility - Extracts response data from validation errors when HTTP succeeds but schema validation fails_audiences,startWith/endWithcomparators)ENABLE_OUTPUT_SCHEMASas they don't working Curosr andENABLE_DVC_MCP_DEBUGfor debug logs.