Skip to content

Commit e2a90e9

Browse files
authored
Revert "Adopt mcp token flag " (#251408)
Revert "Adopt mcp token flag (#251297)" This reverts commit 3aaf8f9.
1 parent aa3933c commit e2a90e9

File tree

3 files changed

+28
-56
lines changed

3 files changed

+28
-56
lines changed

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,12 @@ configurationRegistry.registerConfiguration({
249249
type: 'boolean',
250250
description: nls.localize('chat.mcp.enabled', "Enables integration with Model Context Protocol servers to provide additional tools and functionality."),
251251
default: true,
252+
tags: ['preview'],
252253
policy: {
253254
name: 'ChatMCP',
254255
minimumVersion: '1.99',
256+
previewFeature: true,
257+
defaultValue: false
255258
}
256259
},
257260
[mcpServerSamplingSection]: {

src/vs/workbench/services/accounts/common/defaultAccount.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export interface IDefaultAccount {
3636
readonly can_signup_for_limited?: boolean;
3737
readonly chat_enabled?: boolean;
3838
readonly chat_preview_features_enabled?: boolean;
39-
readonly mcp?: boolean;
4039
readonly analytics_tracking_id?: string;
4140
readonly limited_user_quotas?: {
4241
readonly chat: number;
@@ -190,15 +189,15 @@ export class DefaultAccountManagementContribution extends Disposable implements
190189
}
191190
}
192191

193-
private extractFromToken(token: string): Map<string, string> {
192+
private extractFromToken(token: string, key: string): string | undefined {
194193
const result = new Map<string, string>();
195194
const firstPart = token?.split(':')[0];
196195
const fields = firstPart?.split(';');
197196
for (const field of fields) {
198197
const [key, value] = field.split('=');
199198
result.set(key, value);
200199
}
201-
return result;
200+
return result.get(key);
202201
}
203202

204203
private async getDefaultAccountFromAuthenticatedSessions(authProviderId: string, enterpriseAuthProviderId: string, enterpriseAuthProviderConfig: string, scopes: string[], tokenEntitlementUrl: string, chatEntitlementUrl: string): Promise<IDefaultAccount | null> {
@@ -244,12 +243,9 @@ export class DefaultAccountManagementContribution extends Disposable implements
244243

245244
const chatData = await asJson<ITokenEntitlementsResponse>(chatContext);
246245
if (chatData) {
247-
const tokenMap = this.extractFromToken(chatData.token);
248246
return {
249247
// Editor preview features are disabled if the flag is present and set to 0
250-
chat_preview_features_enabled: tokenMap.get('editor_preview_features') !== '0',
251-
// MCP is disabled if the flag is present and set to 0
252-
mcp: tokenMap.get('mcp') !== '0',
248+
chat_preview_features_enabled: this.extractFromToken(chatData.token, 'editor_preview_features') !== '0',
253249
};
254250
}
255251
this.logService.error('Failed to fetch token entitlements', 'No data returned');

src/vs/workbench/services/policies/common/accountPolicyService.ts

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IStringDictionary } from '../../../../base/common/collections.js';
7-
import { equals } from '../../../../base/common/objects.js';
87
import { ILogService } from '../../../../platform/log/common/log.js';
98
import { AbstractPolicyService, IPolicyService, PolicyDefinition } from '../../../../platform/policy/common/policy.js';
109
import { IDefaultAccountService } from '../../accounts/common/defaultAccount.js';
1110

12-
interface IAccountPolicy {
13-
readonly chatPreviewFeaturesEnabled: boolean;
14-
readonly mcpEnabled: boolean;
15-
}
16-
1711
export class AccountPolicyService extends AbstractPolicyService implements IPolicyService {
18-
private accountPolicy: IAccountPolicy = {
19-
chatPreviewFeaturesEnabled: true,
20-
mcpEnabled: true
21-
};
12+
private chatPreviewFeaturesEnabled: boolean = true;
2213
constructor(
2314
@ILogService private readonly logService: ILogService,
2415
@IDefaultAccountService private readonly defaultAccountService: IDefaultAccountService
@@ -27,61 +18,43 @@ export class AccountPolicyService extends AbstractPolicyService implements IPoli
2718

2819
this.defaultAccountService.getDefaultAccount()
2920
.then(account => {
30-
this._update({
31-
chatPreviewFeaturesEnabled: account?.chat_preview_features_enabled ?? true,
32-
mcpEnabled: account?.mcp ?? true
33-
});
34-
this._register(this.defaultAccountService.onDidChangeDefaultAccount(
35-
account => this._update({
36-
chatPreviewFeaturesEnabled: account?.chat_preview_features_enabled ?? true,
37-
mcpEnabled: account?.mcp ?? true
38-
})
39-
));
21+
this._update(account?.chat_preview_features_enabled ?? true);
22+
this._register(this.defaultAccountService.onDidChangeDefaultAccount(account => this._update(account?.chat_preview_features_enabled ?? true)));
4023
});
4124
}
4225

43-
private _update(updatedPolicy: IAccountPolicy): void {
44-
if (!equals(this.accountPolicy, updatedPolicy)) {
45-
this.accountPolicy = updatedPolicy;
26+
private _update(chatPreviewFeaturesEnabled: boolean | undefined) {
27+
const newValue = (chatPreviewFeaturesEnabled === undefined) || chatPreviewFeaturesEnabled;
28+
if (this.chatPreviewFeaturesEnabled !== newValue) {
29+
this.chatPreviewFeaturesEnabled = newValue;
4630
this._updatePolicyDefinitions(this.policyDefinitions);
4731
}
4832
}
4933

5034
protected async _updatePolicyDefinitions(policyDefinitions: IStringDictionary<PolicyDefinition>): Promise<void> {
5135
this.logService.trace(`AccountPolicyService#_updatePolicyDefinitions: Got ${Object.keys(policyDefinitions).length} policy definitions`);
52-
const updated: string[] = [];
53-
54-
const updateIfNeeded = (key: string, policy: PolicyDefinition, isFeatureEnabled: boolean): void => {
55-
if (isFeatureEnabled) {
56-
// Clear the policy if it is set
57-
if (this.policies.has(key)) {
58-
this.policies.delete(key);
59-
updated.push(key);
60-
}
61-
} else {
62-
// Enforce the defaultValue if not already set
63-
const updatedValue = policy.defaultValue === undefined ? false : policy.defaultValue;
64-
if (this.policies.get(key) !== updatedValue) {
65-
this.policies.set(key, updatedValue);
66-
updated.push(key);
67-
}
68-
}
69-
};
7036

37+
const update: string[] = [];
7138
for (const key in policyDefinitions) {
7239
const policy = policyDefinitions[key];
73-
// Preview Features
7440
if (policy.previewFeature) {
75-
updateIfNeeded(key, policy, this.accountPolicy?.chatPreviewFeaturesEnabled);
76-
}
77-
// MCP
78-
else if (key === 'ChatMCP') {
79-
updateIfNeeded(key, policy, this.accountPolicy?.mcpEnabled);
41+
if (this.chatPreviewFeaturesEnabled) {
42+
this.policies.delete(key);
43+
update.push(key);
44+
continue;
45+
}
46+
const defaultValue = policy.defaultValue;
47+
const updatedValue = defaultValue === undefined ? false : defaultValue;
48+
if (this.policies.get(key) === updatedValue) {
49+
continue;
50+
}
51+
this.policies.set(key, updatedValue);
52+
update.push(key);
8053
}
8154
}
8255

83-
if (updated.length) {
84-
this._onDidChange.fire(updated);
56+
if (update.length) {
57+
this._onDidChange.fire(update);
8558
}
8659
}
8760
}

0 commit comments

Comments
 (0)