Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(mcp): say why each next_actions input is unavailable in get_overview (#4649)

Raghav Chamadiyae3aa023b8399
diff --git a/docs/reference/MCP_RESPONSE_FIELDS.md b/docs/reference/MCP_RESPONSE_FIELDS.md
index cb4e19cdb..2aa96f5fd 100644
--- a/docs/reference/MCP_RESPONSE_FIELDS.md
+++ b/docs/reference/MCP_RESPONSE_FIELDS.md
@@ -554,7 +554,7 @@ Groups changed files over index edges, co-change pairs and (for a range) shared
- **`dependencies`:** the ten heaviest package edges (`from`, `to`, `verb`, `weight`), `edges_total` when more; absent in a single-package repo.
- **`code_health`:** `production_average` when tests are in the reading; `files_scored` when some files have no score.
-- **`next_actions`:** `include=["actions"]` serves both horizons with `done_when` and `by_tier`; `get_health(fix_id="act_...")` opens one.
+- **`next_actions`:** `include=["actions"]` serves both horizons with `done_when` and `by_tier`; `get_health(fix_id="act_...")` opens one. `unavailable` names inputs the list was built without and `unavailable_reasons` gives each one's reason; both are absent when every input was read.
- **`repo="all"`:** each repo has `summary` (essay's first sentence), `code_files` (its `code_health.code_files`, or graph code files before health runs) and `symbol_count`; `total_code_files` sums them.
Opt-in blocks, computed only when named: `outline` (page tree, two levels), `tour` (`guided_tour`, `reading_order`), `decisions` (`key_decisions`), `graph` (`community_summary`), `ownership` (`knowledge_map`), `components`, `changes`, `actions`, `tools` (`tool_surface`), `scope` (whole `_meta.index_scope`).
diff --git a/packages/server/src/repowise/server/mcp_server/tool_overview/actions.py b/packages/server/src/repowise/server/mcp_server/tool_overview/actions.py
index b1857995d..149245de6 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_overview/actions.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_overview/actions.py
@@ -62,9 +62,12 @@ def compact_actions_view(view: dict[str, Any], *, full: bool = True) -> dict[str
_compact(a, full=full) for a in horizon.get("actions", [])[:_PER_HORIZON]
]
block[name] = row
- unavailable = sorted(view.get("unavailable") or {})
- if unavailable:
- block["unavailable"] = unavailable
+ # ``unavailable`` stays the sorted name list older readers expect;
+ # ``unavailable_reasons`` says why each one is missing.
+ reasons = view.get("unavailable") or {}
+ if reasons:
+ block["unavailable"] = sorted(reasons)
+ block["unavailable_reasons"] = dict(sorted(reasons.items()))
return block
diff --git a/tests/unit/server/mcp/test_overview_next_actions.py b/tests/unit/server/mcp/test_overview_next_actions.py
index b339c6e68..ef8c8df9d 100644
--- a/tests/unit/server/mcp/test_overview_next_actions.py
+++ b/tests/unit/server/mcp/test_overview_next_actions.py
@@ -114,7 +114,7 @@ def test_compact_view_keeps_three_rows_and_names_unavailable_stores():
"quarter": {"actions": [], "total": 0, "hidden": 0, "by_tier": {}},
},
"summary": {"week": "9 things worth doing this week.", "quarter": "Nothing."},
- "unavailable": {"security": "why", "performance": "why"},
+ "unavailable": {"security": "not computed", "performance": "read failed"},
}
block = compact_actions_view(view)
@@ -127,6 +127,10 @@ def test_compact_view_keeps_three_rows_and_names_unavailable_stores():
assert block["week"]["actions"][0]["target"] == {"kind": "file", "path": "a0.py"}
assert block["quarter"] == {"total": 0, "by_tier": {}, "actions": []}
assert block["unavailable"] == ["performance", "security"]
+ assert block["unavailable_reasons"] == {
+ "performance": "read failed",
+ "security": "not computed",
+ }
def test_the_default_cut_is_one_horizon_with_one_line_impacts():