@@ -26,6 +26,7 @@ import { observableConfigValue } from '../../../../platform/observable/common/pl
2626import { IQuickInputButton , IQuickInputService , IQuickPickItem } from '../../../../platform/quickinput/common/quickInput.js' ;
2727import { StorageScope , StorageTarget } from '../../../../platform/storage/common/storage.js' ;
2828import { IWorkspaceFolderData } from '../../../../platform/workspace/common/workspace.js' ;
29+ import { IWorkspaceTrustManagementService , IWorkspaceTrustRequestService } from '../../../../platform/workspace/common/workspaceTrust.js' ;
2930import { IConfigurationResolverService } from '../../../services/configurationResolver/common/configurationResolver.js' ;
3031import { ConfigurationResolverExpression , IResolvedValue } from '../../../services/configurationResolver/common/configurationResolverExpression.js' ;
3132import { AUX_WINDOW_GROUP , IEditorService } from '../../../services/editor/common/editorService.js' ;
@@ -87,6 +88,8 @@ export class McpRegistry extends Disposable implements IMcpRegistry {
8788 @ILabelService private readonly _labelService : ILabelService ,
8889 @ILogService private readonly _logService : ILogService ,
8990 @IMcpSandboxService private readonly _mcpSandboxService : IMcpSandboxService ,
91+ @IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService : IWorkspaceTrustManagementService ,
92+ @IWorkspaceTrustRequestService private readonly _workspaceTrustRequestService : IWorkspaceTrustRequestService ,
9093 ) {
9194 super ( ) ;
9295 this . _mcpAccessValue = observableConfigValue ( mcpAccessConfig , McpAccessValue . All , configurationService ) ;
@@ -215,6 +218,14 @@ export class McpRegistry extends Disposable implements IMcpRegistry {
215218 autoTrustChanges = false ,
216219 errorOnUserInteraction = false ,
217220 } : IMcpResolveConnectionOptions ) {
221+ if ( collection . scope === StorageScope . WORKSPACE && ! this . _workspaceTrustManagementService . isWorkspaceTrusted ( ) ) {
222+ if ( errorOnUserInteraction ) {
223+ throw new UserInteractionRequiredError ( 'workspaceTrust' ) ;
224+ } else if ( ! await this . _workspaceTrustRequestService . requestWorkspaceTrust ( { message : localize ( 'runTrust' , "This MCP server definition is defined in your workspace files." ) } ) ) {
225+ return false ;
226+ }
227+ }
228+
218229 if ( collection . trustBehavior === McpServerTrust . Kind . Trusted ) {
219230 this . _logService . trace ( `MCP server ${ definition . id } is trusted, no trust prompt needed` ) ;
220231 return true ;
0 commit comments