feat: Add support for MCP Resources (#13178)

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
Alex Gavrilescu
2025-12-09 03:43:12 +01:00
committed by GitHub
parent 720b31cb8b
commit 560550f5df
20 changed files with 1146 additions and 80 deletions
@@ -49,6 +49,9 @@ describe('useAtCompletion', () => {
})),
getEnableRecursiveFileSearch: () => true,
getFileFilteringDisableFuzzySearch: () => false,
getResourceRegistry: vi.fn().mockReturnValue({
getAllResources: () => [],
}),
} as unknown as Config;
vi.clearAllMocks();
});
@@ -174,6 +177,34 @@ describe('useAtCompletion', () => {
});
});
describe('MCP resource suggestions', () => {
it('should include MCP resources in the suggestion list using fuzzy matching', async () => {
mockConfig.getResourceRegistry = vi.fn().mockReturnValue({
getAllResources: () => [
{
serverName: 'server-1',
uri: 'file:///tmp/server-1/logs.txt',
name: 'logs',
discoveredAt: Date.now(),
},
],
});
const { result } = renderHook(() =>
useTestHarnessForAtCompletion(true, 'logs', mockConfig, '/tmp'),
);
await waitFor(() => {
expect(
result.current.suggestions.some(
(suggestion) =>
suggestion.value === 'server-1:file:///tmp/server-1/logs.txt',
),
).toBe(true);
});
});
});
describe('UI State and Loading Behavior', () => {
it('should be in a loading state during initial file system crawl', async () => {
testRootDir = await createTmpDir({});