Skip to content

Commit cb7c025

Browse files
authored
refresh default mcp servers view on mcp manifest change (microsoft#264891)
1 parent a993103 commit cb7c025

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/vs/workbench/contrib/mcp/browser/mcpCommands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { ConfigurationTarget, IConfigurationService } from '../../../../platform
3131
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
3232
import { IFileService } from '../../../../platform/files/common/files.js';
3333
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
34+
import { McpGalleryManifestStatus } from '../../../../platform/mcp/common/mcpGalleryManifest.js';
3435
import { mcpAutoStartConfig, McpAutoStartValue } from '../../../../platform/mcp/common/mcpManagement.js';
3536
import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js';
3637
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
@@ -63,7 +64,7 @@ import { TEXT_FILE_EDITOR_ID } from '../../files/common/files.js';
6364
import { McpCommandIds } from '../common/mcpCommandIds.js';
6465
import { McpContextKeys } from '../common/mcpContextKeys.js';
6566
import { IMcpRegistry } from '../common/mcpRegistryTypes.js';
66-
import { HasInstalledMcpServersContext, IMcpSamplingService, IMcpServer, IMcpServerStartOpts, IMcpService, InstalledMcpServersViewId, LazyCollectionState, McpCapability, McpCollectionDefinition, McpConnectionState, McpDefinitionReference, mcpPromptPrefix, McpServerCacheState, McpStartServerInteraction } from '../common/mcpTypes.js';
67+
import { HasInstalledMcpServersContext, IMcpSamplingService, IMcpServer, IMcpServerStartOpts, IMcpService, InstalledMcpServersViewId, LazyCollectionState, McpCapability, McpCollectionDefinition, McpConnectionState, McpDefinitionReference, mcpPromptPrefix, McpServerCacheState, McpServersGalleryStatusContext, McpStartServerInteraction } from '../common/mcpTypes.js';
6768
import { McpAddConfigurationCommand } from './mcpCommandsAddConfiguration.js';
6869
import { McpResourceQuickAccess, McpResourceQuickPick } from './mcpResourceQuickAccess.js';
6970
import './media/mcpServerAction.css';
@@ -876,7 +877,7 @@ export class BrowseMcpServersPageCommand extends Action2 {
876877
icon: Codicon.globe,
877878
menu: [{
878879
id: MenuId.ViewTitle,
879-
when: ContextKeyExpr.equals('view', InstalledMcpServersViewId),
880+
when: ContextKeyExpr.and(ContextKeyExpr.equals('view', InstalledMcpServersViewId), McpServersGalleryStatusContext.isEqualTo(McpGalleryManifestStatus.Unavailable)),
880881
group: 'navigation',
881882
}],
882883
});

src/vs/workbench/contrib/mcp/browser/mcpServersView.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { DropDownAction, InstallAction, InstallingLabelAction, ManageMcpServerAc
2929
import { PublisherWidget, StarredWidget, McpServerIconWidget, McpServerHoverWidget, McpServerScopeBadgeWidget } from './mcpServerWidgets.js';
3030
import { ActionRunner, IAction, Separator } from '../../../../base/common/actions.js';
3131
import { IActionViewItemOptions } from '../../../../base/browser/ui/actionbar/actionViewItems.js';
32-
import { IAllowedMcpServersService, IMcpGalleryService } from '../../../../platform/mcp/common/mcpManagement.js';
32+
import { IAllowedMcpServersService } from '../../../../platform/mcp/common/mcpManagement.js';
3333
import { URI } from '../../../../base/common/uri.js';
3434
import { ThemeIcon } from '../../../../base/common/themables.js';
3535
import { IProductService } from '../../../../platform/product/common/productService.js';
@@ -49,6 +49,7 @@ import { HoverPosition } from '../../../../base/browser/ui/hover/hoverWidget.js'
4949
import { IWorkbenchLayoutService, Position } from '../../../services/layout/browser/layoutService.js';
5050
import { mcpServerIcon } from './mcpServerIcons.js';
5151
import { IPagedRenderer } from '../../../../base/browser/ui/list/listPaging.js';
52+
import { IMcpGalleryManifestService, McpGalleryManifestStatus } from '../../../../platform/mcp/common/mcpGalleryManifest.js';
5253

5354
export interface McpServerListViewOptions {
5455
showWelcomeOnEmpty?: boolean;
@@ -82,7 +83,7 @@ export class McpServersListView extends AbstractExtensionsListView<IWorkbenchMcp
8283
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
8384
@IOpenerService openerService: IOpenerService,
8485
@IMcpWorkbenchService private readonly mcpWorkbenchService: IMcpWorkbenchService,
85-
@IMcpGalleryService private readonly mcpGalleryService: IMcpGalleryService,
86+
@IMcpGalleryManifestService protected readonly mcpGalleryManifestService: IMcpGalleryManifestService,
8687
@IProductService private readonly productService: IProductService,
8788
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
8889
) {
@@ -186,7 +187,8 @@ export class McpServersListView extends AbstractExtensionsListView<IWorkbenchMcp
186187
}
187188

188189
this.input = await this.query(query.trim());
189-
this.input.showWelcomeContent = !this.mcpGalleryService.isEnabled() && this.input.model.length === 0 && !!this.mpcViewOptions.showWelcomeOnEmpty;
190+
191+
this.input.showWelcomeContent = !!this.mpcViewOptions.showWelcomeOnEmpty && this.mcpGalleryManifestService.mcpGalleryManifestStatus === McpGalleryManifestStatus.Unavailable && this.input.model.length === 0;
190192
this.renderInput();
191193

192194
if (this.input.onDidChangeModel) {
@@ -195,7 +197,7 @@ export class McpServersListView extends AbstractExtensionsListView<IWorkbenchMcp
195197
return;
196198
}
197199
this.input.model = model;
198-
this.input.showWelcomeContent = !this.mcpGalleryService.isEnabled() && this.input.model.length === 0 && !!this.mpcViewOptions.showWelcomeOnEmpty;
200+
this.input.showWelcomeContent = !!this.mpcViewOptions.showWelcomeOnEmpty && this.mcpGalleryManifestService.mcpGalleryManifestStatus === McpGalleryManifestStatus.Unavailable && this.input.model.length === 0;
199201
this.renderInput();
200202
}));
201203
}
@@ -419,6 +421,12 @@ class McpServerRenderer implements IPagedRenderer<IWorkbenchMcpServer, IMcpServe
419421

420422

421423
export class DefaultBrowseMcpServersView extends McpServersListView {
424+
425+
protected override renderBody(container: HTMLElement): void {
426+
super.renderBody(container);
427+
this._register(this.mcpGalleryManifestService.onDidChangeMcpGalleryManifest(() => this.show()));
428+
}
429+
422430
override async show(): Promise<IPagedModel<IWorkbenchMcpServer>> {
423431
return super.show('@mcp');
424432
}

src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { DidUninstallWorkbenchMcpServerEvent, IWorkbenchLocalMcpServer, IWorkben
3636
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
3737
import { mcpConfigurationSection } from '../common/mcpConfiguration.js';
3838
import { McpServerInstallData, McpServerInstallClassification } from '../common/mcpServer.js';
39-
import { HasInstalledMcpServersContext, IMcpConfigPath, IMcpWorkbenchService, IWorkbenchMcpServer, McpCollectionSortOrder, McpServerEnablementState, McpServerInstallState, McpServersGalleryEnabledContext } from '../common/mcpTypes.js';
39+
import { HasInstalledMcpServersContext, IMcpConfigPath, IMcpWorkbenchService, IWorkbenchMcpServer, McpCollectionSortOrder, McpServerEnablementState, McpServerInstallState, McpServersGalleryStatusContext } from '../common/mcpTypes.js';
4040
import { McpServerEditorInput } from './mcpServerEditorInput.js';
4141
import { IMcpGalleryManifestService } from '../../../../platform/mcp/common/mcpGalleryManifest.js';
4242
import { IPager, singlePagePager } from '../../../../base/common/paging.js';
@@ -699,12 +699,16 @@ export class MCPContextsInitialisation extends Disposable implements IWorkbenchC
699699

700700
constructor(
701701
@IMcpWorkbenchService mcpWorkbenchService: IMcpWorkbenchService,
702-
@IMcpGalleryService mcpGalleryService: IMcpGalleryService,
702+
@IMcpGalleryManifestService mcpGalleryManifestService: IMcpGalleryManifestService,
703703
@IContextKeyService contextKeyService: IContextKeyService,
704704
) {
705705
super();
706+
707+
const mcpServersGalleryStatus = McpServersGalleryStatusContext.bindTo(contextKeyService);
708+
mcpServersGalleryStatus.set(mcpGalleryManifestService.mcpGalleryManifestStatus);
709+
this._register(mcpGalleryManifestService.onDidChangeMcpGalleryManifestStatus(status => mcpServersGalleryStatus.set(status)));
710+
706711
const hasInstalledMcpServersContextKey = HasInstalledMcpServersContext.bindTo(contextKeyService);
707-
McpServersGalleryEnabledContext.bindTo(contextKeyService).set(mcpGalleryService.isEnabled());
708712
hasInstalledMcpServersContextKey.set(mcpWorkbenchService.local.length > 0);
709713
this._register(mcpWorkbenchService.onChange(() => hasInstalledMcpServersContextKey.set(mcpWorkbenchService.local.length > 0)));
710714
}

src/vs/workbench/contrib/mcp/common/mcpTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { RawContextKey } from '../../../../platform/contextkey/common/contextkey
2121
import { IEditorOptions } from '../../../../platform/editor/common/editor.js';
2222
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
2323
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
24+
import { McpGalleryManifestStatus } from '../../../../platform/mcp/common/mcpGalleryManifest.js';
2425
import { IGalleryMcpServer, IInstallableMcpServer, IGalleryMcpServerConfiguration, IQueryOptions } from '../../../../platform/mcp/common/mcpManagement.js';
2526
import { IMcpDevModeConfig, IMcpServerConfiguration } from '../../../../platform/mcp/common/mcpPlatformTypes.js';
2627
import { StorageScope } from '../../../../platform/storage/common/storage.js';
@@ -707,7 +708,7 @@ export class McpServerContainers extends Disposable {
707708
}
708709
}
709710

710-
export const McpServersGalleryEnabledContext = new RawContextKey<boolean>('mcpServersGalleryEnabled', false);
711+
export const McpServersGalleryStatusContext = new RawContextKey<string>('mcpServersGalleryStatus', McpGalleryManifestStatus.Unavailable);
711712
export const HasInstalledMcpServersContext = new RawContextKey<boolean>('hasInstalledMcpServers', true);
712713
export const InstalledMcpServersViewId = 'workbench.views.mcp.installed';
713714

0 commit comments

Comments
 (0)