update generation scripts and readme
This commit is contained in:
parent
b8acfa0b6b
commit
ca977811cc
2 changed files with 21 additions and 4 deletions
18
README.md
18
README.md
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue