# 🚀 Sync Gemini CLI v0.2.1 - Major Feature Update (#483)

This commit is contained in:
tanzhenxin
2025-09-01 14:48:55 +08:00
committed by GitHub
parent 1610c1586e
commit 2572faf726
292 changed files with 19401 additions and 5941 deletions

View File

@@ -85,4 +85,38 @@ describe('mcp add command', () => {
},
);
});
it('should handle MCP server args with -- separator', async () => {
await parser.parseAsync(
'add my-server npx -- -y http://example.com/some-package',
);
expect(mockSetValue).toHaveBeenCalledWith(
SettingScope.Workspace,
'mcpServers',
{
'my-server': {
command: 'npx',
args: ['-y', 'http://example.com/some-package'],
},
},
);
});
it('should handle unknown options as MCP server args', async () => {
await parser.parseAsync(
'add test-server npx -y http://example.com/some-package',
);
expect(mockSetValue).toHaveBeenCalledWith(
SettingScope.Workspace,
'mcpServers',
{
'test-server': {
command: 'npx',
args: ['-y', 'http://example.com/some-package'],
},
},
);
});
});

View File

@@ -130,6 +130,10 @@ export const addCommand: CommandModule = {
builder: (yargs) =>
yargs
.usage('Usage: gemini mcp add [options] <name> <commandOrUrl> [args...]')
.parserConfiguration({
'unknown-options-as-args': true, // Pass unknown options as server args
'populate--': true, // Populate server args after -- separator
})
.positional('name', {
describe: 'Name of the server',
type: 'string',
@@ -189,22 +193,29 @@ export const addCommand: CommandModule = {
describe: 'A comma-separated list of tools to exclude',
type: 'array',
string: true,
})
.middleware((argv) => {
// Handle -- separator args as server args if present
if (argv['--']) {
const existingArgs = (argv['args'] as Array<string | number>) || [];
argv['args'] = [...existingArgs, ...(argv['--'] as string[])];
}
}),
handler: async (argv) => {
await addMcpServer(
argv.name as string,
argv.commandOrUrl as string,
argv.args as Array<string | number>,
argv['name'] as string,
argv['commandOrUrl'] as string,
argv['args'] as Array<string | number>,
{
scope: argv.scope as string,
transport: argv.transport as string,
env: argv.env as string[],
header: argv.header as string[],
timeout: argv.timeout as number | undefined,
trust: argv.trust as boolean | undefined,
description: argv.description as string | undefined,
includeTools: argv.includeTools as string[] | undefined,
excludeTools: argv.excludeTools as string[] | undefined,
scope: argv['scope'] as string,
transport: argv['transport'] as string,
env: argv['env'] as string[],
header: argv['header'] as string[],
timeout: argv['timeout'] as number | undefined,
trust: argv['trust'] as boolean | undefined,
description: argv['description'] as string | undefined,
includeTools: argv['includeTools'] as string[] | undefined,
excludeTools: argv['excludeTools'] as string[] | undefined,
},
);
},

View File

@@ -53,8 +53,8 @@ export const removeCommand: CommandModule = {
choices: ['user', 'project'],
}),
handler: async (argv) => {
await removeMcpServer(argv.name as string, {
scope: argv.scope as string,
await removeMcpServer(argv['name'] as string, {
scope: argv['scope'] as string,
});
},
};