UNPKG

n8n-nodes-mcp

Version:
56 lines 2.38 kB
"use strict"; describe('MCP Client listTools schema passthrough', () => { const serverToolsResponse = [ { name: 'complexTool', description: 'A tool with a complex nested schema', inputSchema: { type: 'object', properties: { simple: { type: 'string', description: 'A simple string' }, nested: { type: 'object', properties: { inner: { type: 'number', description: 'A nested number' }, deep: { type: 'object', properties: { flag: { type: 'boolean', description: 'A deep boolean' } }, required: ['flag'] } }, required: ['inner', 'deep'] }, arr: { type: 'array', items: { type: 'string' }, description: 'An array of strings' } }, required: ['simple', 'nested', 'arr'] } } ]; function listToolsPassthrough(rawTools) { return rawTools.map(tool => ({ name: tool.name, description: tool.description || `Execute the ${tool.name} tool`, schema: tool.inputSchema })); } it('should return the original schema from the server without modification', () => { const output = listToolsPassthrough(serverToolsResponse); expect(output[0].schema).toEqual(serverToolsResponse[0].inputSchema); expect(JSON.stringify(output[0].schema)).toBe(JSON.stringify(serverToolsResponse[0].inputSchema)); }); it('should fail if the schema is truncated or converted', () => { const buggy = [{ name: 'complexTool', description: 'A tool with a complex nested schema', schema: { type: 'object', properties: { simple: { type: 'string' } }, required: ['simple'] } }]; expect(buggy[0].schema).not.toEqual(serverToolsResponse[0].inputSchema); }); }); //# sourceMappingURL=listTools.schema.test.js.map