@@ -29,13 +29,22 @@ export const driverOptions = setupDriverConfig({
2929
3030export const defaultDriverOptions : DriverOptions = { ...driverOptions } ;
3131
32- interface ParameterInfo {
32+ interface Parameter {
3333 name : string ;
34- type : string ;
3534 description : string ;
3635 required : boolean ;
3736}
3837
38+ interface SingleValueParameter extends Parameter {
39+ type : string ;
40+ }
41+
42+ interface AnyOfParameter extends Parameter {
43+ anyOf : { type : string } [ ] ;
44+ }
45+
46+ type ParameterInfo = SingleValueParameter | AnyOfParameter ;
47+
3948type ToolInfo = Awaited < ReturnType < Client [ "listTools" ] > > [ "tools" ] [ number ] ;
4049
4150export interface IntegrationTest {
@@ -217,18 +226,38 @@ export function getParameters(tool: ToolInfo): ParameterInfo[] {
217226
218227 return Object . entries ( tool . inputSchema . properties )
219228 . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
220- . map ( ( [ key , value ] ) => {
221- expect ( value ) . toHaveProperty ( "type" ) ;
229+ . map ( ( [ name , value ] ) => {
222230 expect ( value ) . toHaveProperty ( "description" ) ;
223231
224- const typedValue = value as { type : string ; description : string } ;
225- expect ( typeof typedValue . type ) . toBe ( "string" ) ;
226- expect ( typeof typedValue . description ) . toBe ( "string" ) ;
232+ const description = ( value as { description : string } ) . description ;
233+ const required = ( tool . inputSchema . required as string [ ] ) ?. includes ( name ) ?? false ;
234+ expect ( typeof description ) . toBe ( "string" ) ;
235+
236+ if ( value && typeof value === "object" && "anyOf" in value ) {
237+ const typedOptions = new Array < { type : string } > ( ) ;
238+ for ( const option of value . anyOf as { type : string } [ ] ) {
239+ expect ( option ) . toHaveProperty ( "type" ) ;
240+
241+ typedOptions . push ( { type : option . type } ) ;
242+ }
243+
244+ return {
245+ name,
246+ anyOf : typedOptions ,
247+ description : description ,
248+ required,
249+ } ;
250+ }
251+
252+ expect ( value ) . toHaveProperty ( "type" ) ;
253+
254+ const type = ( value as { type : string } ) . type ;
255+ expect ( typeof type ) . toBe ( "string" ) ;
227256 return {
228- name : key ,
229- type : typedValue . type ,
230- description : typedValue . description ,
231- required : ( tool . inputSchema . required as string [ ] ) ?. includes ( key ) ?? false ,
257+ name,
258+ type,
259+ description,
260+ required,
232261 } ;
233262 } ) ;
234263}
0 commit comments