Path: blob/main/src/vs/workbench/contrib/mcp/browser/mcpServerEditorInput.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Schemas } from '../../../../base/common/network.js';6import { URI } from '../../../../base/common/uri.js';7import { localize } from '../../../../nls.js';8import { EditorInputCapabilities, IUntypedEditorInput } from '../../../common/editor.js';9import { EditorInput } from '../../../common/editor/editorInput.js';10import { join } from '../../../../base/common/path.js';11import { ThemeIcon } from '../../../../base/common/themables.js';12import { Codicon } from '../../../../base/common/codicons.js';13import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';14import { IWorkbenchMcpServer } from '../common/mcpTypes.js';1516const MCPServerEditorIcon = registerIcon('mcp-server-editor-icon', Codicon.mcp, localize('mcpServerEditorLabelIcon', 'Icon of the MCP Server editor.'));1718export class McpServerEditorInput extends EditorInput {1920static readonly ID = 'workbench.mcpServer.input2';2122override get typeId(): string {23return McpServerEditorInput.ID;24}2526override get capabilities(): EditorInputCapabilities {27return EditorInputCapabilities.Readonly | EditorInputCapabilities.Singleton;28}2930override get resource() {31return URI.from({32scheme: Schemas.extension,33path: join(this.mcpServer.id, 'mcpServer')34});35}3637constructor(private _mcpServer: IWorkbenchMcpServer) {38super();39}4041get mcpServer(): IWorkbenchMcpServer { return this._mcpServer; }4243override getName(): string {44return localize('extensionsInputName', "MCP Server: {0}", this._mcpServer.label);45}4647override getIcon(): ThemeIcon | undefined {48return MCPServerEditorIcon;49}5051override matches(other: EditorInput | IUntypedEditorInput): boolean {52if (super.matches(other)) {53return true;54}5556return other instanceof McpServerEditorInput && this._mcpServer.name === other._mcpServer.name;57}58}596061