-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(cli): MCP add/remove now correctly persists headers and server deletions #3973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| // File for 'qwen mcp remove' command | ||
| import type { CommandModule } from 'yargs'; | ||
| import { loadSettings, SettingScope } from '../../config/settings.js'; | ||
| import { writeStdoutLine } from '../../utils/stdioHelpers.js'; | ||
| import { writeStdoutLine, writeStderrLine } from '../../utils/stdioHelpers.js'; | ||
| import { MCPOAuthTokenStorage } from '@qwen-code/qwen-code-core'; | ||
|
|
||
| async function removeMcpServer( | ||
|
|
@@ -20,9 +20,20 @@ async function removeMcpServer( | |
| const settingsScope = | ||
| scope === 'user' ? SettingScope.User : SettingScope.Workspace; | ||
| const settings = loadSettings(); | ||
| const inHome = settings.workspace.path === settings.user.path; | ||
|
|
||
| const existingSettings = settings.forScope(settingsScope).settings; | ||
| const mcpServers = existingSettings.mcpServers || {}; | ||
| if (scope === 'project' && inHome) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new Consider adding similar tests to |
||
| writeStderrLine( | ||
| 'Error: Please use --scope user to edit settings in the home directory.', | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const existingSettings = settings.forScope(settingsScope).originalSettings; | ||
| const mcpServers = (existingSettings.mcpServers || {}) as Record< | ||
| string, | ||
| Record<string, unknown> | ||
| >; | ||
|
|
||
| if (!mcpServers[name]) { | ||
| writeStdoutLine(`Server "${name}" not found in ${scope} settings.`); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion]
existingSettings = settings.forScope(scope).settingsreads the already-resolved copy (viaresolveEnvVarsInObject). WhensetValueFullSavewrites this resolved value intooriginalSettings(the pre-resolution copy),${ENV_VAR}tokens inmcpServerswill be replaced with actual values and persisted to disk. Consider reading fromoriginalSettingsto preserve the original references:— DeepSeek/deepseek-v4-pro via Qwen Code /review