fix(mcp): advertise object roots for union input schemas (#1373)
* fix(mcp): advertise object roots for union input schemas
Anthropic tool input schemas reject anyOf, oneOf, and allOf at the root.
Since 63bf9140 removed root flattening, compare_web_captures,
inspect_web_page, inspect_electron_page, and
project_managed_application_graph advertised root unions: Claude Desktop
disabled compare_web_captures and Claude Code exposed the tools without
parameters.
Present a root union of plain-reference object branches as one strict
object with the union of properties, shared required fields, a
minProperties bound, and a description of the accepted input groups. The
canonical Zod union still validates every call, so mixed input groups are
rejected before the handler runs. Branches whose reference siblings cannot
be merged keep their root alternatives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(browser): keep comparison input boundary within lint limits
Express advertised and runtime expectations as one case table so the
boundary test stays under the 150-line function limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(mcp): preserve input group dependencies in object schemas
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
morluto
parent
73a664bc78
commit
39dabd0608
@@ -396,15 +396,18 @@ describe("MCP root input schemas", () => {
|
||||
expect(ajv.compile(graphTool.inputSchema)({ unrelated: true })).toBe(
|
||||
false,
|
||||
);
|
||||
expect(graphTool.inputSchema.description).toContain(
|
||||
"Provide a complete input group",
|
||||
);
|
||||
expect(graphTool.inputSchema.description).not.toContain("exactly one");
|
||||
|
||||
for (const contract of TOOL_CONTRACTS) {
|
||||
const inputSchema = advertised.get(contract.name)!.inputSchema;
|
||||
expect(inputSchema.type, contract.name).toBe("object");
|
||||
expect(
|
||||
inputSchema.properties !== undefined ||
|
||||
Array.isArray(inputSchema.anyOf),
|
||||
contract.name,
|
||||
).toBe(true);
|
||||
expect(inputSchema.properties, contract.name).toBeDefined();
|
||||
// Anthropic tool input schemas reject root combinators.
|
||||
for (const combinator of ["anyOf", "oneOf", "allOf"])
|
||||
expect(inputSchema, contract.name).not.toHaveProperty(combinator);
|
||||
const validate = ajv.compile(inputSchema);
|
||||
for (const example of contract.examples)
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user