fix(browser): preserve distinct WebMCP declaration metadata (#2854)

* fix(browser): preserve distinct WebMCP declaration metadata

* test(browser): retain the first equivalent declaration location
This commit is contained in:
xingzhou
2026-10-13 23:19:37 +08:00
committed by GitHub
parent 3e7c630223
commit 40e94aeb9d
2 changed files with 59 additions and 9 deletions
+8 -9
View File
@@ -293,19 +293,18 @@ const addWebMcpDeclaration = (
: [],
)
: [];
const metadata = {
name: name ?? null,
description: description ?? null,
schema_property_names: [...new Set(schemaPropertyNames)].sort(),
};
// Deduplicate the metadata we return, preserving omission and descriptions.
// Property names are a variable-length source-derived list: NUL-joins
// would collapse ["a\0b"] with ["a", "b"] and drop a declaration.
const key = compositeKey([
"webmcp",
script.script_key,
name ?? "",
schemaPropertyNames,
]);
const key = compositeKey(["webmcp", script.script_key, metadata]);
addUnique(accumulator, key, () =>
accumulator.webMcp.push({
name: name ?? null,
description: description ?? null,
schema_property_names: [...new Set(schemaPropertyNames)].sort(),
...metadata,
trust: "page-declared-untrusted",
location: location(script.script_key, node),
}),