Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f4d4a05
fix(memory): route auto-memory recall selector to fast model
B-A-M-N May 5, 2026
97688e7
feat(cli): polish --add-dir / --include-directories feature
B-A-M-N May 5, 2026
fc44af6
fix(directory): address review comments on /directory remove command
B-A-M-N May 6, 2026
112d5ff
fix(i18n): add zh and zh-TW translations for /directory remove command
B-A-M-N May 6, 2026
5e306fc
fix(core): retry API request on model-unloaded errors for local model…
B-A-M-N May 7, 2026
5a58502
fix(cli): MCP add/remove now correctly persists headers and server de…
B-A-M-N May 7, 2026
d09381c
fix(cli): merge origin/main into fix/mcp-add-remove-persist
B-A-M-N May 8, 2026
e31e1c8
fix(cli): address review comments on MCP persist and directory remove
B-A-M-N May 8, 2026
b9a8206
fix: address PR #3937 review feedback
B-A-M-N May 8, 2026
f654062
refactor(cli): provider-first auth registry with unified install pipe…
pomelo-nwu May 8, 2026
876c260
fix(core): split prior-read enforcement: partial-OK for Edit, full-re…
wenshao May 8, 2026
d8354b2
fix(cli,core): live-phase panel-ownership filter + post-delete status…
wenshao May 8, 2026
4c07b97
fix(core): close bound-tool gap on runForkedAgent's YOLO wrapper (#3892)
wenshao May 8, 2026
f43f5aa
feat(sdk-python): replace verbatim release notes inheritance with --g…
doudouOUC May 8, 2026
0696f29
ci(release): keep skip-ci out of release PR titles (#3950)
yiliang114 May 8, 2026
bb6ebf0
fix(vscode): mark Qwen OAuth coder-model as Discontinued in model pic…
dreamWB May 8, 2026
4b9377c
chore: Add bilingual requirement to create-issue command (#3952)
pomelo-nwu May 8, 2026
9022aa0
feat(cli): add Idealab as third-party provider (#3955)
pomelo-nwu May 8, 2026
9bd9d5d
feat(session): add /branch to fork the current conversation (#3539)
qqqys May 8, 2026
1fc4b87
feat(core): foreground → background promote integration (#3831 PR-2 o…
wenshao May 8, 2026
4be5a58
fix(cli): show tool details in subagent approval banner (#3956)
tanzhenxin May 8, 2026
60157ec
fix(cli): persist ACP model selection (#3947)
DragonnZhang May 8, 2026
4a817fe
fix(cli): trim blank streaming tails from live preview (#3965)
chiga0 May 8, 2026
cc71b1b
fix(memory): route auto-memory recall selector to fast model
B-A-M-N May 5, 2026
f1f751f
fix(cli): setValueFullSave must write full file to delete keys; fix(p…
B-A-M-N May 8, 2026
3579586
fix(cli): address PR #3937 review feedback
B-A-M-N May 8, 2026
112dde5
fix(test): move stream retry describe block out of createRequestConte…
B-A-M-N May 8, 2026
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ storybook-static

# Dev symlink: qc-helper bundled skill docs (created by scripts/dev.js)
packages/core/src/skills/bundled/qc-helper/docs
tmp/
tmp/.prforge/
.prforge-run
.prforge-*
145 changes: 110 additions & 35 deletions packages/cli/src/commands/mcp/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ const mockedLoadSettings = loadSettings as Mock;

describe('mcp add command', () => {
let parser: Argv;
let mockSetValue: Mock;
let mockSetValueFullSave: Mock;

beforeEach(() => {
vi.resetAllMocks();
const yargsInstance = yargs([]).command(addCommand);
parser = yargsInstance;
mockSetValue = vi.fn();
mockSetValueFullSave = vi.fn();
mockWriteStderrLine.mockClear();
mockedLoadSettings.mockReturnValue({
forScope: () => ({ settings: {} }),
setValue: mockSetValue,
forScope: () => ({ settings: {}, originalSettings: {} }),
setValueFullSave: mockSetValueFullSave,
workspace: { path: '/path/to/project' },
user: { path: '/home/user' },
});
Expand All @@ -72,7 +72,7 @@ describe('mcp add command', () => {
'add my-server /path/to/server arg1 arg2 -e FOO=bar',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'my-server': {
command: '/path/to/server',
args: ['arg1', 'arg2'],
Expand All @@ -84,7 +84,7 @@ describe('mcp add command', () => {
it('should auto-detect http transport when commandOrUrl is an https URL', async () => {
await parser.parseAsync('add http-server https://example.com/mcp');

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'http-server': {
httpUrl: 'https://example.com/mcp',
},
Expand All @@ -94,7 +94,7 @@ describe('mcp add command', () => {
it('should auto-detect http transport when commandOrUrl is an http URL', async () => {
await parser.parseAsync('add http-server http://localhost:8080/mcp');

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'http-server': {
httpUrl: 'http://localhost:8080/mcp',
},
Expand All @@ -106,7 +106,7 @@ describe('mcp add command', () => {
'add --transport sse sse-server https://example.com/sse-endpoint',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'sse-server': {
url: 'https://example.com/sse-endpoint',
},
Expand All @@ -118,7 +118,7 @@ describe('mcp add command', () => {
'add --transport sse sse-server https://example.com/sse-endpoint --scope user -H "X-API-Key: your-key"',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'sse-server': {
url: 'https://example.com/sse-endpoint',
headers: { 'X-API-Key': 'your-key' },
Expand All @@ -131,7 +131,7 @@ describe('mcp add command', () => {
'add --transport http http-server https://example.com/mcp -H "Authorization: Bearer your-token"',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'http-server': {
httpUrl: 'https://example.com/mcp',
headers: { Authorization: 'Bearer your-token' },
Expand All @@ -144,7 +144,7 @@ describe('mcp add command', () => {
'add my-server npx -- -y http://example.com/some-package',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'my-server': {
command: 'npx',
args: ['-y', 'http://example.com/some-package'],
Expand All @@ -157,7 +157,7 @@ describe('mcp add command', () => {
'add test-server npx -y http://example.com/some-package',
);

expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
expect(mockSetValueFullSave).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'test-server': {
command: 'npx',
args: ['-y', 'http://example.com/some-package'],
Expand All @@ -172,8 +172,8 @@ describe('mcp add command', () => {
const setupMocks = (cwd: string, workspacePath: string) => {
vi.spyOn(process, 'cwd').mockReturnValue(cwd);
mockedLoadSettings.mockReturnValue({
forScope: () => ({ settings: {} }),
setValue: mockSetValue,
forScope: () => ({ settings: {}, originalSettings: {} }),
setValueFullSave: mockSetValueFullSave,
workspace: { path: workspacePath },
user: { path: '/home/user' },
});
Expand All @@ -186,7 +186,7 @@ describe('mcp add command', () => {

it('should use user scope by default', async () => {
await parser.parseAsync(`add ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -195,7 +195,7 @@ describe('mcp add command', () => {

it('should use project scope when --scope=project is used', async () => {
await parser.parseAsync(`add --scope project ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.Workspace,
'mcpServers',
expect.any(Object),
Expand All @@ -204,7 +204,7 @@ describe('mcp add command', () => {

it('should use user scope when --scope=user is used', async () => {
await parser.parseAsync(`add --scope user ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -219,7 +219,7 @@ describe('mcp add command', () => {

it('should use user scope by default', async () => {
await parser.parseAsync(`add ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -234,7 +234,7 @@ describe('mcp add command', () => {

it('should use user scope by default without error', async () => {
await parser.parseAsync(`add ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -257,12 +257,12 @@ describe('mcp add command', () => {
'Error: Please use --scope user to edit settings in the home directory.',
);
expect(mockProcessExit).toHaveBeenCalledWith(1);
expect(mockSetValue).not.toHaveBeenCalled();
expect(mockSetValueFullSave).not.toHaveBeenCalled();
});

it('should use user scope when --scope=user is used', async () => {
await parser.parseAsync(`add --scope user ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -278,7 +278,7 @@ describe('mcp add command', () => {

it('should use user scope by default', async () => {
await parser.parseAsync(`add ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -288,11 +288,11 @@ describe('mcp add command', () => {
it('should write to the USER scope by default', async () => {
await parser.parseAsync(`add my-new-server echo`);

// We expect setValue to be called once.
expect(mockSetValue).toHaveBeenCalledTimes(1);
// We expect setValueFullSave to be called once.
expect(mockSetValueFullSave).toHaveBeenCalledTimes(1);

// We get the scope that setValue was called with.
const calledScope = mockSetValue.mock.calls[0][0];
// We get the scope that setValueFullSave was called with.
const calledScope = mockSetValueFullSave.mock.calls[0][0];

// We assert that the scope was User by default.
expect(calledScope).toBe(SettingScope.User);
Expand All @@ -306,7 +306,7 @@ describe('mcp add command', () => {

it('should use user scope by default', async () => {
await parser.parseAsync(`add ${serverName} ${command}`);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.any(Object),
Expand All @@ -331,8 +331,15 @@ describe('mcp add command', () => {
},
},
},
originalSettings: {
mcpServers: {
[serverName]: {
command: initialCommand,
},
},
},
}),
setValue: mockSetValue,
setValueFullSave: mockSetValueFullSave,
workspace: { path: '/path/to/project' },
user: { path: '/home/user' },
});
Expand All @@ -342,7 +349,7 @@ describe('mcp add command', () => {
await parser.parseAsync(
`add ${serverName} ${updatedCommand} ${updatedArgs.join(' ')}`,
);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand All @@ -358,7 +365,7 @@ describe('mcp add command', () => {
await parser.parseAsync(
`add --scope user ${serverName} ${updatedCommand} ${updatedArgs.join(' ')}`,
);
expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand All @@ -371,6 +378,74 @@ describe('mcp add command', () => {
});
});

describe('when updating an existing server with headers', () => {
const serverName = 'existing-http-server';

beforeEach(() => {
mockedLoadSettings.mockReturnValue({
forScope: () => ({
settings: {
mcpServers: {
[serverName]: {
httpUrl: 'https://example.com/mcp',
headers: { 'X-Old-Key': 'old-value' },
},
},
},
originalSettings: {
mcpServers: {
[serverName]: {
httpUrl: 'https://example.com/mcp',
headers: { 'X-Old-Key': 'old-value' },
},
},
},
}),
setValueFullSave: mockSetValueFullSave,
workspace: { path: '/path/to/project' },
user: { path: '/home/user' },
});
});

it('should replace old headers when updating a server with new headers', async () => {
await parser.parseAsync(
`add --transport http ${serverName} https://example.com/mcp -H "Authorization: Bearer new-token"`,
);
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
[serverName]: expect.objectContaining({
httpUrl: 'https://example.com/mcp',
headers: { Authorization: 'Bearer new-token' },
}),
}),
);
// Verify old header is not present
const callArg = mockSetValueFullSave.mock.calls[0][2];
const serverConfig = callArg[serverName];
expect(serverConfig.headers).not.toHaveProperty('X-Old-Key');
});

it('should remove headers when updating a server without headers', async () => {
await parser.parseAsync(
`add --transport http ${serverName} https://example.com/mcp`,
);
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
[serverName]: expect.objectContaining({
httpUrl: 'https://example.com/mcp',
}),
}),
);
const callArg = mockSetValueFullSave.mock.calls[0][2];
const serverConfig = callArg[serverName];
expect(serverConfig).not.toHaveProperty('headers');
});
});

describe('OAuth configuration', () => {
it('should add OAuth config when OAuth options are provided', async () => {
await parser.parseAsync(
Expand All @@ -383,7 +458,7 @@ describe('mcp add command', () => {
'--oauth-scopes read,write',
);

expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand All @@ -409,7 +484,7 @@ describe('mcp add command', () => {
'--oauth-redirect-uri https://example.com/oauth/callback',
);

expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand All @@ -429,7 +504,7 @@ describe('mcp add command', () => {
'add my-server https://example.com/mcp --transport http',
);

expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand Down Expand Up @@ -460,7 +535,7 @@ describe('mcp add command', () => {
),
);
expect(mockProcessExit).toHaveBeenCalledWith(1);
expect(mockSetValue).not.toHaveBeenCalled();
expect(mockSetValueFullSave).not.toHaveBeenCalled();
});

it('should split comma-separated scopes and trim whitespace', async () => {
Expand All @@ -469,7 +544,7 @@ describe('mcp add command', () => {
'--oauth-scopes "read, write , admin"',
);

expect(mockSetValue).toHaveBeenCalledWith(
expect(mockSetValueFullSave).toHaveBeenCalledWith(
SettingScope.User,
'mcpServers',
expect.objectContaining({
Expand Down
Loading