Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(mcp): give free-form tool inputs a JSON type

Amruth Pillaia42e9a6c0e2b
diff --git a/packages/mcp/src/contracts.ts b/packages/mcp/src/contracts.ts
index 1656e4e10..519b67f15 100644
--- a/packages/mcp/src/contracts.ts
+++ b/packages/mcp/src/contracts.ts
@@ -91,6 +91,9 @@ const outputSchemaReferences = new Map<unknown, JsonSchemaReference>([
],
]);
+// Directories reject input parameters without a type, so free-form JSON inputs list every JSON type.
+const anyJsonTypes = (["string", "number", "boolean", "object", "array", "null"] as const).map((type) => ({ type }));
+
/** MCP JSON values retain the API's native dates and files through explicit wire forms. */
export function wireJsonSchema(schema: z.ZodType, io: "input" | "output" = "output") {
return z.toJSONSchema(schema, {
@@ -106,6 +109,8 @@ export function wireJsonSchema(schema: z.ZodType, io: "input" | "output" = "outp
throw new Error(`Unsupported MCP schema: ${zodSchema._zod.def.type}`);
},
override: ({ zodSchema, jsonSchema }) => {
+ const type = zodSchema._zod.def.type;
+ if (io === "input" && (type === "unknown" || type === "any")) jsonSchema.anyOf = anyJsonTypes;
const reference =
schemaReferences.get(zodSchema) ?? (io === "output" ? outputSchemaReferences.get(zodSchema) : undefined);
if (reference) {
diff --git a/packages/mcp/src/tool-meta.ts b/packages/mcp/src/tool-meta.ts
index 55ab30794..8529ba93d 100644
--- a/packages/mcp/src/tool-meta.ts
+++ b/packages/mcp/src/tool-meta.ts
@@ -357,7 +357,7 @@ const BASE_TOOL_META = {
inputSchema: wireInput(
z.strictObject({
data: z
- .unknown()
+ .looseObject({})
.describe("Complete ResumeData JSON (same shape as `read_resume` body or `resume://_meta/schema`)."),
}),
),