Skip to content

bug(cli/mcp): path → repo_path aliasing breaks calculate_cyclomatic_complexity — passing the documented disambiguation arg makes it return null #1532

Closed

Description

@Shashankss1205

server.py:695-699

The MCP dispatcher aliases path and repo_path in both directions. The path_means_file guard covers only the repo_path → path direction; the path → repo_path branch still fires for tools where path means a file.

calculate_cyclomatic_complexity documents path as "Optional file path to disambiguate the function", but the alias copies it into repo_path, which the handler uses as a repository prefix filter:

WHERE (f.path ENDS WITH $path OR f.path = $path)
  AND f.path STARTS WITH $repo_path

Reproduction

Captured params for calculate_cyclomatic_complexity(function_name="parse", path="src/foo.py"):

{'function_name': 'parse', 'path': 'src/foo.py', 'repo_path': 'src/foo.py'}

Stored f.path is absolute (per schema_contract.FILE_MERGE_KEYS), so STARTS WITH 'src/foo.py' is never true.

Impact

Passing path to disambiguate — exactly what the schema tells the agent to do — makes the tool return results: null for a function that exists. Omitting path works. So the documented disambiguation parameter is the thing that breaks it, which is a confusing failure for an agent to recover from.

Suggested fix

Add calculate_cyclomatic_complexity to the path_means_file set so the path → repo_path aliasing is skipped for it, as is already done for the reverse direction.


Environment
Commit c0e0bed (main)
Python 3.12.3, Linux

Reproduced by capturing the dispatcher's outgoing params and running the resulting query shape.

Activity

  1. added
    bugSomething isn't working
    severity: mediumIncorrect results, misleading output, or a broken contract
    area: cli/mcpCLI commands, MCP tool contracts, docs
    on Aug 1, 2026
  2. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  3. ASHMEET555 commented on Aug 6, 2026

    @ASHMEET555
    Contributor

    Hi @Shashankss1205 👋

    I'd like to work on this issue under GSSoC'26. Please assign it to me.

    Understanding
    In server.py, path_means_file already protects the repo_path → path alias for calculate_cyclomatic_complexity, but the reverse path → repo_path branch still runs. So when an agent passes path="src/foo.py" for disambiguation, it also becomes repo_path, and the Cypher STARTS WITH $repo_path filter never matches absolute file paths — the tool returns null.

    Approach

    1. Reproduce with calculate_cyclomatic_complexity(function_name=..., path=...) and confirm outgoing args get repo_path copied from path.
    2. Extend the path_means_file guard so the path → repo_path alias is also skipped for this tool (and audit if any other tools treat path as a file, not a repo).
    3. Add a unit/regression test that passes path as a file disambiguator and asserts repo_path is not set / complexity results are returned.
    4. Open a PR with a clear reproduction → fix → test.

    Thanks!

  4. moved this from Backlog tasks to In progress in CGC Progress Boardon Aug 15, 2026
  5. ASHMEET555 commented on Aug 15, 2026

    @ASHMEET555
    Contributor

    HI @Shashankss1205 i have fixed this issue in the PR #1638 , review and merge it.
    Thanks

  6. moved this from In progress to Done in CGC Progress Boardon Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cli/mcpCLI commands, MCP tool contracts, docsbugSomething isn't workingseverity: mediumIncorrect results, misleading output, or a broken contract

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions