update generation scripts and readme

This commit is contained in:
Caitie McCaffrey 2026-05-11 16:00:24 -07:00
commit ca977811cc
2 changed files with 21 additions and 4 deletions

View file

@ -19,8 +19,22 @@ Tasks are useful for:
The full specification for Tasks as defined in the `2025-11-25` MCP protocol version can be found at:
- **Specification:** [`docs/specification/2025-11-25/tasks.mdx`](docs/specification/2025-11-25/tasks.mdx)
- **Schema (TypeScript):** [`schema/draft/2025-11-25/schema.ts`](schema/draft/2025-11-25/schema.ts)
- **Schema (JSON):** [`schema/draft/2025-11-25/schema.json`](schema/draft/2025-11-25/schema.json)
- **Schema (TypeScript):** [`schema/2025-11-25/schema.ts`](schema/2025-11-25/schema.ts)
- **Schema (JSON):** [`schema/2025-11-25/schema.json`](schema/2025-11-25/schema.json)
## Development
### Schema Generation
The JSON Schema is auto-generated from the TypeScript type definitions using [ts-to-zod](https://github.com/fabien0102/ts-to-zod) and Zod's `toJSONSchema()`. Do not hand-edit `schema.json` or `generated/schema.ts`.
```bash
# Generate Zod schemas and JSON Schema from schema.ts
npm run generate:schemas
# Verify TypeScript compiles and generated files are up to date
npm run check:schema
```
## SEPs

View file

@ -23,7 +23,7 @@
* @see https://github.com/fabien0102/ts-to-zod
*/
import { readFileSync, writeFileSync, existsSync } from "node:fs";
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
import { dirname, join, relative } from "node:path";
import { fileURLToPath } from "node:url";
import { generate } from "ts-to-zod";
@ -33,7 +33,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PROJECT_ROOT = join(__dirname, "..");
const SCHEMA_DIR = join(PROJECT_ROOT, "schema", "draft", "2025-11-25");
const SCHEMA_DIR = join(PROJECT_ROOT, "schema", "2025-11-25");
const SPEC_TYPES_FILE = join(SCHEMA_DIR, "schema.ts");
const GENERATED_DIR = join(SCHEMA_DIR, "generated");
const SCHEMA_OUTPUT_FILE = join(GENERATED_DIR, "schema.ts");
@ -164,6 +164,9 @@ async function main() {
return;
}
// Ensure generated directory exists
mkdirSync(GENERATED_DIR, { recursive: true });
// Write Zod schemas
writeFileSync(SCHEMA_OUTPUT_FILE, schemasContent, "utf-8");
console.log(`✅ Written: ${SCHEMA_OUTPUT_FILE}`);