@@ -275,35 +275,27 @@ export class McpResourceFilesystem extends Disposable implements IWorkbenchContr
275275
276276 private async _readURIInner ( uri : URI , token ?: CancellationToken ) : Promise < IReadData > {
277277 const { resourceURI, server } = this . _decodeURI ( uri ) ;
278- let fallbackToMCPServer = false ;
279- let returnVal : { contents : ( MCP . TextResourceContents | MCP . BlobResourceContents ) [ ] ; resourceURI : URL ; forSameURI : ( MCP . TextResourceContents | MCP . BlobResourceContents ) [ ] } | undefined ;
280278 const matchedServer = this . _mcpService . servers . get ( ) . find ( s => s . definition . id === server . definition . id ) ;
279+
281280 //check for http/https resources and use web content extractor service to fetch the contents.
282281 if ( canLoadMcpNetworkResourceDirectly ( resourceURI , matchedServer ) ) {
283282 const extractURI = URI . parse ( resourceURI . toString ( ) ) ;
284- const result = await this . _webContentExtractorService . extract ( [ extractURI ] , { followRedirects : false } ) ;
285- returnVal = {
286- contents : result . map ( r => {
287- if ( r . status === 'ok' ) {
288- return { uri : resourceURI . toString ( ) , text : r . result } ;
289- } else {
290- fallbackToMCPServer = true ;
291- return { uri : resourceURI . toString ( ) , text : '' } ;
292- }
293- } ) ,
294- resourceURI,
295- forSameURI : result . filter ( r => r . status === 'ok' ) . map ( r => ( { uri : resourceURI . toString ( ) , text : r . result } ) )
296- } ;
297- }
298- if ( fallbackToMCPServer || ! returnVal ) {
299- const res = await McpServer . callOn ( server , r => r . readResource ( { uri : resourceURI . toString ( ) } , token ) , token ) ;
300- returnVal = {
301- contents : res . contents ,
302- resourceURI,
303- forSameURI : res . contents . filter ( c => equalsUrlPath ( c . uri , resourceURI ) )
304- } ;
283+ const result = ( await this . _webContentExtractorService . extract ( [ extractURI ] , { followRedirects : false } ) ) . at ( 0 ) ;
284+ if ( result ?. status === 'ok' ) {
285+ return {
286+ contents : [ { uri : resourceURI . toString ( ) , text : result . result } ] ,
287+ resourceURI,
288+ forSameURI : [ { uri : resourceURI . toString ( ) , text : result . result } ]
289+ } ;
290+ }
305291 }
306- return returnVal ;
292+
293+ const res = await McpServer . callOn ( server , r => r . readResource ( { uri : resourceURI . toString ( ) } , token ) , token ) ;
294+ return {
295+ contents : res . contents ,
296+ resourceURI,
297+ forSameURI : res . contents . filter ( c => equalsUrlPath ( c . uri , resourceURI ) )
298+ } ;
307299 }
308300}
309301
0 commit comments