Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/mcp/common/allowedMcpServersService.ts
5292 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 { Disposable } from '../../../base/common/lifecycle.js';
7
import * as nls from '../../../nls.js';
8
import { createCommandUri, IMarkdownString, MarkdownString } from '../../../base/common/htmlContent.js';
9
import { IConfigurationService } from '../../configuration/common/configuration.js';
10
import { Emitter } from '../../../base/common/event.js';
11
import { IAllowedMcpServersService, IGalleryMcpServer, IInstallableMcpServer, ILocalMcpServer, mcpAccessConfig, McpAccessValue } from './mcpManagement.js';
12
13
export class AllowedMcpServersService extends Disposable implements IAllowedMcpServersService {
14
15
_serviceBrand: undefined;
16
17
private _onDidChangeAllowedMcpServers = this._register(new Emitter<void>());
18
readonly onDidChangeAllowedMcpServers = this._onDidChangeAllowedMcpServers.event;
19
20
constructor(
21
@IConfigurationService private readonly configurationService: IConfigurationService
22
) {
23
super();
24
this._register(this.configurationService.onDidChangeConfiguration(e => {
25
if (e.affectsConfiguration(mcpAccessConfig)) {
26
this._onDidChangeAllowedMcpServers.fire();
27
}
28
}));
29
}
30
31
isAllowed(mcpServer: IGalleryMcpServer | ILocalMcpServer | IInstallableMcpServer): true | IMarkdownString {
32
if (this.configurationService.getValue(mcpAccessConfig) !== McpAccessValue.None) {
33
return true;
34
}
35
36
const settingsCommandLink = createCommandUri('workbench.action.openSettings', { query: `@id:${mcpAccessConfig}` }).toString();
37
return new MarkdownString(nls.localize('mcp servers are not allowed', "Model Context Protocol servers are disabled in the Editor. Please check your [settings]({0}).", settingsCommandLink));
38
}
39
}
40
41