44
55import { ClientScenario , ConformanceCheck } from '../../types.js' ;
66import { connectToServer } from './client-helper.js' ;
7+ import {
8+ TextResourceContents ,
9+ BlobResourceContents
10+ } from '@modelcontextprotocol/sdk/types.js' ;
711
812export class ResourcesListScenario implements ClientScenario {
913 name = 'resources-list' ;
@@ -94,7 +98,7 @@ export class ResourcesReadTextScenario implements ClientScenario {
9498 errors . push ( 'contents is not an array' ) ;
9599 if ( result . contents . length === 0 ) errors . push ( 'contents array is empty' ) ;
96100
97- const content = result . contents [ 0 ] ;
101+ const content = result . contents [ 0 ] as TextResourceContents | undefined ;
98102 if ( content ) {
99103 if ( ! content . uri ) errors . push ( 'Content missing uri' ) ;
100104 if ( ! content . mimeType ) errors . push ( 'Content missing mimeType' ) ;
@@ -162,7 +166,7 @@ export class ResourcesReadBinaryScenario implements ClientScenario {
162166 if ( ! result . contents ) errors . push ( 'Missing contents array' ) ;
163167 if ( result . contents . length === 0 ) errors . push ( 'contents array is empty' ) ;
164168
165- const content = result . contents [ 0 ] ;
169+ const content = result . contents [ 0 ] as BlobResourceContents | undefined ;
166170 if ( content ) {
167171 if ( ! content . uri ) errors . push ( 'Content missing uri' ) ;
168172 if ( ! content . mimeType ) errors . push ( 'Content missing mimeType' ) ;
@@ -233,11 +237,15 @@ export class ResourcesTemplateReadScenario implements ClientScenario {
233237 const content = result . contents [ 0 ] ;
234238 if ( content ) {
235239 if ( ! content . uri ) errors . push ( 'Content missing uri' ) ;
236- if ( ! content . text && ! content . blob )
237- errors . push ( 'Content missing text or blob' ) ;
238-
239- // Check if parameter was substituted
240- const text = content . text || ( content . blob ? '[binary]' : '' ) ;
240+ const hasText = 'text' in content ;
241+ const hasBlob = 'blob' in content ;
242+ if ( ! hasText && ! hasBlob ) errors . push ( 'Content missing text or blob' ) ;
243+
244+ const text = hasText
245+ ? ( content as TextResourceContents ) . text
246+ : hasBlob
247+ ? '[binary]'
248+ : '' ;
241249 if ( typeof text === 'string' && ! text . includes ( '123' ) ) {
242250 errors . push ( 'Parameter substitution not reflected in content' ) ;
243251 }
@@ -258,7 +266,11 @@ export class ResourcesTemplateReadScenario implements ClientScenario {
258266 ] ,
259267 details : {
260268 uri : content ?. uri ,
261- content : content ?. text || content ?. blob
269+ content : content
270+ ? 'text' in content
271+ ? ( content as TextResourceContents ) . text
272+ : ( content as BlobResourceContents ) . blob
273+ : undefined
262274 }
263275 } ) ;
264276
0 commit comments