Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/src/config/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe('Settings Loading and Merging', () => {
fileName: 'WORKSPACE_CONTEXT.md',
},
mcp: {
allowed: ['server1', 'server2'],
allowed: ['server1', 'server2', 'server3', 'server1', 'server2'],
},
});
});
Expand Down Expand Up @@ -1474,8 +1474,8 @@ describe('Settings Loading and Merging', () => {
const settings = loadSettings(MOCK_WORKSPACE_DIR);

expect(settings.merged.mcp).toEqual({
allowed: ['system-allowed'],
excluded: ['workspace-excluded'],
allowed: ['user-allowed', 'workspace-allowed', 'system-allowed'],
excluded: ['user-excluded', 'workspace-excluded'],
});
});

Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/config/settingsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ const SETTINGS_SCHEMA = {
default: undefined as string[] | undefined,
description: 'A list of MCP servers to allow.',
showInDialog: false,
mergeStrategy: MergeStrategy.CONCAT,
},
excluded: {
type: 'array',
Expand All @@ -1007,6 +1008,7 @@ const SETTINGS_SCHEMA = {
default: undefined as string[] | undefined,
description: 'A list of MCP servers to exclude.',
showInDialog: false,
mergeStrategy: MergeStrategy.CONCAT,
},
},
},
Expand Down
15 changes: 4 additions & 11 deletions packages/cli/src/ui/components/mcp/MCPManagementDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,10 @@ export const MCPManagementDialog: React.FC<MCPManagementDialogProps> = ({
let source: 'user' | 'project' | 'extension' = 'user';
if (serverConfig.extensionName) {
source = 'extension';
}

// Determine the scope of the configuration
let scope: 'user' | 'workspace' | 'extension' = 'user';
if (serverConfig.extensionName) {
scope = 'extension';
} else if (workspaceSettings.mcpServers?.[name]) {
scope = 'workspace';
source = 'project';
} else if (userSettings.mcpServers?.[name]) {
scope = 'user';
source = 'user';
}

// Use config.isMcpServerDisabled() to check if server is disabled
Expand All @@ -119,7 +113,6 @@ export const MCPManagementDialog: React.FC<MCPManagementDialogProps> = ({
name,
status,
source,
scope,
config: serverConfig,
toolCount: serverTools.length,
invalidToolCount,
Expand Down Expand Up @@ -343,15 +336,15 @@ export const MCPManagementDialog: React.FC<MCPManagementDialogProps> = ({

// Determine the scope based on server configuration location
let targetScope: 'user' | 'workspace' = 'user';
if (server.scope === 'extension') {
if (server.source === 'extension') {
// Extension servers should not be disabled through user/workspace settings
// Show error message and return
debugLogger.warn(
`Cannot disable extension MCP server '${server.name}'`,
);
setIsLoading(false);
return;
} else if (server.scope === 'workspace') {
} else if (server.source === 'project') {
targetScope = 'workspace';
}

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/components/mcp/steps/ServerDetailStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export const ServerDetailStep: React.FC<ServerDetailStepProps> = ({
</Box>
<Box>
<Text color={theme.text.primary}>
{server.scope === 'user'
{server.source === 'user'
? t('User Settings')
: server.scope === 'workspace'
: server.source === 'project'
? t('Workspace Settings')
: t('Extension')}
</Text>
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/ui/components/mcp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export interface MCPServerDisplayInfo {
status: MCPServerStatus;
/** 来源类型 */
source: 'user' | 'project' | 'extension';
/** 配置所在的 scope */
scope: 'user' | 'workspace' | 'extension';
/** 配置文件路径 */
configPath?: string;
/** 服务器配置 */
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/ui/components/mcp/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('MCP utils', () => {
name: 'server1',
status: MCPServerStatus.CONNECTED,
source: 'user',
scope: 'user',
config: { command: 'cmd1' },
toolCount: 1,
promptCount: 0,
Expand All @@ -35,7 +34,6 @@ describe('MCP utils', () => {
name: 'server2',
status: MCPServerStatus.CONNECTED,
source: 'extension',
scope: 'extension',
config: { command: 'cmd2' },
toolCount: 2,
promptCount: 0,
Expand Down