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
feat(mcp): add get_why to the lean profile; make get_answer the entry point (#889)
Swati Ahuja843eb5f00809
diff --git a/docs/MCP_TOOLS.md b/docs/MCP_TOOLS.mdindex dd9a6a04b..c0587777a 100644--- a/docs/MCP_TOOLS.md+++ b/docs/MCP_TOOLS.md@@ -73,7 +73,7 @@ repowise mcp --all # every available toolWorkspace-only tools named explicitly in single-repo mode are ignored (they cannot do useful work there). Unknown tool names are ignored with a warning.-**The `lean` profile** is the agent-lean surface: `get_answer`, `get_context`, `get_symbol`, `search_codebase`, and `get_risk`, plus `list_repos` in workspace mode (where repo aliases must be discoverable). It advertises ~1.8k tokens of schema versus ~4.1k for the default surface. That is small enough to keep always loaded, so when a repo has `mcp.tools: lean` configured, `repowise init` skips the tool-search recommendation (the `ENABLE_TOOL_SEARCH` setting that defers MCP schemas behind a lookup round trip) for Claude Code; the five schemas the agent actually reaches for stay in context on every turn. init never turns an existing `ENABLE_TOOL_SEARCH` setting off, since it applies to every MCP server, not just repowise.+**The `lean` profile** is the agent-lean surface: `get_answer`, `get_context`, `get_symbol`, `search_codebase`, `get_risk`, and `get_why`, plus `list_repos` in workspace mode (where repo aliases must be discoverable). `get_why` is part of the lean set because why/history questions are the category no code-search surface can answer from the tree alone; a lean profile without it measurably underperforms on exactly those questions. The profile advertises ~2.1k tokens of schema versus ~4.1k for the default surface. That is small enough to keep always loaded, so when a repo has `mcp.tools: lean` configured, `repowise init` skips the tool-search recommendation (the `ENABLE_TOOL_SEARCH` setting that defers MCP schemas behind a lookup round trip) for Claude Code; the six schemas the agent actually reaches for stay in context on every turn. init never turns an existing `ENABLE_TOOL_SEARCH` setting off, since it applies to every MCP server, not just repowise.**Or from the dashboard:** the Settings page lists every tool with its description and a per-repo toggle, and writes the same `mcp.tools` config for you.diff --git a/packages/server/src/repowise/server/mcp_server/_tool_selection.py b/packages/server/src/repowise/server/mcp_server/_tool_selection.pyindex e5f622463..61a9a2997 100644--- a/packages/server/src/repowise/server/mcp_server/_tool_selection.py+++ b/packages/server/src/repowise/server/mcp_server/_tool_selection.py@@ -35,12 +35,18 @@ _log = logging.getLogger("repowise.mcp")# usable in the current mode, including opt-in and workspace-only tools.ALL = "all"-# A value of "lean" enables the agent-lean profile: the five pre-edit tools a+# A value of "lean" enables the agent-lean profile: the pre-edit tools a# coding agent actually reaches for, small enough that every schema can stay# always-loaded instead of deferred behind a tool-search round trip. list_repos# joins it in workspace mode only, where repo aliases must be discoverable.+# get_why belongs in the lean set: why/history questions are the category no+# graph- or search-shaped tool can answer, and a comparative benchmark run+# with a lean surface that omitted it scored repowise BELOW a bare agent on+# history-why questions — the differentiator was configured out, not absent.LEAN = "lean"-LEAN_TOOLS = frozenset({"get_answer", "get_context", "get_symbol", "search_codebase", "get_risk"})+LEAN_TOOLS = frozenset(+ {"get_answer", "get_context", "get_symbol", "search_codebase", "get_risk", "get_why"}+)_LEAN_WORKSPACE_EXTRAS = frozenset({"list_repos"})# Snapshot of every tool registered on the server, captured once after thediff --git a/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py b/packages/server/src/repowise/server/mcp_server/tool_answer/answer.pyindex e726592b7..34861a7f3 100644--- a/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py+++ b/packages/server/src/repowise/server/mcp_server/tool_answer/answer.py@@ -392,7 +392,9 @@ async def get_answer() -> dict:"""Synthesised answer with citations and a calibrated trust signal.- First call for "how does X work" / "where is Y" / "why is Z" questions.+ The single entry point for questions: "how does X work" / "where is Y" /+ "why is Z". It runs the full hybrid retrieval internally (no prior+ search_codebase call needed) and answers in one round-trip.confidence=high is content-grounded (value + citation-source + framegates): cite it directly, no verification Read needed. A "why" answerwhose named mechanism is absent from the retrieved source is downgradeddiff --git a/packages/server/src/repowise/server/mcp_server/tool_search.py b/packages/server/src/repowise/server/mcp_server/tool_search.pyindex 4833e94e7..a6125aefa 100644--- a/packages/server/src/repowise/server/mcp_server/tool_search.py+++ b/packages/server/src/repowise/server/mcp_server/tool_search.py@@ -717,6 +717,13 @@ async def search_codebase() -> dict:"""Find code by concept, symbol, or path — hybrid codebase search.+ For QUESTIONS ("how does X work", "where is Y handled", "why is Z like+ this"), call get_answer instead: it runs this same hybrid retrieval+ internally and synthesizes a cited answer, so a search_codebase call+ before get_answer is a wasted round-trip. Use this tool directly when you+ want the raw ranked hits themselves — enumerating matches, resolving an+ identifier to a symbol_id, or scoping a later get_context call.+mode="auto" (default) routes the query: identifier-shaped queries searchthe indexed symbols (returns symbol_id/file/line bounds — pipe intoget_symbol), path-shaped queries resolve files (pipe into get_context),