Add support for MCP server instructions behind config option (#13432)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
christine betts
2025-11-26 13:08:47 -05:00
committed by GitHub
parent 558c8ece2c
commit bc365f1eaa
9 changed files with 129 additions and 1 deletions
@@ -193,4 +193,55 @@ describe('McpClientManager', () => {
);
});
});
describe('getMcpInstructions', () => {
it('should only return instructions from servers with useInstructions: true', async () => {
// Override McpClient mock for this test to return distinct objects based on config
vi.mocked(McpClient).mockImplementation(
(name, config) =>
({
connect: vi.fn(),
discover: vi.fn(),
disconnect: vi.fn(),
getServerConfig: vi.fn().mockReturnValue(config),
getInstructions: vi
.fn()
.mockReturnValue(`Instructions for ${name}`),
}) as unknown as McpClient,
);
const manager = new McpClientManager({} as ToolRegistry, mockConfig);
// 1. Configured server with useInstructions: true
mockConfig.getMcpServers.mockReturnValue({
'enabled-server': {
useInstructions: true,
},
'disabled-server': {
useInstructions: false,
},
'default-server': {
// undefined should be treated as false
},
});
await manager.startConfiguredMcpServers();
const instructions = manager.getMcpInstructions();
expect(instructions).toContain(
"# Instructions for MCP Server 'enabled-server'",
);
expect(instructions).toContain('Instructions for enabled-server');
expect(instructions).not.toContain(
"# Instructions for MCP Server 'disabled-server'",
);
expect(instructions).not.toContain('Instructions for disabled-server');
expect(instructions).not.toContain(
"# Instructions for MCP Server 'default-server'",
);
expect(instructions).not.toContain('Instructions for default-server');
});
});
});