fix: Zodios Validation Errors in MCP Tools#465
Merged
jonathannorris merged 2 commits intochore-mcp-planning-docfrom Jul 18, 2025
Merged
fix: Zodios Validation Errors in MCP Tools#465jonathannorris merged 2 commits intochore-mcp-planning-docfrom
jonathannorris merged 2 commits intochore-mcp-planning-docfrom
Conversation
JamieSinn
reviewed
Jul 18, 2025
There was a problem hiding this comment.
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
JamieSinn
reviewed
Jul 18, 2025
JamieSinn
approved these changes
Jul 18, 2025
jonathannorris
added a commit
that referenced
this pull request
Jul 23, 2025
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
jonathannorris
added a commit
that referenced
this pull request
Jul 25, 2025
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
jonathannorris
added a commit
that referenced
this pull request
Aug 11, 2025
* fix: Zodios Validation Errors in MCP Tools * chore: cleanup TS comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.