Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(mcp): resolve health repository from scoped session (#865)
SK4e0b81618681
diff --git a/packages/server/src/repowise/server/mcp_server/tool_health.py b/packages/server/src/repowise/server/mcp_server/tool_health.pyindex efc326f49..68f69c5e5 100644--- a/packages/server/src/repowise/server/mcp_server/tool_health.py+++ b/packages/server/src/repowise/server/mcp_server/tool_health.py@@ -380,7 +380,7 @@ async def get_health(perf_coverage: PerfCoverage | None = Noneperf_findings_count = 0async with get_session(ctx.session_factory) as session:- repository = await _get_repo(session, repo)+ repository = await _get_repo(session)all_metrics_q = select(HealthFileMetric).where(HealthFileMetric.repository_id == repository.iddiff --git a/tests/unit/server/test_mcp_workspace.py b/tests/unit/server/test_mcp_workspace.pyindex 55ef568be..a084c3f68 100644--- a/tests/unit/server/test_mcp_workspace.py+++ b/tests/unit/server/test_mcp_workspace.py@@ -34,7 +34,14 @@ from repowise.core.workspace.registry import RepoContext_NOW = datetime(2026, 4, 12, 10, 0, 0, tzinfo=UTC)-async def _make_repo_context(alias: str, repo_path: str, pages: list, extra_models: list | None = None) -> RepoContext:+async def _make_repo_context(+ alias: str,+ repo_path: str,+ pages: list,+ extra_models: list | None = None,+ *,+ repo_name: str | None = None,+) -> RepoContext:"""Create an in-memory RepoContext with test data."""engine = create_async_engine("sqlite+aiosqlite:///:memory:",@@ -47,7 +54,7 @@ async def _make_repo_context(alias: str, repo_path: str, pages: list, extra_modeasync with factory() as session:repo = Repository(id=f"repo-{alias}",- name=alias,+ name=repo_name or alias,url=f"https://example.com/{alias}",local_path=repo_path,default_branch="main",@@ -58,7 +65,7 @@ async def _make_repo_context(alias: str, repo_path: str, pages: list, extra_modesession.add(repo)for p in pages:session.add(p)- for m in (extra_models or []):+ for m in extra_models or []:session.add(m)await session.commit()@@ -188,7 +195,7 @@ async def workspace_mcp():frontend_ctx = await _make_repo_context("frontend",- "/tmp/workspace/frontend",+ "/tmp/workspace/web-client",pages=[Page(id="repo_overview:frontend",@@ -246,6 +253,7 @@ async def workspace_mcp():affected_modules_json='["src"]',),],+ repo_name="web-client",)registry = _MockRegistry(@@ -278,6 +286,21 @@ async def workspace_mcp():mcp_mod._cross_repo_enricher = None+# ---------------------------------------------------------------------------+# get_health — workspace alias routing+# ---------------------------------------------------------------------------+++async def test_get_health_resolves_alias_different_from_repo_name(workspace_mcp):+ from repowise.server.mcp_server import get_health++ result = await get_health(repo="frontend")++ assert result["mode"] == "dashboard"+ assert result["kpis"]["file_count"] == 0++# ---------------------------------------------------------------------------# get_overview — workspace footer# ---------------------------------------------------------------------------