fix: reject plain JSON Schema objects passed as inputSchema (#1596)
Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com>
This commit is contained in:
parent
4cbcec0edb
commit
93640d33ab
1 changed files with 40 additions and 4 deletions
|
|
@ -2050,6 +2050,37 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
// Clean up spies
|
||||
warnSpy.mockRestore();
|
||||
});
|
||||
|
||||
test('should reject plain JSON Schema objects passed as inputSchema', () => {
|
||||
const mcpServer = new McpServer({
|
||||
name: 'test server',
|
||||
version: '1.0'
|
||||
});
|
||||
|
||||
const jsonSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
directory_id: {
|
||||
type: 'string',
|
||||
format: 'uuid',
|
||||
description: 'The UUID of the directory'
|
||||
}
|
||||
},
|
||||
required: ['directory_id']
|
||||
} as any;
|
||||
|
||||
const cb = async ({ directory_id }: any) => ({
|
||||
content: [{ type: 'text' as const, text: `Got: ${directory_id}` }]
|
||||
});
|
||||
|
||||
expect(() => {
|
||||
mcpServer.tool('test', 'A tool', jsonSchema, cb);
|
||||
}).toThrow(/unrecognized object/);
|
||||
|
||||
expect(() => {
|
||||
mcpServer.registerTool('test', { description: 'A tool', inputSchema: jsonSchema }, cb);
|
||||
}).toThrow(/unrecognized object/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resource()', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue