fix(mcp): clarify advertised schema fields

This commit is contained in:
morluto
2026-07-17 02:23:22 +00:00
parent a7c1e87365
commit 1581e40fce
3 changed files with 155 additions and 3 deletions
+26
View File
@@ -25,6 +25,7 @@ import {
annotationsFromEffects,
TOOL_EFFECTS,
} from "../src/contracts/toolEffects.js";
import { toolRegistrationOptions } from "../src/server/toolRegistrationOptions.js";
const convertContractJsonSchema = (schema: z.ZodType) =>
z.toJSONSchema(schema, {
@@ -59,6 +60,31 @@ const emptySchemaPaths = (value: unknown, path = "$"): string[] => {
};
describe("tool contract surface", () => {
it("gives fallback parameter guidance operational meaning", () => {
const contract = TOOL_CONTRACTS.find(
({ name }) => name === "analyze_function",
);
expect(contract).toBeDefined();
if (contract === undefined) return;
const advertisedSchema =
toolRegistrationOptions(contract).inputSchema[
"~standard"
].jsonSchema.input();
const properties = Object.fromEntries(
Object.entries(advertisedSchema.properties ?? {}),
);
expect(properties.include_assembly).toMatchObject({
description: "Whether to include assembly in the result.",
});
expect(properties.max_instructions).toMatchObject({
description: "Maximum permitted instructions for this operation.",
});
expect(properties.pseudocode_offset).toMatchObject({
description: "Zero-based index of the first pseudocode to return.",
});
});
it("advertises complete typed schemas and annotations for all analysis tools", () => {
const contracts = [
...OFFICIAL_TOOL_CONTRACTS,
@@ -115,6 +115,16 @@ const assertDescribedStrictObjects = (
assertDescribedStrictObjects(value, root, `${path}[${String(index)}]`);
};
const assertDescribedRootObject = (schema: unknown, path: string): void => {
const object = Object.fromEntries(objectEntries(schema));
expect(object.additionalProperties, path).toBe(false);
for (const [property, propertySchema] of objectEntries(object.properties))
expect(
Object.fromEntries(objectEntries(propertySchema)).description,
`${path}.properties.${property}`,
).toEqual(expect.any(String));
};
describe("full MCP integration with multi-tool sequences", () => {
it("executes a realistic workflow: list methods, decompile selected, get xrefs", async () => {
const client = await connect({
@@ -225,6 +235,7 @@ describe("full MCP integration with multi-tool sequences", () => {
tool.inputSchema,
tool.name,
);
assertDescribedRootObject(tool.outputSchema, `${tool.name}.output`);
}
});