elastic / elastic/semantic-code-search-mcp-server

Bug: ELASTICSEARCH_INDEX with multiple indices breaks <index>_locations resolution

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12
Forks
7
PR merge metrics
No merged PRs in 30d

Description

## Problem
This MCP assumes a split-index model: `` for chunks + `_locations` for file/line metadata.

If `ELASTICSEARCH_INDEX` is set to a comma-separated list (e.g. `kibana,elasticsearch`), we pass that string directly as the Elasticsearch `index` parameter (multi-index search), but we also derive the locations index as `${baseIndex}_locations`.

That produces an invalid locations index name like `kibana,elasticsearch_locations` instead of querying `kibana_locations` and `elasticsearch_locations`.

## Impact
- `semantic_code_search` location join breaks (errors or returns empty `locations`)
- `read_file`, `map_symbols_by_query`, `symbol_analysis` break because they query the derived locations index

## Repro
1. Set `ELASTICSEARCH_INDEX=kibana,elasticsearch`
2. Call any tool that needs locations (e.g. `read_file`, or `semantic_code_search` which returns `locations`)
3. Observe an `index_not_found_exception` for `kibana,elasticsearch_locations` (or missing/empty location data)

## Code pointers
- `src/utils/elasticsearch.ts`: `getLocationsIndexName()`
- Tools that call it: `src/mcp_server/tools/semantic_code_search.ts`, `read_file.ts`, `map_symbols_by_query.ts`, `symbol_analysis.ts`

## Expected
Either:
- Support multi-index properly by resolving locations per-hit-index (requires carrying index provenance through the pipeline), or
- Reject comma-separated `ELASTICSEARCH_INDEX` early with a clear error explaining the split-index model limitation and how to configure indexes.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.