From 2061f7de736950fa1655124127d4490615511470 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Thu, 19 Nov 2026 12:23:50 +0000 Subject: [PATCH 1/2] test(tool): pin the MCP server's input rule keywords through every adapter The MCP server now advertises each connector input's validation rules as JSON Schema keywords (minLength/maxLength, format, pattern, minimum/maximum, also on array items). Every adapter already passes the served schema through; this pins that each one keeps those keywords, so a later schema cleanup cannot drop them without a failing test. The adapter list is shared with the root pass-through tests through adaptersFor(). Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- src/tool.test.ts | 67 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/src/tool.test.ts b/src/tool.test.ts index 35a7f32e..40274e6f 100644 --- a/src/tool.test.ts +++ b/src/tool.test.ts @@ -87,6 +87,44 @@ const present = (value: Value | null | undefined): Value => { const localTool = (name: string, schema: unknown, description = 'Test tool') => new BaseTool(name, description, toolParametersFromInputSchema(schema), { kind: 'local' }); +/** Each provider-bound adapter, as the parameters schema it hands the provider. */ +const adaptersFor = (tool: BaseTool): Array<[string, () => Promise>]> => [ + ['toOpenAI', async () => present(tool.toOpenAI().function.parameters)], + ['toAnthropic', async () => tool.toAnthropic().input_schema], + [ + 'toOpenAIResponses (strict)', + async () => present(tool.toOpenAIResponses({ strict: true }).parameters), + ], + ['toOpenAIResponses (non-strict)', async () => present(tool.toOpenAIResponses().parameters)], + [ + 'toAISDK', + async () => { + const aiTools = await tool.toAISDK({ executable: false }); + const aiTool = aiTools[tool.name]; + assert.isDefined(aiTool); + return aiSdkJsonSchema(aiTool.inputSchema); + }, + ], +]; + +/** The keywords the MCP server advertises from a connector's input `rules`, as `tools/list` serves them. */ +const ruleKeywordsSchema = { + type: 'object', + properties: { + name: { type: 'string', minLength: 2, maxLength: 50 }, + email: { type: 'string', format: 'email' }, + id: { type: 'string', format: 'uuid' }, + start_date: { type: 'string', format: 'date' }, + updated_after: { type: 'string', format: 'date-time' }, + language: { type: 'string', pattern: '^[a-z]{2}$' }, + website: { type: 'string', pattern: '^https?:\\/\\/[^\\s/?#]+(?:[/?#]\\S*)?$' }, + callback: { type: 'string', pattern: '^[a-zA-Z][a-zA-Z0-9+.-]*:\\S+$' }, + expires_in: { type: 'number', minimum: 86400, maximum: 31536000 }, + tags: { type: 'array', items: { type: 'string', minLength: 1, maxLength: 10 } }, + }, + required: ['name', 'expires_in'], +} as const; + const simpleTool = () => localTool('test_tool', { type: 'object', @@ -137,25 +175,7 @@ describe('BaseTool', () => { describe('root schema pass-through across every adapter', () => { const tool = localTool('hris_rich_probe', richSchema, 'Rich probe'); const { oneOf: _rejected, ...providerRoot } = richSchema; - - const adapters: Array<[string, () => Promise>]> = [ - ['toOpenAI', async () => present(tool.toOpenAI().function.parameters)], - ['toAnthropic', async () => tool.toAnthropic().input_schema], - [ - 'toOpenAIResponses (strict)', - async () => present(tool.toOpenAIResponses({ strict: true }).parameters), - ], - ['toOpenAIResponses (non-strict)', async () => present(tool.toOpenAIResponses().parameters)], - [ - 'toAISDK', - async () => { - const aiTools = await tool.toAISDK({ executable: false }); - const aiTool = aiTools.hris_rich_probe; - assert.isDefined(aiTool); - return aiSdkJsonSchema(aiTool.inputSchema); - }, - ], - ]; + const adapters = adaptersFor(tool); it.each(adapters)( '%s keeps $schema, $defs, $ref, title and every property', @@ -210,6 +230,15 @@ describe('BaseTool', () => { }); }); + describe('input rule keywords across every adapter', () => { + it.each(adaptersFor(localTool('netbird_create_setup_key', ruleKeywordsSchema)))( + '%s hands the model every rule the server advertises', + async (_name, adapt) => { + expect((await adapt()).properties).toEqual(ruleKeywordsSchema.properties); + }, + ); + }); + it('converts to the OpenAI Chat Completions shape', () => { expect(simpleTool().toOpenAI()).toEqual({ type: 'function', From 014f3db74a16d6eccf504316b60904996f97902f Mon Sep 17 00:00:00 2001 From: S2D2 Date: Thu, 19 Nov 2026 12:27:17 +0000 Subject: [PATCH 2/2] test(tool): pin required alongside the rule keywords Review: the served required list is part of what reaches the model, and a re-sorted or dropped required list has shipped before in the Python SDK. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- src/tool.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tool.test.ts b/src/tool.test.ts index 40274e6f..a4826e09 100644 --- a/src/tool.test.ts +++ b/src/tool.test.ts @@ -234,7 +234,12 @@ describe('BaseTool', () => { it.each(adaptersFor(localTool('netbird_create_setup_key', ruleKeywordsSchema)))( '%s hands the model every rule the server advertises', async (_name, adapt) => { - expect((await adapt()).properties).toEqual(ruleKeywordsSchema.properties); + const { properties, required } = await adapt(); + + expect({ properties, required }).toEqual({ + properties: ruleKeywordsSchema.properties, + required: ruleKeywordsSchema.required, + }); }, ); });