Skip to content

Commit 12fb672

Browse files
authored
1 parent 9f7ea05 commit 12fb672

File tree

3 files changed

+30
-34
lines changed

3 files changed

+30
-34
lines changed

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

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import { IContextMenuService } from '../../../../platform/contextview/browser/co
1212
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
1313
import { manageExtensionIcon } from '../../extensions/browser/extensionsIcons.js';
1414
import { getDomNodePagePosition } from '../../../../base/browser/dom.js';
15-
import { IMcpSamplingService, IMcpServer, IMcpServerContainer, IMcpService, IMcpWorkbenchService, IWorkbenchMcpServer, McpCapability, McpConnectionState } from '../common/mcpTypes.js';
16-
import { IMcpRegistry } from '../common/mcpRegistryTypes.js';
17-
import { URI } from '../../../../base/common/uri.js';
18-
import { Location } from '../../../../editor/common/languages.js';
15+
import { IMcpSamplingService, IMcpServer, IMcpServerContainer, IMcpService, IMcpWorkbenchService, IWorkbenchMcpServer, McpCapability, McpConnectionState, McpServerEditorTab } from '../common/mcpTypes.js';
1916
import { IEditorService } from '../../../services/editor/common/editorService.js';
2017
import { ICommandService } from '../../../../platform/commands/common/commands.js';
2118
import { McpCommandIds } from '../common/mcpCommandIds.js';
@@ -540,9 +537,7 @@ export class ShowServerConfigurationAction extends McpServerAction {
540537
private static readonly HIDE = `${this.CLASS} hide`;
541538

542539
constructor(
543-
@IMcpService private readonly mcpService: IMcpService,
544-
@IMcpRegistry private readonly mcpRegistry: IMcpRegistry,
545-
@IEditorService private readonly editorService: IEditorService,
540+
@IMcpWorkbenchService private readonly mcpWorkbenchService: IMcpWorkbenchService
546541
) {
547542
super('extensions.config', localize('config', "Show Configuration"), ShowServerConfigurationAction.CLASS, false);
548543
this.update();
@@ -551,8 +546,7 @@ export class ShowServerConfigurationAction extends McpServerAction {
551546
update(): void {
552547
this.enabled = false;
553548
this.class = ShowServerConfigurationAction.HIDE;
554-
const configurationTarget = this.getConfigurationTarget();
555-
if (!configurationTarget) {
549+
if (!this.mcpServer?.local) {
556550
return;
557551
}
558552
this.class = ShowServerConfigurationAction.CLASS;
@@ -561,31 +555,12 @@ export class ShowServerConfigurationAction extends McpServerAction {
561555
}
562556

563557
override async run(): Promise<any> {
564-
const configurationTarget = this.getConfigurationTarget();
565-
if (!configurationTarget) {
558+
if (!this.mcpServer?.local) {
566559
return;
567560
}
568-
this.editorService.openEditor({
569-
resource: URI.isUri(configurationTarget) ? configurationTarget : configurationTarget!.uri,
570-
options: { selection: URI.isUri(configurationTarget) ? undefined : configurationTarget!.range }
571-
});
561+
this.mcpWorkbenchService.open(this.mcpServer, { tab: McpServerEditorTab.Configuration });
572562
}
573563

574-
private getConfigurationTarget(): Location | URI | undefined {
575-
if (!this.mcpServer) {
576-
return;
577-
}
578-
if (!this.mcpServer.local) {
579-
return;
580-
}
581-
const server = this.mcpService.servers.get().find(s => s.definition.label === this.mcpServer?.name);
582-
if (!server) {
583-
return;
584-
}
585-
const collection = this.mcpRegistry.collections.get().find(c => c.id === server.collection.id);
586-
const serverDefinition = collection?.serverDefinitions.get().find(s => s.id === server.definition.id);
587-
return serverDefinition?.presentation?.origin || collection?.presentation?.origin;
588-
}
589564
}
590565

591566
export class ConfigureModelAccessAction extends McpServerAction {

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ import { IWebview, IWebviewService } from '../../webview/browser/webview.js';
3737
import { IEditorGroup } from '../../../services/editor/common/editorGroupsService.js';
3838
import { IExtensionService } from '../../../services/extensions/common/extensions.js';
3939
import { IHoverService } from '../../../../platform/hover/browser/hover.js';
40-
import { IWorkbenchMcpServer, McpServerContainers } from '../common/mcpTypes.js';
40+
import { IMcpServerEditorOptions, IWorkbenchMcpServer, McpServerContainers } from '../common/mcpTypes.js';
4141
import { InstallCountWidget, McpServerIconWidget, McpServerWidget, onClick, PublisherWidget, RatingsWidget } from './mcpServerWidgets.js';
4242
import { DropDownAction, InstallAction, ManageMcpServerAction, UninstallAction } from './mcpServerActions.js';
4343
import { McpServerEditorInput } from './mcpServerEditorInput.js';
44-
import { IEditorOptions } from '../../../../platform/editor/common/editor.js';
4544
import { ILocalMcpServer, IMcpServerManifest, IMcpServerPackage, PackageType } from '../../../../platform/mcp/common/mcpManagement.js';
4645
import { IActionViewItemOptions } from '../../../../base/browser/ui/actionbar/actionViewItems.js';
4746
import { McpServerType } from '../../../../platform/mcp/common/mcpPlatformTypes.js';
@@ -286,7 +285,7 @@ export class McpServerEditor extends EditorPane {
286285
};
287286
}
288287

289-
override async setInput(input: McpServerEditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
288+
override async setInput(input: McpServerEditorInput, options: IMcpServerEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
290289
await super.setInput(input, options, context, token);
291290
if (this.template) {
292291
await this.render(input.mcpServer, this.template, !!options?.preserveFocus);
@@ -313,6 +312,13 @@ export class McpServerEditor extends EditorPane {
313312
this.renderNavbar(mcpServer, template, preserveFocus);
314313
}
315314

315+
override setOptions(options: IMcpServerEditorOptions | undefined): void {
316+
super.setOptions(options);
317+
if (options?.tab) {
318+
this.template?.navbar.switch(options.tab);
319+
}
320+
}
321+
316322
private renderNavbar(extension: IWorkbenchMcpServer, template: IExtensionEditorTemplate, preserveFocus: boolean): void {
317323
template.content.innerText = '';
318324
template.navbar.clear();
@@ -334,6 +340,10 @@ export class McpServerEditor extends EditorPane {
334340
template.navbar.push(McpServerEditorTab.Manifest, localize('manifest', "Manifest"), localize('manifesttooltip', "Server manifest details"));
335341
}
336342

343+
if ((<IMcpServerEditorOptions | undefined>this.options)?.tab) {
344+
template.navbar.switch((<IMcpServerEditorOptions>this.options).tab!);
345+
}
346+
337347
if (template.navbar.currentId) {
338348
this.onNavbarChange(extension, { id: template.navbar.currentId, focus: !preserveFocus }, template);
339349
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,24 @@ export interface IMcpServerContainer extends IDisposable {
569569
update(): void;
570570
}
571571

572+
export interface IMcpServerEditorOptions extends IEditorOptions {
573+
tab?: McpServerEditorTab;
574+
sideByside?: boolean;
575+
}
576+
572577
export const enum McpServerInstallState {
573578
Installing,
574579
Installed,
575580
Uninstalling,
576581
Uninstalled
577582
}
578583

584+
export const enum McpServerEditorTab {
585+
Readme = 'readme',
586+
Manifest = 'manifest',
587+
Configuration = 'configuration',
588+
}
589+
579590
export interface IWorkbenchMcpServer {
580591
readonly gallery: IGalleryMcpServer | undefined;
581592
readonly local: IWorkbenchLocalMcpServer | undefined;
@@ -615,7 +626,7 @@ export interface IMcpWorkbenchService {
615626
uninstall(mcpServer: IWorkbenchMcpServer): Promise<void>;
616627
getMcpConfigPath(arg: IWorkbenchLocalMcpServer): IMcpConfigPath | undefined;
617628
getMcpConfigPath(arg: URI): Promise<IMcpConfigPath | undefined>;
618-
open(extension: IWorkbenchMcpServer | string, options?: IEditorOptions): Promise<void>;
629+
open(extension: IWorkbenchMcpServer | string, options?: IMcpServerEditorOptions): Promise<void>;
619630
}
620631

621632
export class McpServerContainers extends Disposable {

0 commit comments

Comments
 (0)