Summary
While running a cross-project tool-usage analysis via the Cortex MCP server, several read paths returned 502 Bad Gateway because kind-routed global indices are missing, and cortex_query mis-derived the repo slug from the caller's cwd. Reproduced against a healthy daemon (api_reachable: true).
Environment
- cortex MCP server
cortex-mcp-server 0.1.0 (pid live), cortex-api 0.1.0 at http://127.0.0.1:17000
- daemon up,
api_reachable: true, 60+ indexed_repos
coverage.overall_severity: "warn" (see secondary findings)
Bugs
1. cortex_tool_calls / cortex_turns indices missing → 502 on events & tool-call search
cortex_tool_calls:
cortex-api .../v1/search/tool-calls returned HTTP 502 Bad Gateway
detail: Index `cortex_tool_calls` not found.
cortex_events_by_kind (kind=tool_call):
.../v1/search/events returned HTTP 502 Bad Gateway
detail: Index `cortex_tool_calls` not found.
cortex_events_by_kind (kind=turn):
.../v1/search/events returned HTTP 502 Bad Gateway
detail: Index `cortex_turns` not found.
A missing Meili index is a recoverable empty state, not a gateway failure — these should return 200 with empty hits (or 404/structured index_unavailable), not 502. Right now any consumer that asks for tool-call or turn telemetry hard-fails. The kind-routed indices (cortex_tool_calls, cortex_turns) appear to never have been created on this daemon despite turns/tool_calls being ingested per-repo (cortex-<repo>-turns style indices exist, e.g. keyword_search against cortex_decisions works).
2. cortex_query derives an un-indexed repo slug from cwd
Calling cortex_query without an explicit scope.repo from cwd E:\HiveLLM\Rulebook auto-resolved:
"scope_resolved": { "repo": "e-hivellm-rulebook" }
"notice": { "code": "repo_not_indexed", "message": "scope.repo `e-hivellm-rulebook` is not present in the cortex-api indexed-repo snapshot" }
…but the repo is indexed — under slug rulebook (present in status.indexed_repos). The cwd→slug derivation lowercases/joins the full path (e-hivellm-rulebook) instead of using the basename / the slug the indexer registered (rulebook). Result: default-scoped queries silently return empty for any project whose path has >1 segment. Passing scope.repo: "rulebook" explicitly works.
Repro
cortex_tool_calls({ limit: 50 }) → 502
cortex_events_by_kind({ kind: "tool_call" }) / { kind: "turn" } → 502
- From a nested project dir,
cortex_query({ intent: "free_search", query: "x" }) with no scope → repo_not_indexed for a repo that is indexed under its basename slug.
Expected
- Missing index → empty result set (200) or structured
index_unavailable, never 502.
- cwd→repo-slug resolution matches the slug under which the indexer registered the repo (basename), or falls back to fuzzy-matching
indexed_repos before declaring repo_not_indexed.
Secondary findings (lower priority)
- Coverage drift (
/v1/health/coverage, severity warn): vectorizer backend present 15 / expected 594 (missing 579, unexpected 12); meili present 170 / expected 594 (missing 424, unexpected 50). Large gap between expected and present documents across both backends.
cortex_keyword_search oversize hits: an empty-query search against cortex_decisions returned a single 91 KB line that exceeded the MCP per-result token cap. Consider a default per-hit field cap or auto-applying attributes_to_retrieve when the caller omits it, so the tool is usable without manual field restriction.
Impact
Tool-call and turn telemetry are unreachable via MCP (502), and default-scoped cortex_query returns empty for normally-indexed projects — both block agent-side usage analytics and pre-change context retrieval.
Filed by an automated analysis session (Claude Code) with the user's authorization.
Summary
While running a cross-project tool-usage analysis via the Cortex MCP server, several read paths returned
502 Bad Gatewaybecause kind-routed global indices are missing, andcortex_querymis-derived the repo slug from the caller's cwd. Reproduced against a healthy daemon (api_reachable: true).Environment
cortex-mcp-server0.1.0 (pid live),cortex-api0.1.0 athttp://127.0.0.1:17000api_reachable: true, 60+indexed_reposcoverage.overall_severity: "warn"(see secondary findings)Bugs
1.
cortex_tool_calls/cortex_turnsindices missing → 502 on events & tool-call searchcortex_tool_calls:cortex_events_by_kind(kind=tool_call):cortex_events_by_kind(kind=turn):A missing Meili index is a recoverable empty state, not a gateway failure — these should return
200with empty hits (or404/structuredindex_unavailable), not502. Right now any consumer that asks for tool-call or turn telemetry hard-fails. The kind-routed indices (cortex_tool_calls,cortex_turns) appear to never have been created on this daemon despite turns/tool_calls being ingested per-repo (cortex-<repo>-turnsstyle indices exist, e.g. keyword_search againstcortex_decisionsworks).2.
cortex_queryderives an un-indexed repo slug from cwdCalling
cortex_querywithout an explicitscope.repofrom cwdE:\HiveLLM\Rulebookauto-resolved:…but the repo is indexed — under slug
rulebook(present instatus.indexed_repos). The cwd→slug derivation lowercases/joins the full path (e-hivellm-rulebook) instead of using the basename / the slug the indexer registered (rulebook). Result: default-scoped queries silently return empty for any project whose path has >1 segment. Passingscope.repo: "rulebook"explicitly works.Repro
cortex_tool_calls({ limit: 50 })→ 502cortex_events_by_kind({ kind: "tool_call" })/{ kind: "turn" }→ 502cortex_query({ intent: "free_search", query: "x" })with noscope→repo_not_indexedfor a repo that is indexed under its basename slug.Expected
index_unavailable, never 502.indexed_reposbefore declaringrepo_not_indexed.Secondary findings (lower priority)
/v1/health/coverage, severity warn): vectorizer backendpresent 15 / expected 594(missing 579, unexpected 12); meilipresent 170 / expected 594(missing 424, unexpected 50). Large gap between expected and present documents across both backends.cortex_keyword_searchoversize hits: an empty-query search againstcortex_decisionsreturned a single 91 KB line that exceeded the MCP per-result token cap. Consider a default per-hit field cap or auto-applyingattributes_to_retrievewhen the caller omits it, so the tool is usable without manual field restriction.Impact
Tool-call and turn telemetry are unreachable via MCP (502), and default-scoped
cortex_queryreturns empty for normally-indexed projects — both block agent-side usage analytics and pre-change context retrieval.Filed by an automated analysis session (Claude Code) with the user's authorization.