Repository: google-gemini/gemini-cli (TypeScript)

Issue:
support comma separated lists for array args in cli
### What happened?

We support this for allowed tools and directories. We need to add support for extensions and allowed MCP server names.

### What did you expect to happen?

For all array args to accept comma separated lists.

### Client information

 About Gemini CLI                           │
│                                            │
│ CLI Version    0.5.5                       │
│ Git Commit     b7ece4ee                    │
│ Model          gemini-2.5-pro              │
│ Sandbox        no sandbox                  │
│ OS             darwin                      │
│ Auth Method    gemini-api-key              │
│ IDE Client     VS Code  

### Login information

_No response_

### Anything else we need to know?

_No response_


Discussion:
This is a feature request to improve the consistency of command-line argument parsing for array-type arguments. It's a low-priority enhancement for a core CLI component.



Patch:
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts
index aaa47e04c12..e5dd0c75108 100755
--- a/packages/cli/src/config/config.ts
+++ b/packages/cli/src/config/config.ts
@@ -229,6 +229,11 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
           type: 'array',
           string: true,
           description: 'Allowed MCP server names',
+          coerce: (mcpServerNames: string[]) =>
+            // Handle comma-separated values
+            mcpServerNames.flatMap((mcpServerName) =>
+              mcpServerName.split(',').map((m) => m.trim()),
+            ),
         })
         .option('allowed-tools', {
           type: 'array',
@@ -244,6 +249,11 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
           string: true,
           description:
             'A list of extensions to use. If not provided, all extensions are used.',
+          coerce: (extensions: string[]) =>
+            // Handle comma-separated values
+            extensions.flatMap((extension) =>
+              extension.split(',').map((e) => e.trim()),
+            ),
         })
         .option('list-extensions', {
           alias: 'l',


Test patch:
diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts
index 16b70ec9e20..c101da75431 100644
--- a/packages/cli/src/config/config.test.ts
+++ b/packages/cli/src/config/config.test.ts
@@ -307,6 +307,23 @@ describe('parseArguments', () => {
     const argv = await parseArguments({} as Settings);
     expect(argv.allowedTools).toEqual(['read_file', 'ShellTool(git status)']);
   });
+
+  it('should support comma-separated values for --allowed-mcp-server-names', async () => {
+    process.argv = [
+      'node',
+      'script.js',
+      '--allowed-mcp-server-names',
+      'server1,server2',
+    ];
+    const argv = await parseArguments({} as Settings);
+    expect(argv.allowedMcpServerNames).toEqual(['server1', 'server2']);
+  });
+
+  it('should support comma-separated values for --extensions', async () => {
+    process.argv = ['node', 'script.js', '--extensions', 'ext1,ext2'];
+    const argv = await parseArguments({} as Settings);
+    expect(argv.extensions).toEqual(['ext1', 'ext2']);
+  });
 });
 
 describe('loadCliConfig', () => {