check-mcp-hosted-schema.mjs
35 lines 1.2 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 11 days ago
1 #!/usr/bin/env node
2 /**
3 * CI guard: z.record(z.unknown()) breaks Zod v4 JSON Schema export in @modelcontextprotocol/sdk
4 * for hosted tools/list — one bad schema fails the entire tool list.
5 * Scope: hub/gateway/mcp-hosted*.mjs only.
6 */
7
8 import { readdirSync, readFileSync } from 'node:fs';
9 import { join } from 'node:path';
10 import { fileURLToPath } from 'node:url';
11 import { dirname } from 'node:path';
12
13 const __dirname = dirname(fileURLToPath(import.meta.url));
14 const root = join(__dirname, '..');
15 const gatewayDir = join(root, 'hub', 'gateway');
16 const FORBIDDEN = 'z.record(z.unknown())';
17
18 const files = readdirSync(gatewayDir).filter((f) => f.startsWith('mcp-hosted') && f.endsWith('.mjs'));
19 let failed = false;
20
21 for (const name of files) {
22 const path = join(gatewayDir, name);
23 const src = readFileSync(path, 'utf8');
24 if (src.includes(FORBIDDEN)) {
25 console.error(`[check-mcp-hosted-schema] Forbidden pattern ${JSON.stringify(FORBIDDEN)} in ${path}`);
26 failed = true;
27 }
28 }
29
30 if (failed) {
31 console.error('[check-mcp-hosted-schema] Use z.record(z.string(), z.unknown()) or explicit object shapes.');
32 process.exit(1);
33 }
34
35 console.log(`[check-mcp-hosted-schema] OK (${files.length} file(s))`);
File History 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 31 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 50 days ago