mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
ci: watch the MCP registry hourly for HeyGen listings server.json never held (#8107)
* test(ci): flag registry listings under HeyGen names that server.json never held * ci: watch the MCP registry hourly for HeyGen listings server.json never held * test(ci): the registry watch covers heygen.com's subdomain namespaces * fix(ci): the registry watch covers heygen.com subdomains and opens an issue when it fails
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// Fails when the MCP registry lists a server under a HeyGen namespace at a name and version server.json never held.
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
const REGISTRY = "https://registry.modelcontextprotocol.io/v0.1/servers";
|
||||
// heygen.com and every subdomain (the registry's DNS and HTTP logins grant both), and the GitHub org.
|
||||
const OURS = ["com.heygen/", "com.heygen.", "io.github.heygen-com/"];
|
||||
|
||||
/** Every name@version among server.json's texts. @param {string[]} texts */
|
||||
export function publishedListings(texts) {
|
||||
const published = new Set();
|
||||
for (const text of texts) {
|
||||
try {
|
||||
const { name, version } = JSON.parse(text);
|
||||
if (name && version) published.add(`${name}@${version}`);
|
||||
} catch {}
|
||||
}
|
||||
return published;
|
||||
}
|
||||
|
||||
/** @param {{ server: { name: string, version: string } }[]} servers @param {Set<string>} published */
|
||||
export function unexpectedListings(servers, published) {
|
||||
return servers
|
||||
.map(({ server }) => `${server.name}@${server.version}`)
|
||||
.filter((id) => OURS.some((prefix) => id.startsWith(prefix)) && !published.has(id));
|
||||
}
|
||||
|
||||
function serverJsonHistory() {
|
||||
const git = (...args) =>
|
||||
execFileSync("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
||||
return git("log", "--format=%H", "--", "server.json")
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.map((sha) => {
|
||||
try {
|
||||
return git("show", `${sha}:server.json`);
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function registryListings() {
|
||||
const servers = [];
|
||||
let cursor = "";
|
||||
do {
|
||||
const url = new URL(REGISTRY);
|
||||
url.searchParams.set("search", "heygen");
|
||||
url.searchParams.set("limit", "100");
|
||||
if (cursor) url.searchParams.set("cursor", cursor);
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error(`${url} answered ${response.status}`);
|
||||
const page = await response.json();
|
||||
servers.push(...page.servers);
|
||||
cursor = page.metadata?.nextCursor ?? "";
|
||||
} while (cursor);
|
||||
return servers;
|
||||
}
|
||||
|
||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
const servers = await registryListings();
|
||||
const unexpected = unexpectedListings(servers, publishedListings(serverJsonHistory()));
|
||||
if (unexpected.length) {
|
||||
console.error(
|
||||
`::error::the MCP registry lists HeyGen servers server.json never held: ${unexpected.join(", ")}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(
|
||||
`${servers.length} listing(s) checked; every HeyGen one is a name and version server.json held`,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { publishedListings, unexpectedListings } from "./mcp-registry-watch.mjs";
|
||||
|
||||
const listing = (name, version) => ({ server: { name, version } });
|
||||
|
||||
test("a listing under a HeyGen namespace that server.json never held is unexpected", () => {
|
||||
const published = new Set([
|
||||
"io.github.heygen-com/hyperframes@1.0.0",
|
||||
"com.heygen/hyperframes@1.0.0",
|
||||
]);
|
||||
const servers = [
|
||||
listing("io.github.heygen-com/hyperframes", "1.0.0"),
|
||||
listing("com.heygen/hyperframes", "1.0.0"),
|
||||
listing("io.github.heygen-com/hyperframes", "1.0.1"),
|
||||
listing("io.github.heygen-com/other", "0.1.0"),
|
||||
listing("com.heygen/hyperframes-x", "9.9.9"),
|
||||
listing("com.heygen.docs/hyperframes", "1.0.0"),
|
||||
listing("com.heygenx/hyperframes", "1.0.0"),
|
||||
listing("io.github.someone/heygen-tools", "1.0.0"),
|
||||
];
|
||||
assert.deepEqual(unexpectedListings(servers, published), [
|
||||
"io.github.heygen-com/hyperframes@1.0.1",
|
||||
"io.github.heygen-com/other@0.1.0",
|
||||
"com.heygen/hyperframes-x@9.9.9",
|
||||
"com.heygen.docs/hyperframes@1.0.0",
|
||||
]);
|
||||
});
|
||||
|
||||
test("what this repo published is every name and version server.json has held", () => {
|
||||
const history = [
|
||||
'{"name": "com.heygen/hyperframes", "version": "1.0.0"}',
|
||||
'{"name": "io.github.heygen-com/hyperframes", "version": "1.0.0"}',
|
||||
"not json",
|
||||
];
|
||||
assert.deepEqual([...publishedListings(history)].sort(), [
|
||||
"com.heygen/hyperframes@1.0.0",
|
||||
"io.github.heygen-com/hyperframes@1.0.0",
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user