LearnNewsExamplesServices
Frontmatter
id7494
titleImplement Zod-based Validation with JSON Schema Conversion
stateClosed
labels
enhancementai
assigneestobiu
createdAtOct 15, 2025, 1:43 PM
updatedAtOct 15, 2025, 1:48 PM
githubUrlhttps://github.com/neomjs/neo/issues/7494
authortobiu
commentsCount0
parentIssue7477
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtOct 15, 2025, 1:48 PM

Implement Zod-based Validation with JSON Schema Conversion

Closed v11.0.0 enhancementai
tobiu
tobiu commented on Oct 15, 2025, 1:43 PM

To implement MCP input validation correctly, we must use zod. The core challenge is that the inputSchema returned by the tools/list discovery endpoint must be a JSON-serializable object, while the actual validation requires a live zod schema object.

This ticket covers the refactoring of the tool service to manage both schema types: the zod schema for server-side validation and its JSON Schema representation for client-facing discovery.

Acceptance Criteria

  1. The zod and zod-to-json-schema packages are added as dependencies to package.json.
  2. toolService.mjs is refactored to generate a zod schema for each tool's input based on the openapi.yaml file.
  3. The service then converts the zod schema to a standard JSON Schema object using zod-to-json-schema.
  4. The listTools function is updated to return the plain JSON Schema object in the inputSchema field of each tool.
  5. The callTool function is updated to use the internal zod schema to validate arguments via .parse() before executing the tool handler.
tobiu assigned to @tobiu on Oct 15, 2025, 1:43 PM
tobiu added parent issue #7477 on Oct 15, 2025, 1:43 PM
tobiu added the enhancement label on Oct 15, 2025, 1:43 PM
tobiu added the ai label on Oct 15, 2025, 1:43 PM
tobiu referenced in commit 16c8961 - "Implement Zod-based Validation with JSON Schema Conversion #7494" on Oct 15, 2025, 1:47 PM
tobiu closed this issue on Oct 15, 2025, 1:48 PM