253
254
private async _readURI(uri: URI, token?: CancellationToken) {
256
>
if (cached) {
257
cached.pool.add(token || CancellationToken.None);
258
return cached.promise;
259
}
261
>
const pool = this._store.add(new CancellationTokenPool());
262
>
pool.add(token || CancellationToken.None);
263
>
264
>
const promise = this._readURIInner(uri, pool.token);
265
>
this._momentaryCache.set(uri, { pool, promise });
266
>
267
>
const disposable = this._store.add(disposableTimeout(() => {
268
this._momentaryCache.delete(uri);
269
this._store.delete(disposable);
270
this._store.delete(pool);
272
>
273
>
return promise;
274
>
}
275
276
private async _readURIInner(uri: URI, token?: CancellationToken): Promise<IReadData> {
278
>
const matchedServer = this._mcpService.servers.get().find(s => s.definition.id === server.definition.id);
279
>
280
>
//check for http/https resources and use web content extractor service to fetch the contents.
281
>
if (canLoadMcpNetworkResourceDirectly(resourceURI, matchedServer)) {
282
const extractURI = URI.parse(resourceURI.toString());
283
const result = (await this._webContentExtractorService.extract([extractURI], { followRedirects: false })).at(0);