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.

fix(mcp): name get_health's unscored-file count unanalysed_file_count, as the HTTP API does (#3038)

Raghav Chamadiya35461ca9a687
diff --git a/docs/reference/MCP_RESPONSE_FIELDS.md b/docs/reference/MCP_RESPONSE_FIELDS.md
index 9cf15ef17..7e67bafff 100644
--- a/docs/reference/MCP_RESPONSE_FIELDS.md
+++ b/docs/reference/MCP_RESPONSE_FIELDS.md
@@ -334,6 +334,7 @@ Items are ordered by value first, then tier. History markers (churn, ownership,
| Field | Meaning |
|-------|---------|
| `kpis` | Hotspot health, `average_health` (NLOC-weighted), `average_health_unweighted`, `average_health_weighting`, pillar averages, `worst_performer_path`, `worst_test_path`, `non_code_files`, `average_health_code_only` |
+| `unanalysed_file_count` | Files in a language health has no dialect for, stored with no score and left out of every figure; absent when there are none |
| `gap_analysis` | Weighted points the average must recover to reach 8.0, files below it, `files_to_reach_target`, `files_for_half_gap`, `weighted_gap_points`, `weighted_gross_gap_points` |
| `worst_files`, `test_worst_files` | Lowest raw scores, production and test |
| `high_leverage_files` | Ranked by `weighted_deficit`, with `share_of_repo_gap_pct` |
diff --git a/packages/server/src/repowise/server/mcp_server/tool_health/dashboard.py b/packages/server/src/repowise/server/mcp_server/tool_health/dashboard.py
index 0cb1064e4..c9856569e 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_health/dashboard.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_health/dashboard.py
@@ -48,7 +48,7 @@ def build_dashboard(
"unscored_files": pop.unscored_files,
# Files in a language health has no dialect for: no score, so in no
# figure here. Only said when there are some.
- **({"unanalysed_files": len(pop.unanalysed_paths)} if pop.unanalysed_paths else {}),
+ **({"unanalysed_file_count": len(pop.unanalysed_paths)} if pop.unanalysed_paths else {}),
"kpis": kpis,
"distribution": health_distribution(all_metrics),
# Where the gap to the target concentrates: a short list of files.
diff --git a/tests/unit/server/mcp/test_health.py b/tests/unit/server/mcp/test_health.py
index 1bef8d380..5a87e420e 100644
--- a/tests/unit/server/mcp/test_health.py
+++ b/tests/unit/server/mcp/test_health.py
@@ -2405,3 +2405,34 @@ async def test_a_targeted_read_returns_its_connection(setup_mcp, health_data, fa
gc.collect()
async with factory() as s:
assert (await s.execute(text("SELECT count(*) FROM repositories"))).scalar() == 1
+
+
+async def test_dashboard_unanalysed_file_count_name(setup_mcp, health_data, session):
+ """The dashboard names the unscored-file count as the HTTP API does."""
+ from sqlalchemy import select
+
+ from repowise.core.persistence.models import HealthFileMetric
+ from repowise.server.mcp_server import get_health
+
+ absent = await get_health()
+ assert "unanalysed_file_count" not in absent
+ assert "unanalysed_files" not in absent
+
+ row = (
+ (
+ await session.execute(
+ select(HealthFileMetric).where(HealthFileMetric.repository_id == health_data)
+ )
+ )
+ .scalars()
+ .first()
+ )
+ row.score = None
+ await session.flush()
+
+ dashboard = await get_health()
+ assert dashboard["unanalysed_file_count"] == 1
+ only = await get_health(only=["unanalysed_file_count"])
+ assert only["unanalysed_file_count"] == 1
+ assert "unknown_only_keys" not in only