fix: patch zod-to-json-schema to use Draft-07 for MCP client compatibility

- Add FastMCPCompat.js to monkey-patch zodToJsonSchema function
- Force JSON Schema Draft-07 instead of Draft 2020-12
- Use relative refs for better MCP client compatibility
- Fixes MCP server startup error in Augment IDE and other clients

Closes #1284

Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-10-08 15:39:49 +00:00
committed by Ralph Khreish
parent b8830d9508
commit 7c84d9ffe3
2 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
/**
* @fileoverview JSON Schema Draft-07 compatibility patch
*
* This patches the zod-to-json-schema module to default to JSON Schema Draft-7
* instead of Draft 2020-12 for better MCP client compatibility.
*
* The patch works by overriding the zodToJsonSchema function's default behavior.
*/
import * as zodToJsonSchemaModule from 'zod-to-json-schema';
// Store original function
const originalZodToJsonSchema = zodToJsonSchemaModule.zodToJsonSchema;
/**
* Patched zodToJsonSchema function that defaults to Draft-07
*/
function patchedZodToJsonSchema(schema, options = {}) {
// Force JSON Schema Draft-07 for MCP compatibility
const draft7Options = {
...options,
target: 'jsonSchema7',
$refStrategy: options.$refStrategy || 'relative'
};
return originalZodToJsonSchema(schema, draft7Options);
}
// Apply the patch by overriding the module's export
zodToJsonSchemaModule.zodToJsonSchema = patchedZodToJsonSchema;
// Export the patched FastMCP (just re-export regular FastMCP since we've patched at module level)
export { FastMCP } from 'fastmcp';

View File

@@ -1,4 +1,4 @@
import { FastMCP } from 'fastmcp';
import { FastMCP } from './FastMCPCompat.js';
import path from 'path';
import dotenv from 'dotenv';
import { fileURLToPath } from 'url';