-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-server-version.js
More file actions
49 lines (40 loc) · 1.73 KB
/
Copy pathsync-server-version.js
File metadata and controls
49 lines (40 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
// Keeps server.json in sync with package.json for the MCP registry manifest.
// package.json is the single source of truth for the version, so this runs at
// the front of `pnpm build` and rewrites server.json's version to match --
// the registry can never publish a stale version.
//
// The description is NOT auto-copied: server.schema.json (2025-12-11) caps
// description at 100 characters, so server.json may intentionally carry a
// shorter, hand-written variant than package.json. Instead we guard that
// invariant and fail the build loudly if server.json's description is empty
// or over the limit.
import fs from "node:fs";
const PACKAGE_FILE = "package.json";
const SERVER_FILE = "server.json";
const REGISTRY_DESCRIPTION_MAX_LENGTH = 100;
function syncServerVersion() {
if (!fs.existsSync(SERVER_FILE)) {
console.error(`${SERVER_FILE} not found`);
process.exit(1);
}
const pkg = JSON.parse(fs.readFileSync(PACKAGE_FILE, "utf8"));
const server = JSON.parse(fs.readFileSync(SERVER_FILE, "utf8"));
const descriptionLength = server.description?.length ?? 0;
if (descriptionLength === 0 || descriptionLength > REGISTRY_DESCRIPTION_MAX_LENGTH) {
console.error(
`${SERVER_FILE} description is ${descriptionLength} chars; ` +
`must be 1-${REGISTRY_DESCRIPTION_MAX_LENGTH} for the MCP registry schema`
);
process.exit(1);
}
if (server.version === pkg.version) {
console.log(`${SERVER_FILE} version already in sync (${pkg.version})`);
return;
}
const previous = server.version;
server.version = pkg.version;
fs.writeFileSync(SERVER_FILE, `${JSON.stringify(server, null, 2)}\n`);
console.log(`${SERVER_FILE} version ${previous} -> ${pkg.version}`);
}
syncServerVersion();