When implementing or verifying the fix for schema truncation, use a unit test to ensure that complex, nested JSON Schemas are returned identically to how they were received from the MCP server. The test should assert that the schema property in the output matches the inputSchema of the mock tool, including nested properties, formats, and required fields.
import { McpClient } from '../nodes/McpClient/McpClient.node';
// ...other imports
describe('MCP Client Tool Schema Serialization', () => {
it('should return the full, original JSON Schema for a tool', async () => {
const originalSchema = {
type: 'object',
properties: {
queries: {
type: 'array',
items: {
type: 'object',
properties: {
fg_id: { type: 'string', format: 'uuid' },
emailExact: { type: 'string', format: 'email' },
// ...more fields
},
required: ['fg_id'],
additionalProperties: false
}
}
},
required: ['queries'],
additionalProperties: false
};
// Mock the MCP server/tools response
const fakeTool = {
name: 'fg_findPersons',
description: 'Find persons based on an array of criteria.',
inputSchema: originalSchema
};
// Simulate your listTools logic here
const aiTools = [fakeTool].map(tool => ({
name: tool.name,
description: tool.description,
schema: tool.inputSchema
}));
// Assert the schema is identical
expect(aiTools[0].schema).toEqual(originalSchema);
});
});