zod schema validation
Parse at the boundary, read the failure, and let the schema be the type.
- For
zod@4.5.4- Verified
- 2026-09-07, 7 examples executed
- Package
@modootoday/pmcp-zod-schema-validation@1.2.0
What it covers
- When to reach for it
- Parse or branch, not both
- Unknown keys are dropped, not rejected
- Read the failure, do not stringify it
- Let the schema be the type
- Coerce only where the wire is untyped
- What this skill does not cover
One example from this skill
This is the skill's own text, not a summary of it. It runs: that is what verifying means here.
import { z } from "zod";
import assert from "node:assert/strict";
const Config = z.object({ port: z.number(), host: z.string() });
// safeParse when the caller answers for the failure.
const result = Config.safeParse({ port: "8080", host: "localhost" });
assert.equal(result.success, false);
// parse when there is no answer but to stop.
assert.deepEqual(Config.parse({ port: 8080, host: "localhost" }), {
port: 8080,
host: "localhost",
});
Getting it
With a subscription:
npx -y @modootoday/pmcp login
npx -y @modootoday/pmcp install @modootoday/pmcp-zod-schema-validation
It installs as a dev dependency of your project, and the MCP server finds it there like any other skill.