@@ -371,39 +371,6 @@ describe("ToolBase", () => {
371371 expect ( result . structuredContent ) . toBeUndefined ( ) ;
372372 } ) ;
373373
374- it ( "should not append UIResource when outputSchema validation fails" , async ( ) => {
375- const toolWithInvalidOutput = createToolWithInvalidStructuredContent (
376- [ "mcpUI" ] ,
377- mockSession ,
378- mockConfig ,
379- mockTelemetry ,
380- mockElicitation ,
381- mockUIRegistry
382- ) ;
383- ( mockUIRegistry . get as Mock ) . mockReturnValue ( "<html>test UI</html>" ) ;
384-
385- let invalidCallback : ToolCallback < ZodRawShape > | undefined ;
386- const mockServer = {
387- mcpServer : {
388- registerTool : (
389- _name : string ,
390- _config : unknown ,
391- cb : ToolCallback < ZodRawShape >
392- ) : { enabled : boolean ; disable : ( ) => void ; enable : ( ) => void } => {
393- invalidCallback = cb ;
394- return { enabled : true , disable : vi . fn ( ) , enable : vi . fn ( ) } ;
395- } ,
396- } ,
397- } ;
398- toolWithInvalidOutput . register ( mockServer as unknown as Server ) ;
399-
400- expectDefined ( invalidCallback ) ;
401- const result = await invalidCallback ( { input : "test" } , { } as never ) ;
402-
403- expect ( result . content ) . toHaveLength ( 1 ) ;
404- expect ( mockLoggerWarning ) . toHaveBeenCalled ( ) ;
405- } ) ;
406-
407374 it ( "should append UIResource correctly when all conditions are met" , async ( ) => {
408375 toolWithUI = createToolWithUI ( [ "mcpUI" ] ) ;
409376 ( mockUIRegistry . get as Mock ) . mockReturnValue ( "<html>test UI</html>" ) ;
@@ -419,7 +386,7 @@ describe("ToolBase", () => {
419386 resource : { uri : string ; text : string ; mimeType : string ; _meta ?: Record < string , unknown > } ;
420387 } ;
421388 expect ( uiResource . type ) . toBe ( "resource" ) ;
422- expect ( uiResource . resource . uri ) . toMatch ( / ^ u i : \/ \ /t e s t - t o o l - w i t h - o u t p u t - s c h e m a \/ \d + $ / ) ;
389+ expect ( uiResource . resource . uri ) . toBe ( " ui:/ /test-tool-with-output-schema" ) ;
423390 expect ( uiResource . resource . text ) . toBe ( "<html>test UI</html>" ) ;
424391 expect ( uiResource . resource . mimeType ) . toBe ( "text/html" ) ;
425392 expect ( uiResource . resource . _meta ) . toEqual ( {
@@ -475,27 +442,6 @@ function createToolWithoutStructuredContent(
475442 return new TestToolWithoutStructuredContent ( constructorParams ) ;
476443}
477444
478- function createToolWithInvalidStructuredContent (
479- previewFeatures : PreviewFeature [ ] ,
480- mockSession : Session ,
481- mockConfig : UserConfig ,
482- mockTelemetry : Telemetry ,
483- mockElicitation : Elicitation ,
484- mockUIRegistry : UIRegistry
485- ) : TestToolWithInvalidStructuredContent {
486- mockConfig . previewFeatures = previewFeatures ;
487- const constructorParams : ToolConstructorParams = {
488- category : TestToolWithInvalidStructuredContent . category ,
489- operationType : TestToolWithInvalidStructuredContent . operationType ,
490- session : mockSession ,
491- config : mockConfig ,
492- telemetry : mockTelemetry ,
493- elicitation : mockElicitation ,
494- uiRegistry : mockUIRegistry ,
495- } ;
496- return new TestToolWithInvalidStructuredContent ( constructorParams ) ;
497- }
498-
499445class TestTool extends ToolBase {
500446 public name = "test-tool" ;
501447 static category : ToolCategory = "mongodb" ;
@@ -592,35 +538,3 @@ class TestToolWithoutStructuredContent extends ToolBase {
592538 return { } ;
593539 }
594540}
595-
596- class TestToolWithInvalidStructuredContent extends ToolBase {
597- public name = "test-tool-with-invalid-structured" ;
598- static category : ToolCategory = "mongodb" ;
599- static operationType : OperationType = "metadata" ;
600- protected description = "A test tool with invalid structured content" ;
601- protected argsShape = {
602- input : z . string ( ) . describe ( "Test input" ) ,
603- } ;
604- protected override outputSchema = {
605- value : z . string ( ) ,
606- requiredField : z . number ( ) ,
607- } ;
608-
609- protected async execute ( ) : Promise < CallToolResult > {
610- return Promise . resolve ( {
611- content : [
612- {
613- type : "text" ,
614- text : "Tool with invalid structured content executed" ,
615- } ,
616- ] ,
617- structuredContent : {
618- value : "test" ,
619- } ,
620- } ) ;
621- }
622-
623- protected resolveTelemetryMetadata ( ) : TelemetryToolMetadata {
624- return { } ;
625- }
626- }
0 commit comments