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:
luisfelipe-alt
2026-06-09 18:51:02 +00:00
committed by GitHub
parent 0567b25a26
commit 8e99c26dd8
2 changed files with 12 additions and 5 deletions
+11 -5
View File
@@ -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(
+1
View File
@@ -1404,6 +1404,7 @@ export async function discoverTools(
error,
mcpServerName,
);
throw error;
}
return [];
}