Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Schemas } from '../../../../base/common/network.js';
7
import { URI } from '../../../../base/common/uri.js';
8
import { localize } from '../../../../nls.js';
9
import { EditorInputCapabilities, IUntypedEditorInput } from '../../../common/editor.js';
10
import { EditorInput } from '../../../common/editor/editorInput.js';
11
import { join } from '../../../../base/common/path.js';
12
import { ThemeIcon } from '../../../../base/common/themables.js';
13
import { Codicon } from '../../../../base/common/codicons.js';
14
import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';
15
import { IWorkbenchMcpServer } from '../common/mcpTypes.js';
16
17
const MCPServerEditorIcon = registerIcon('mcp-server-editor-icon', Codicon.mcp, localize('mcpServerEditorLabelIcon', 'Icon of the MCP Server editor.'));
18
19
export class McpServerEditorInput extends EditorInput {
20
21
static readonly ID = 'workbench.mcpServer.input2';
22
23
override get typeId(): string {
24
return McpServerEditorInput.ID;
25
}
26
27
override get capabilities(): EditorInputCapabilities {
28
return EditorInputCapabilities.Readonly | EditorInputCapabilities.Singleton;
29
}
30
31
override get resource() {
32
return URI.from({
33
scheme: Schemas.extension,
34
path: join(this.mcpServer.id, 'mcpServer')
35
});
36
}
37
38
constructor(private _mcpServer: IWorkbenchMcpServer) {
39
super();
40
}
41
42
get mcpServer(): IWorkbenchMcpServer { return this._mcpServer; }
43
44
override getName(): string {
45
return localize('extensionsInputName', "MCP Server: {0}", this._mcpServer.label);
46
}
47
48
override getIcon(): ThemeIcon | undefined {
49
return MCPServerEditorIcon;
50
}
51
52
override matches(other: EditorInput | IUntypedEditorInput): boolean {
53
if (super.matches(other)) {
54
return true;
55
}
56
57
return other instanceof McpServerEditorInput && this._mcpServer.name === other._mcpServer.name;
58
}
59
}
60
61