Stop extension MCPs from hopping into settings. (#1026)
This commit is contained in:
parent
bb67d31739
commit
a2fe3d2ad0
|
@ -269,3 +269,32 @@ describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
|
|||
});
|
||||
*/
|
||||
});
|
||||
|
||||
describe('mergeMcpServers', () => {
|
||||
it('should not modify the original settings object', async () => {
|
||||
const settings: Settings = {
|
||||
mcpServers: {
|
||||
'test-server': {
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
},
|
||||
};
|
||||
const extensions: Extension[] = [
|
||||
{
|
||||
config: {
|
||||
name: 'ext1',
|
||||
version: '1.0.0',
|
||||
mcpServers: {
|
||||
'ext1-server': {
|
||||
url: 'http://localhost:8081',
|
||||
},
|
||||
},
|
||||
},
|
||||
contextFiles: [],
|
||||
},
|
||||
];
|
||||
const originalSettings = JSON.parse(JSON.stringify(settings));
|
||||
await loadCliConfig(settings, extensions, [], 'test-session');
|
||||
expect(settings).toEqual(originalSettings);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -205,7 +205,7 @@ export async function loadCliConfig(
|
|||
}
|
||||
|
||||
function mergeMcpServers(settings: Settings, extensions: Extension[]) {
|
||||
const mcpServers = settings.mcpServers || {};
|
||||
const mcpServers = { ...(settings.mcpServers || {}) };
|
||||
for (const extension of extensions) {
|
||||
Object.entries(extension.config.mcpServers || {}).forEach(
|
||||
([key, server]) => {
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('loadExtensions', () => {
|
|||
'ext1',
|
||||
'1.0.0',
|
||||
false,
|
||||
'my-context.md',
|
||||
'my-context-file.md',
|
||||
);
|
||||
|
||||
const extensions = loadExtensions(tempWorkspaceDir);
|
||||
|
@ -80,7 +80,7 @@ describe('loadExtensions', () => {
|
|||
expect(extensions).toHaveLength(1);
|
||||
const ext1 = extensions.find((e) => e.config.name === 'ext1');
|
||||
expect(ext1?.contextFiles).toEqual([
|
||||
path.join(workspaceExtensionsDir, 'ext1', 'my-context.md'),
|
||||
path.join(workspaceExtensionsDir, 'ext1', 'my-context-file.md'),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -107,7 +107,7 @@ function loadExtension(extensionDir: string): Extension | null {
|
|||
|
||||
function getContextFileNames(config: ExtensionConfig): string[] {
|
||||
if (!config.contextFileName) {
|
||||
return ['GEMINI.md', 'gemini.md', 'Gemini.md'];
|
||||
return ['GEMINI.md'];
|
||||
} else if (!Array.isArray(config.contextFileName)) {
|
||||
return [config.contextFileName];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue