@@ -11,7 +11,9 @@ import { Emitter } from '../../../../base/common/event.js';
11
11
import { IMarkdownString , MarkdownString } from '../../../../base/common/htmlContent.js' ;
12
12
import { disposeIfDisposable } from '../../../../base/common/lifecycle.js' ;
13
13
import { ThemeIcon } from '../../../../base/common/themables.js' ;
14
+ import { URI } from '../../../../base/common/uri.js' ;
14
15
import { localize } from '../../../../nls.js' ;
16
+ import { Location } from '../../../../editor/common/languages.js' ;
15
17
import { ICommandService } from '../../../../platform/commands/common/commands.js' ;
16
18
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js' ;
17
19
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
@@ -22,6 +24,7 @@ import { IAccountQuery, IAuthenticationQueryService } from '../../../services/au
22
24
import { IEditorService } from '../../../services/editor/common/editorService.js' ;
23
25
import { errorIcon , infoIcon , manageExtensionIcon , trustIcon , warningIcon } from '../../extensions/browser/extensionsIcons.js' ;
24
26
import { McpCommandIds } from '../common/mcpCommandIds.js' ;
27
+ import { IMcpRegistry } from '../common/mcpRegistryTypes.js' ;
25
28
import { IMcpSamplingService , IMcpServer , IMcpServerContainer , IMcpService , IMcpWorkbenchService , IWorkbenchMcpServer , McpCapability , McpConnectionState , McpServerEditorTab , McpServerInstallState } from '../common/mcpTypes.js' ;
26
29
27
30
export abstract class McpServerAction extends Action implements IMcpServerContainer {
@@ -234,6 +237,7 @@ export class ManageMcpServerAction extends DropDownAction {
234
237
groups . push ( [
235
238
this . instantiationService . createInstance ( ShowServerOutputAction ) ,
236
239
this . instantiationService . createInstance ( ShowServerConfigurationAction ) ,
240
+ this . instantiationService . createInstance ( ShowServerJsonConfigurationAction ) ,
237
241
] ) ;
238
242
groups . push ( [
239
243
this . instantiationService . createInstance ( ConfigureModelAccessAction ) ,
@@ -574,7 +578,6 @@ export class ShowServerConfigurationAction extends McpServerAction {
574
578
}
575
579
this . class = ShowServerConfigurationAction . CLASS ;
576
580
this . enabled = true ;
577
- this . label = localize ( 'config' , "Show Configuration" ) ;
578
581
}
579
582
580
583
override async run ( ) : Promise < any > {
@@ -586,6 +589,59 @@ export class ShowServerConfigurationAction extends McpServerAction {
586
589
587
590
}
588
591
592
+ export class ShowServerJsonConfigurationAction extends McpServerAction {
593
+
594
+ static readonly CLASS = `${ this . LABEL_ACTION_CLASS } prominent config` ;
595
+ private static readonly HIDE = `${ this . CLASS } hide` ;
596
+
597
+ constructor (
598
+ @IMcpService private readonly mcpService : IMcpService ,
599
+ @IMcpRegistry private readonly mcpRegistry : IMcpRegistry ,
600
+ @IEditorService private readonly editorService : IEditorService ,
601
+ ) {
602
+ super ( 'extensions.jsonConfig' , localize ( 'configJson' , "Show Configuration (JSON)" ) , ShowServerJsonConfigurationAction . CLASS , false ) ;
603
+ this . update ( ) ;
604
+ }
605
+
606
+ update ( ) : void {
607
+ this . enabled = false ;
608
+ this . class = ShowServerJsonConfigurationAction . HIDE ;
609
+ const configurationTarget = this . getConfigurationTarget ( ) ;
610
+ if ( ! configurationTarget ) {
611
+ return ;
612
+ }
613
+ this . class = ShowServerConfigurationAction . CLASS ;
614
+ this . enabled = true ;
615
+ }
616
+
617
+ override async run ( ) : Promise < any > {
618
+ const configurationTarget = this . getConfigurationTarget ( ) ;
619
+ if ( ! configurationTarget ) {
620
+ return ;
621
+ }
622
+ this . editorService . openEditor ( {
623
+ resource : URI . isUri ( configurationTarget ) ? configurationTarget : configurationTarget ! . uri ,
624
+ options : { selection : URI . isUri ( configurationTarget ) ? undefined : configurationTarget ! . range }
625
+ } ) ;
626
+ }
627
+
628
+ private getConfigurationTarget ( ) : Location | URI | undefined {
629
+ if ( ! this . mcpServer ) {
630
+ return ;
631
+ }
632
+ if ( ! this . mcpServer . local ) {
633
+ return ;
634
+ }
635
+ const server = this . mcpService . servers . get ( ) . find ( s => s . definition . label === this . mcpServer ?. name ) ;
636
+ if ( ! server ) {
637
+ return ;
638
+ }
639
+ const collection = this . mcpRegistry . collections . get ( ) . find ( c => c . id === server . collection . id ) ;
640
+ const serverDefinition = collection ?. serverDefinitions . get ( ) . find ( s => s . id === server . definition . id ) ;
641
+ return serverDefinition ?. presentation ?. origin || collection ?. presentation ?. origin ;
642
+ }
643
+ }
644
+
589
645
export class ConfigureModelAccessAction extends McpServerAction {
590
646
591
647
static readonly CLASS = `${ this . LABEL_ACTION_CLASS } prominent config` ;
0 commit comments