Skip to content

Extract Reusable Zod Schema Constants for MCP Tools #37

Description

@foxintheloop

Problem

apps/mcp-server/src/tools/tasks.ts duplicates field definitions across createTaskSchema, updateTaskSchema, and bulkCreateTasksSchema (effort_score, impact_score, urgency_score, importance_score, energy_required, etc.).

Solution

  1. Extract reusable schema constants: idSchema, dateSchema, scoreSchema, energySchema
  2. Use .pick() / .extend() / .partial() for schema variants instead of redefining fields
  3. Add .max() limits on all string fields (title: 500, notes: 10000)
  4. Add regex validation for date (YYYY-MM-DD) and time (HH:MM) fields
  5. Add cross-field validation with .refine() (e.g., due_time requires due_date)

Files

  • apps/mcp-server/src/tools/tasks.ts — refactor schemas
  • apps/mcp-server/src/tools/goals.ts — refactor schemas
  • Consider apps/mcp-server/src/schemas.ts for shared schema constants

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions