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(server): check for a repo path before building get_symbol's exclusion spec (#2554)
Raghav Chamadiya8611fa28af65
diff --git a/packages/server/src/repowise/server/mcp_server/tool_symbol.py b/packages/server/src/repowise/server/mcp_server/tool_symbol.pyindex 25fa2ab7b..14a1a846c 100644--- a/packages/server/src/repowise/server/mcp_server/tool_symbol.py+++ b/packages/server/src/repowise/server/mcp_server/tool_symbol.py@@ -551,10 +551,11 @@ async def _resolve_range_read(),}- if is_excluded(path, _get_exclude_spec(ctx.path)):- return _err(f"'{path}' is excluded from indexing.")+ # Before the exclusion spec: it is built from the repo path.if not ctx.path:return _err("MCP server has no repo path configured")+ if is_excluded(path, _get_exclude_spec(ctx.path)):+ return _err(f"'{path}' is excluded from indexing.")text = _read_file_text(Path(str(ctx.path)), path)if text is None:@@ -966,6 +967,17 @@ async def get_symbol(repository = await _get_repo(session)rows = await _resolve_symbol(session, repository.id, symbol_id)+ # Before the exclusion spec: it is built from the repo path.+ if not ctx.path:+ return {+ "symbol_id": symbol_id,+ "error": "MCP server has no repo path configured",+ "_meta": _build_meta(+ timing_ms=(time.perf_counter() - t0) * 1000,+ repository=repository,+ ),+ }+exclude_spec = _get_exclude_spec(ctx.path)rows = [r for r in rows if not is_excluded(r.file_path, exclude_spec)]if not rows:@@ -1024,16 +1036,6 @@ async def get_symbol(),}- if not ctx.path:- return {- "symbol_id": symbol_id,- "error": "MCP server has no repo path configured",- "_meta": _build_meta(- timing_ms=(time.perf_counter() - t0) * 1000,- repository=repository,- ),- }-if len(rows) > 1:return await _render_ambiguous(rows, symbol_id, ctx, repository, t0, context_lines)diff --git a/tests/unit/server/mcp/test_symbol_range_and_recovery.py b/tests/unit/server/mcp/test_symbol_range_and_recovery.pyindex b421eed9d..6ee8c48d8 100644--- a/tests/unit/server/mcp/test_symbol_range_and_recovery.py+++ b/tests/unit/server/mcp/test_symbol_range_and_recovery.py@@ -242,3 +242,19 @@ async def test_generated_schema_advertises_id_alias():)assert accepts_string, f"`id` is not typed as a string: {id_schema}"assert "id" not in tool.inputSchema.get("required", [])++[email protected]("symbol_id", ["pkg/mod.py:1-2", "pkg/mod.py::alpha"])+async def test_no_repo_path_is_a_named_error(setup_mcp, factory, monkeypatch, symbol_id):+ """A pathless context names the problem instead of failing on the exclusion spec."""+ from types import SimpleNamespace++ from repowise.server.mcp_server import tool_symbol++ async def _context(_repo):+ return SimpleNamespace(path=None, session_factory=factory, alias="")++ monkeypatch.setattr(tool_symbol, "_resolve_repo_context", _context)+ result = await tool_symbol.get_symbol(symbol_id)+ assert result["error"] == "MCP server has no repo path configured"