Skip to content

Input-validation tests check inline schema copies, not the real tool schemas #99

Closed

Description

@TMHSDigital

Summary

The input-validation test suite (931 lines, about 120 tests) re-declares a copy of each tool's schema inline and tests the copy. It never imports the real schemas, so it cannot fail when a real schema changes.

Where

  • mcp-server/src/tools/__tests__/input-validation.test.ts:1-60 (the same pattern runs through the whole file). Examples: serviceLogs at :6-9, prometheusQuery at :214, nodeExec at :818.
  • Each tool file declares const inputSchema without exporting it, for example mcp-server/src/tools/serviceLogs.ts:6-17.

Details

The file imports only vitest and zod. Each describe builds its own z.object({...}). The copies also omit nodeParam, which every real tool spreads in.

Impact

  • Deleting confirmParam from a tool, or loosening .min(1), leaves every test green.
  • Release checklist item 2 in CLAUDE.md ("All new tools have input validation tests") gives false assurance.

Steps to reproduce

  1. Change mcp-server/src/tools/serviceLogs.ts:8 to service: z.string().
  2. Run npm test. Everything still passes.

Suggested fix

  • Export inputSchema from each tool. Alternatively, capture the schema at registration through a fake McpServer whose tool() records its arguments; integration.test.ts already has captureHandler.
  • Run the existing assertions against z.object(captured) and delete the inline copies.
  • Add one table-driven test over all 50 registrations that asserts:
    • every confirm-gated tool has a required boolean confirm;
    • every tool except nodeList accepts an optional node.

Acceptance criteria

  • No inline schema copies remain
  • Loosening a real schema makes a test fail

Getting started

  • Relevant files: mcp-server/src/tools/__tests__/input-validation.test.ts, integration.test.ts, mcp-server/src/tools/*.ts
  • How to run tests: cd mcp-server && npm test

Filed by repo-audit/full-audit at 9cfe5e3. Severity: medium. Effort: M. audit-key: testing|mcp-server/src/tools/__tests__/input-validation.test.ts|inputSchema

Activity

  1. added
    help wanted
    testing
    severity: medium
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions