diff options
| author | christine betts <[email protected]> | 2025-07-15 20:45:24 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-15 20:45:24 +0000 |
| commit | 58f1aa6ceb53df94cc5bba77dc787950be340cb9 (patch) | |
| tree | 10a5ac6bab999da4cfde7f0c209989ac4529780e /packages/cli/src/config/config.test.ts | |
| parent | 03b3917f62e5db2b00bcb27df9d78ee5289d9a85 (diff) | |
Add support for allowed/excluded MCP server names in settings (#4135)
Co-authored-by: Scott Densmore <[email protected]>
Diffstat (limited to 'packages/cli/src/config/config.test.ts')
| -rw-r--r-- | packages/cli/src/config/config.test.ts | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts index 5043fd59..4042bf93 100644 --- a/packages/cli/src/config/config.test.ts +++ b/packages/cli/src/config/config.test.ts @@ -725,6 +725,66 @@ describe('loadCliConfig with allowed-mcp-server-names', () => { const config = await loadCliConfig(baseSettings, [], 'test-session', argv); expect(config.getMcpServers()).toEqual({}); }); + + it('should read allowMCPServers from settings', async () => { + process.argv = ['node', 'script.js']; + const argv = await parseArguments(); + const settings: Settings = { + ...baseSettings, + allowMCPServers: ['server1', 'server2'], + }; + const config = await loadCliConfig(settings, [], 'test-session', argv); + expect(config.getMcpServers()).toEqual({ + server1: { url: 'http://localhost:8080' }, + server2: { url: 'http://localhost:8081' }, + }); + }); + + it('should read excludeMCPServers from settings', async () => { + process.argv = ['node', 'script.js']; + const argv = await parseArguments(); + const settings: Settings = { + ...baseSettings, + excludeMCPServers: ['server1', 'server2'], + }; + const config = await loadCliConfig(settings, [], 'test-session', argv); + expect(config.getMcpServers()).toEqual({ + server3: { url: 'http://localhost:8082' }, + }); + }); + + it('should override allowMCPServers with excludeMCPServers if overlapping ', async () => { + process.argv = ['node', 'script.js']; + const argv = await parseArguments(); + const settings: Settings = { + ...baseSettings, + excludeMCPServers: ['server1'], + allowMCPServers: ['server1', 'server2'], + }; + const config = await loadCliConfig(settings, [], 'test-session', argv); + expect(config.getMcpServers()).toEqual({ + server2: { url: 'http://localhost:8081' }, + }); + }); + + it('should prioritize mcp server flag if set ', async () => { + process.argv = [ + 'node', + 'script.js', + '--allowed-mcp-server-names', + 'server1', + ]; + const argv = await parseArguments(); + const settings: Settings = { + ...baseSettings, + excludeMCPServers: ['server1'], + allowMCPServers: ['server2'], + }; + const config = await loadCliConfig(settings, [], 'test-session', argv); + expect(config.getMcpServers()).toEqual({ + server1: { url: 'http://localhost:8080' }, + }); + }); }); describe('loadCliConfig extensions', () => { |
