Skip to content

feat(askai): Aggregate MCP search tool calls#2891

Open
8bittitan wants to merge 7 commits into
v5from
feat/aggregate-mcp-search-tool
Open

feat(askai): Aggregate MCP search tool calls#2891
8bittitan wants to merge 7 commits into
v5from
feat/aggregate-mcp-search-tool

Conversation

@8bittitan
Copy link
Copy Markdown
Contributor

@8bittitan 8bittitan commented Jun 1, 2026

Why

When Ask AI runs searches through the Algolia MCP server, each query comes back as a separate algolia_search_index (or algolia_search_index_*) tool call. Previously, only the native searchIndex tool was recognized for aggregation, so MCP-backed searches were rendered as a noisy list of individual tool-call entries instead of being collapsed into a single grouped result. This made multi-query MCP searches harder to scan and inconsistent with how native search is presented.

This change teaches the grouping logic to treat MCP search tools as first-class search results so consecutive searches — native or MCP, or a mix of both — are aggregated into one clean entry.

What this enables

  • Consecutive MCP search calls collapse into a single aggregated result, matching native searchIndex behavior.
  • Mixed native + MCP search sequences group together rather than fragmenting.
  • Query extraction accounts for the difference between the two tool shapes (native exposes the query on its output, MCP on its input), and empty/whitespace queries are skipped.
  • Custom tools that merely share the algolia_search_index prefix (e.g. algolia_search_indexer) are intentionally excluded to avoid false grouping.

Notes

  • Shared type guards (isSearchToolPart, isSearchOutputPart, etc.) were centralized in utils/ai.ts and removed from ToolCall.tsx to keep the search-tool detection logic in one place.
  • New unit tests cover the MCP guard and the grouping behavior, including the prefix edge cases and empty-query handling.
  • AGENTS.md was updated to reflect the current toolchain (Playwright instead of Cypress, --run for tests).

Dependencies

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 1, 2026

Deploy Preview for docsearch-demo ready!

Name Link
🔨 Latest commit 840109f
🔍 Latest deploy log https://app.netlify.com/projects/docsearch-demo/deploys/6a1ef3c823bc7757ca36c3cc
😎 Deploy Preview https://deploy-preview-2891--docsearch-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Jun 1, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 24 complexity · 4 duplication

Metric Results
Complexity 24
Duplication 4

View in Codacy

TIP This summary will be updated as you push new changes.

Base automatically changed from feat/feedback-note-collection to v5 June 2, 2026 12:37
Copy link
Copy Markdown
Collaborator

@LorrisSaintGenez LorrisSaintGenez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comment

Comment thread packages/docsearch-react/src/utils/ai.ts
Comment thread packages/docsearch-react/src/utils/ai.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants