@@ -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 {
@@ -219,18 +228,38 @@ export function getParameters(tool: ToolInfo): ParameterInfo[] {
219228
220229 return Object . entries ( tool . inputSchema . properties )
221230 . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
222- . map ( ( [ key , value ] ) => {
223- expect ( value ) . toHaveProperty ( "type" ) ;
231+ . map ( ( [ name , value ] ) => {
224232 expect ( value ) . toHaveProperty ( "description" ) ;
225233
226- const typedValue = value as { type : string ; description : string } ;
227- expect ( typeof typedValue . type ) . toBe ( "string" ) ;
228- expect ( typeof typedValue . description ) . toBe ( "string" ) ;
234+ const description = ( value as { description : string } ) . description ;
235+ const required = ( tool . inputSchema . required as string [ ] ) ?. includes ( name ) ?? false ;
236+ expect ( typeof description ) . toBe ( "string" ) ;
237+
238+ if ( value && typeof value === "object" && "anyOf" in value ) {
239+ const typedOptions = new Array < { type : string } > ( ) ;
240+ for ( const option of value . anyOf as { type : string } [ ] ) {
241+ expect ( option ) . toHaveProperty ( "type" ) ;
242+
243+ typedOptions . push ( { type : option . type } ) ;
244+ }
245+
246+ return {
247+ name,
248+ anyOf : typedOptions ,
249+ description : description ,
250+ required,
251+ } ;
252+ }
253+
254+ expect ( value ) . toHaveProperty ( "type" ) ;
255+
256+ const type = ( value as { type : string } ) . type ;
257+ expect ( typeof type ) . toBe ( "string" ) ;
229258 return {
230- name : key ,
231- type : typedValue . type ,
232- description : typedValue . description ,
233- required : ( tool . inputSchema . required as string [ ] ) ?. includes ( key ) ?? false ,
259+ name,
260+ type,
261+ description,
262+ required,
234263 } ;
235264 } ) ;
236265}
0 commit comments