-
Notifications
You must be signed in to change notification settings - Fork 554
feat(chat): add compatibility with algolia mcp search tool [DASH-2294] #6904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Haroenv
merged 2 commits into
master
from
feat-support-algolia-mcp-search-tool-dash-2294
Feb 19, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/react-instantsearch/src/widgets/chat/tools/__tests__/SearchIndexTool.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /** | ||
| * @jest-environment @instantsearch/testutils/jest-environment-jsdom.ts | ||
| */ | ||
|
|
||
| import { render, screen } from '@testing-library/react'; | ||
| import React from 'react'; | ||
|
|
||
| import { createCarouselTool } from '../SearchIndexTool'; | ||
|
|
||
| import type { ClientSideToolComponentProps } from 'instantsearch-ui-components'; | ||
|
|
||
| type TestHit = { | ||
| objectID: string; | ||
| name: string; | ||
| __position: number; | ||
| }; | ||
|
|
||
| const mockItemComponent = ({ item }: { item: TestHit }) => ( | ||
| <div data-testid={`item-${item.objectID}`}>{item.name}</div> | ||
| ); | ||
|
|
||
| describe('createCarouselTool', () => { | ||
| describe('SearchLayoutComponent', () => { | ||
| test('renders Agent Studio search tool calls', () => { | ||
| const tool = createCarouselTool<TestHit>(false, mockItemComponent); | ||
| const LayoutComponent = tool.layoutComponent!; | ||
|
|
||
| const message: ClientSideToolComponentProps['message'] = { | ||
| type: 'tool-algolia_search_index', | ||
| state: 'output-available', | ||
| toolCallId: 'test-call-id', | ||
| input: { query: 'test', number_of_results: 3 }, | ||
| output: { | ||
| hits: [ | ||
| { objectID: '1', name: 'Product 1', __position: 1 }, | ||
| { objectID: '2', name: 'Product 2', __position: 2 }, | ||
| ], | ||
| nbHits: 100, | ||
| }, | ||
| }; | ||
|
|
||
| render( | ||
| <LayoutComponent | ||
| message={message} | ||
| applyFilters={jest.fn()} | ||
| onClose={jest.fn()} | ||
| indexUiState={{}} | ||
| addToolResult={jest.fn()} | ||
| setIndexUiState={jest.fn()} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('Product 1')).toBeInTheDocument(); | ||
| expect(screen.getByText('Product 2')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders Algolia MCP Server search tool calls', () => { | ||
| const tool = createCarouselTool<TestHit>(false, mockItemComponent); | ||
| const LayoutComponent = tool.layoutComponent!; | ||
|
|
||
| const message: ClientSideToolComponentProps['message'] = { | ||
| type: 'tool-algolia_search_index_products', | ||
| state: 'output-available', | ||
| toolCallId: 'test-call-id', | ||
| input: { query: 'test' }, | ||
| output: { | ||
| hits: [ | ||
| { objectID: '1', name: 'MCP Product 1', __position: 1 }, | ||
| { objectID: '2', name: 'MCP Product 2', __position: 2 }, | ||
| ], | ||
| nbHits: 50, | ||
| }, | ||
| }; | ||
|
|
||
| render( | ||
| <LayoutComponent | ||
| message={message} | ||
| applyFilters={jest.fn()} | ||
| onClose={jest.fn()} | ||
| indexUiState={{}} | ||
| addToolResult={jest.fn()} | ||
| setIndexUiState={jest.fn()} | ||
| /> | ||
| ); | ||
|
|
||
| expect(screen.getByText('MCP Product 1')).toBeInTheDocument(); | ||
| expect(screen.getByText('MCP Product 2')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we did the shim in the InstantSearch.js widget, but not the React InstantSearch widget, is that on purpose?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be handled for the react flavour too.
The
toolsconfig is passed down through a few layers of component and is finally handled inpackages/instantsearch-ui-components/src/components/chat/ChatMessage.tsxwhich I updated 👍Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense! This probably changes with #6874 that's just for @shaejaz to take in account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would remain the same since you still need to map a tool into one with a
layoutComponentin the js chat widget (and not in react) for it to be consumable in ui-components.I'll try to see if this can be avoided in my PR tho.