Fix: Environment Variable Propagation for Algolia Search Client #37
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.
Fix: Environment Variable Propagation for Algolia Search Client
Problem Description
The current implementation fails to properly instantiate the Algolia search client with environment variables when the "search" MCP tool is included in
MCP_ENABLED_TOOLS
. This results in connection failures when attempting to search for indices and documents, as the search client cannot reach the Algolia instance due to missing authentication credentials and configuration.Error Symptoms:
Solution
Created a unified function for instantiating the Algolia search client that properly propagates environment variables across all search operations. This ensures consistent client configuration regardless of which MCP tools are enabled.
Key Changes:
Testing
MCP_ENABLED_TOOLS=""
(empty/all tools enabled)Changes Made
Files Modified:
cmd/mcp/main.go
pkg/mcputil/client.go
pkg/search/search.go
Functionality:
🚀 Impact
Before: Search operations would fail when MCP tools were enabled due to missing environment variable propagation.
After: All search operations work consistently regardless of MCP tool configuration, with proper authentication and connection to Algolia servers.