279
280
private async _promptForTrust(definition: McpServerDefinition, collection: McpCollectionDefinition, interaction: McpStartServerInteraction | undefined, trustNonceBearer: { trustedAtNonce: string | undefined }): Promise<boolean> {
282
>
interaction.participants.set(definition.id, { s: 'waiting', definition, collection });
283
>
284
>
const trustedDefinitionIds = await new Promise<string[] | undefined>(resolve => {
285
>
autorunSelfDisposable(reader => {
286
>
const map = interaction.participants.observable.read(reader);
287
>
if (Iterable.some(map.values(), p => p.s === 'unknown')) {
288
return; // wait to gather all calls
289
}
291
>
reader.dispose();
292
>
interaction.choice ??= this._promptForTrustOpenDialog(
293
>
[...map.values()].map((v) => v.s === 'waiting' ? v : undefined).filter(isDefined),
294
>
);
295
>
resolve(interaction.choice);
296
>
});
297
>
});
298
>
299
>
this._logService.trace(`MCP trusted servers:`, trustedDefinitionIds);
300
>
301
>
if (trustedDefinitionIds) {
302
trustNonceBearer.trustedAtNonce = trustedDefinitionIds.includes(definition.id)
303
? definition.cacheNonce
304
: notTrustedNonce;
305
}
307
>
return !!trustedDefinitionIds?.includes(definition.id);
308
>
}
309
310
/**