fix(cli): accept uppercase URL schemes in mcp add transport detection (#5426)
Some checks are pending
Qwen Code CI / Classify PR (push) Waiting to run
Qwen Code CI / Lint (push) Blocked by required conditions
Qwen Code CI / Test (macos-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Test (ubuntu-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Test (windows-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Blocked by required conditions
Qwen Code CI / Integration Tests (CLI, No Sandbox) (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run

This commit is contained in:
Yufeng He 2026-06-20 09:36:44 +08:00 committed by GitHub
parent 18cc73ce05
commit 196670a356
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -115,6 +115,16 @@ describe('mcp add command', () => {
});
});
it('should auto-detect http transport when commandOrUrl uses an uppercase URL scheme', async () => {
await parser.parseAsync('add http-server HTTPS://example.com/mcp');
expect(mockSetValue).toHaveBeenCalledWith(SettingScope.User, 'mcpServers', {
'http-server': {
httpUrl: 'HTTPS://example.com/mcp',
},
});
});
it('should respect explicit transport even when commandOrUrl is a URL', async () => {
await parser.parseAsync(
'add --transport sse sse-server https://example.com/sse-endpoint',

View file

@ -302,11 +302,7 @@ export const addCommand: CommandModule = {
// Auto-detect transport from URL if not explicitly specified
if (!argv['transport']) {
const commandOrUrl = argv['commandOrUrl'] as string;
if (
commandOrUrl &&
(commandOrUrl.startsWith('http://') ||
commandOrUrl.startsWith('https://'))
) {
if (commandOrUrl && /^https?:\/\//i.test(commandOrUrl)) {
argv['transport'] = 'http';
} else {
argv['transport'] = 'stdio';