Extensions MCP refactor (#12413)

This commit is contained in:
Jacob MacDonald
2025-11-04 07:51:18 -08:00
committed by GitHub
parent 2b77c1ded4
commit da4fa5ad75
28 changed files with 877 additions and 478 deletions

View File

@@ -1146,9 +1146,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
];
const argv = await parseArguments({} as Settings);
const config = await loadCliConfig(baseSettings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server1: { url: 'http://localhost:8080' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1']);
});
it('should allow multiple specified MCP servers', async () => {
@@ -1162,10 +1160,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
];
const argv = await parseArguments({} as Settings);
const config = await loadCliConfig(baseSettings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server1: { url: 'http://localhost:8080' },
server3: { url: 'http://localhost:8082' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server3']);
});
it('should handle server names that do not exist', async () => {
@@ -1179,16 +1174,14 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
];
const argv = await parseArguments({} as Settings);
const config = await loadCliConfig(baseSettings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server1: { url: 'http://localhost:8080' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server4']);
});
it('should allow no MCP servers if the flag is provided but empty', async () => {
process.argv = ['node', 'script.js', '--allowed-mcp-server-names', ''];
const argv = await parseArguments({} as Settings);
const config = await loadCliConfig(baseSettings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({});
expect(config.getAllowedMcpServers()).toEqual(['']);
});
it('should read allowMCPServers from settings', async () => {
@@ -1199,10 +1192,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
mcp: { allowed: ['server1', 'server2'] },
};
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server1: { url: 'http://localhost:8080' },
server2: { url: 'http://localhost:8081' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server2']);
});
it('should read excludeMCPServers from settings', async () => {
@@ -1213,9 +1203,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
mcp: { excluded: ['server1', 'server2'] },
};
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server3: { url: 'http://localhost:8082' },
});
expect(config.getBlockedMcpServers()).toEqual(['server1', 'server2']);
});
it('should override allowMCPServers with excludeMCPServers if overlapping', async () => {
@@ -1229,9 +1217,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
},
};
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server2: { url: 'http://localhost:8081' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server2']);
expect(config.getBlockedMcpServers()).toEqual(['server1']);
});
it('should prioritize mcp server flag if set', async () => {
@@ -1250,9 +1237,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
},
};
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server1: { url: 'http://localhost:8080' },
});
expect(config.getAllowedMcpServers()).toEqual(['server1']);
});
it('should prioritize CLI flag over both allowed and excluded settings', async () => {
@@ -1273,10 +1258,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
},
};
const config = await loadCliConfig(settings, 'test-session', argv);
expect(config.getMcpServers()).toEqual({
server2: { url: 'http://localhost:8081' },
server3: { url: 'http://localhost:8082' },
});
expect(config.getAllowedMcpServers()).toEqual(['server2', 'server3']);
expect(config.getBlockedMcpServers()).toEqual([]);
});
});