elastic / elastic/semantic-code-search-mcp-server
Bug: multi-index search drops index provenance (hits become indistinguishable / id collisions)
- Dominant language
- TypeScript
- Stars
- 12
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
When querying multiple indices in Elasticsearch (e.g. `index: kibana,elasticsearch`), each hit has an `_index` field.
This MCP currently drops that provenance when mapping hits into tool responses (e.g. `semantic_code_search` returns only `{ id, score, type, language, kind, content, locations }`).
That makes multi-index results *indistinguishable* to the caller and also creates a correctness hazard:
- `_id` values are only unique **per index**, not globally. Two different indices can return the same `_id`, but this MCP treats `id` as globally unique.
## Impact
- Users cannot tell which repo/index a hit came from.
- Follow-up operations that rely on a single `id` can be ambiguous or wrong if `_id` collisions occur across indices.
## Code pointers
- `src/mcp_server/tools/semantic_code_search.ts`: `hit._id` is used but `hit._index` is not exposed.
- Other tools also key results purely by `filePath` (which can also collide across repos/indices).
## Expected
- Include index provenance in responses (e.g. `index` or `sourceIndex` per hit), and ensure downstream joins/reads can disambiguate using `(index, id)`.
- If multi-index is not supported, fail fast with a clear error instead of returning blended/untraceable results.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.