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): remove dead context_hint and clean up get_context (#2369)

Rishabh Mishraf298a942cd24
diff --git a/packages/server/src/repowise/server/mcp_server/_meta.py b/packages/server/src/repowise/server/mcp_server/_meta.py
index 71e75fa5f..8621cf027 100644
--- a/packages/server/src/repowise/server/mcp_server/_meta.py
+++ b/packages/server/src/repowise/server/mcp_server/_meta.py
@@ -599,20 +599,6 @@ def _release_meta() -> dict[str, Any]:
}
-def context_hint(targets: list[str], compact: bool, include: set[str] | None = None) -> str | None:
- """Hint for `get_context` callers.
-
- Conservative: only fires when the call shape suggests the agent could
- have used a cheaper tool, AND the suggestion is unambiguously safe.
- """
- if not targets:
- return None
- # If caller requested source and got a large symbol, nudge toward Read with offset
- if include and "source" in include and len(targets) == 1:
- return None # source mode provides its own truncation info
- return None
-
-
def symbol_hint(symbol_id: str, end_line: int, start_line: int) -> str | None:
"""Hint for source retrieval (kept for backward compat with tool_symbol.py)."""
return None
diff --git a/packages/server/src/repowise/server/mcp_server/tool_context/context.py b/packages/server/src/repowise/server/mcp_server/tool_context/context.py
index b6b985e2e..90897b755 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_context/context.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_context/context.py
@@ -58,7 +58,6 @@ from repowise.server.mcp_server._helpers import (
)
from repowise.server.mcp_server._meta import build_meta as _build_meta
from repowise.server.mcp_server._meta import completeness_line as _completeness_line
-from repowise.server.mcp_server._meta import context_hint as _context_hint
from repowise.server.mcp_server.tool_context.enrichment import attach_doc_references
from repowise.server.mcp_server.tool_context.targets import _resolve_one_target
@@ -66,9 +65,8 @@ _log = logging.getLogger("repowise.mcp.context")
# Every value ``include_set`` is tested against downstream, in ``targets.py``.
# ``docs`` and ``freshness`` are always on but remain legal to pass explicitly.
-# ``source`` is tested in ``_meta.context_hint`` and left out deliberately: both
-# branches there return None, so accepting it would promise a block that does
-# nothing.
+# ``source`` is omitted: get_context serves triage cards and structural metadata,
+# not raw source bodies (which are served via include=["skeleton"] or the Read tool).
_INCLUDE_BLOCKS = frozenset(
{
"docs",
@@ -252,7 +250,6 @@ async def get_context(
"targets": {r["target"]: r for r in results},
"_meta": _build_meta(
timing_ms=(_time.perf_counter() - _t0) * 1000,
- hint=_context_hint(targets, compact, include_set),
repository=repository,
targets=targets,
),
diff --git a/tests/unit/server/mcp/test_context.py b/tests/unit/server/mcp/test_context.py
index d16c678ab..083a1e3ab 100644
--- a/tests/unit/server/mcp/test_context.py
+++ b/tests/unit/server/mcp/test_context.py
@@ -851,3 +851,18 @@ async def test_concept_target_returns_section_and_children(setup_mcp, session):
)
assert all(c["page_type"] != "file_page" for c in children)
assert any(f["path"] == "src/payments/charge.py" for f in t["docs"]["files"])
+
+
+async def test_get_context_meta_envelope(setup_mcp):
+ """get_context returns a well-formed _meta envelope without dead hint fields."""
+ from repowise.server.mcp_server import get_context
+
+ result = await get_context(["src/payments/charge.py"])
+ assert "_meta" in result
+ meta = result["_meta"]
+ assert "contract_version" in meta
+ assert "timing_ms" in meta
+ # hint was dead/always None and has been removed; no empty or spurious hint field
+ assert "hint" not in meta
+