Skip to content

Bug: analysis_tools.py and graph.py — 7 MCP tools crash on valid input (v2.3.2) #289

@ice5631024721

Description

@ice5631024721

Issue Labels

bug

Issue Body

## Environment

- **code-review-graph version:** 2.3.2
- **Python:** 3.12
- **Platform:** macOS (Darwin)

---

## Bug 1: `analysis_tools.py``repo_root` type mismatch

### Problem

All 5 functions in `tools/analysis_tools.py` call `_validate_repo_root(repo_root)` directly, passing a bare `str`. But `_validate_repo_root` in `tools/_common.py:61` expects a `Path` object:

```python
# _common.py:68
def _validate_repo_root(path: Path) -> Path:
    resolved = path.resolve()   # ← AttributeError on str

Error: AttributeError: 'str' object has no attribute 'resolve'

Affected MCP tools: get_hub_nodes_tool, get_bridge_nodes_tool, get_knowledge_gaps_tool, get_surprising_connections_tool, get_suggested_questions_tool

Why other tools work

All other modules call _get_store(repo_root) which internally wraps with Path(). Only analysis_tools.py bypasses this.

Fix (5 lines)

In tools/analysis_tools.py, replace all instances of:

root = _validate_repo_root(repo_root)
store = _get_store(str(root))

with:

store, root = _get_store(repo_root)

Bug 2: graph.pyget_communities_list returns incomplete sqlite3.Row

Problem

# graph.py:1091
"SELECT id, name FROM communities"

But analysis.py:148 does c.get("size", 0) — two problems:

  1. Missing size column in the SELECT
  2. sqlite3.Row has no .get() method (crashes with AttributeError: 'sqlite3.Row' object has no attribute 'get')

Affected: get_knowledge_gaps_tool, get_suggested_questions_tool

Fix

def get_communities_list(self) -> list[dict]:
    try:
        return [
            dict(r)
            for r in self._conn.execute(
                "SELECT id, name, size, level, cohesion, dominant_language "
                "FROM communities"
            ).fetchall()
        ]
    except sqlite3.OperationalError as exc:
        logger.debug("Communities list unavailable: %s", exc)
        return []

Combined Impact

7 out of ~20 MCP tools are completely non-functional in v2.3.2.

Both fixes are minimal, non-breaking, and follow the existing code patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions