Skip to content

Commit a1dc7a8

Browse files
authored
fix(cli): support comma separated values for extensions and allowed mcp server names (#9007)
1 parent 62b49ab commit a1dc7a8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/cli/src/config/config.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,23 @@ describe('parseArguments', () => {
307307
const argv = await parseArguments({} as Settings);
308308
expect(argv.allowedTools).toEqual(['read_file', 'ShellTool(git status)']);
309309
});
310+
311+
it('should support comma-separated values for --allowed-mcp-server-names', async () => {
312+
process.argv = [
313+
'node',
314+
'script.js',
315+
'--allowed-mcp-server-names',
316+
'server1,server2',
317+
];
318+
const argv = await parseArguments({} as Settings);
319+
expect(argv.allowedMcpServerNames).toEqual(['server1', 'server2']);
320+
});
321+
322+
it('should support comma-separated values for --extensions', async () => {
323+
process.argv = ['node', 'script.js', '--extensions', 'ext1,ext2'];
324+
const argv = await parseArguments({} as Settings);
325+
expect(argv.extensions).toEqual(['ext1', 'ext2']);
326+
});
310327
});
311328

312329
describe('loadCliConfig', () => {

packages/cli/src/config/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
229229
type: 'array',
230230
string: true,
231231
description: 'Allowed MCP server names',
232+
coerce: (mcpServerNames: string[]) =>
233+
// Handle comma-separated values
234+
mcpServerNames.flatMap((mcpServerName) =>
235+
mcpServerName.split(',').map((m) => m.trim()),
236+
),
232237
})
233238
.option('allowed-tools', {
234239
type: 'array',
@@ -244,6 +249,11 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
244249
string: true,
245250
description:
246251
'A list of extensions to use. If not provided, all extensions are used.',
252+
coerce: (extensions: string[]) =>
253+
// Handle comma-separated values
254+
extensions.flatMap((extension) =>
255+
extension.split(',').map((e) => e.trim()),
256+
),
247257
})
248258
.option('list-extensions', {
249259
alias: 'l',

0 commit comments

Comments
 (0)