mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-13 12:57:12 -07:00
fix(core): implement atomic update in MCP tool discovery (#27619)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
This commit is contained in:
@@ -1244,9 +1244,15 @@ describe('mcp-client', () => {
|
||||
await client.disconnect();
|
||||
|
||||
expect(mockedClient.close).toHaveBeenCalledOnce();
|
||||
expect(mockedToolRegistry.removeMcpToolsByServer).toHaveBeenCalledOnce();
|
||||
expect(mockedPromptRegistry.removePromptsByServer).toHaveBeenCalledOnce();
|
||||
expect(resourceRegistry.removeResourcesByServer).toHaveBeenCalledOnce();
|
||||
expect(mockedToolRegistry.removeMcpToolsByServer).toHaveBeenCalledWith(
|
||||
'test-server',
|
||||
);
|
||||
expect(mockedPromptRegistry.removePromptsByServer).toHaveBeenCalledWith(
|
||||
'test-server',
|
||||
);
|
||||
expect(resourceRegistry.removeResourcesByServer).toHaveBeenCalledWith(
|
||||
'test-server',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1570,8 +1576,8 @@ describe('mcp-client', () => {
|
||||
// Trigger notification - should fail internally but catch the error
|
||||
await notificationCallback();
|
||||
|
||||
// Should try to remove tools
|
||||
expect(mockedToolRegistry.removeMcpToolsByServer).toHaveBeenCalled();
|
||||
// Should NOT try to remove tools because discovery failed (atomic refresh)
|
||||
expect(mockedToolRegistry.removeMcpToolsByServer).not.toHaveBeenCalled();
|
||||
|
||||
// Should NOT emit success feedback
|
||||
expect(coreEvents.emitFeedback).not.toHaveBeenCalledWith(
|
||||
|
||||
@@ -1404,6 +1404,7 @@ export async function discoverTools(
|
||||
error,
|
||||
mcpServerName,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user