Skip to content

Use a discriminated-union Zod schema for retrieve_file operations #118

@bharatsachya

Description

@bharatsachya

Type: refactor · Difficulty: medium

retrieve_file enforces per-operation required fields with runtime throw inside dispatch (packages/mcp/src/retrieveFileTool.ts:111,119,122,133) rather than in the Zod schema (:39). So MCP clients get no schema-level signal that metadata needs relativePaths, content needs relativePath, bulk_search needs paths+search.

Do: model the input as a Zod discriminated union keyed on operation (or superRefine) so required fields per operation are declared in the schema.

Done when: invalid operation payloads are rejected by the schema; the runtime throws become redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions