Skip to content

[Bug]: list_prs/triage_prs/get_pr_impact report "gh not authenticated" when the MCP server cwd is outside the repo (#3917 item 5 never landed) #5535

Done

Description

@thomaswillner

Pre-flight checks

What happened?

list_prs and triage_prs fail with:

Error: gh CLI not found or not authenticated. Run: gh auth login

whenever the MCP server's working directory is not inside the graph's git repository, even though gh is installed and authenticated. get_pr_impact fails the same way (PR #N not found or gh not authenticated.).

Cause: graphify/prs.py _gh() runs gh pr list ... with no --repo and no cwd, so gh resolves the repository from the server process's working directory. _gh() then returns None on any non-zero exit, and fetch_prs() turns that into the auth message, so the real gh error (not a git repository) never reaches the user.

This hits every client that starts the stdio server outside the repo, for example a global MCP config with --graph /abs/path/to/repo/graphify-out/graph.json, or launchers that cd to a neutral directory. The graph tools work in that setup and only the PR tools break, which makes the auth message especially misleading.

Steps to reproduce

  1. Use any git repo with a GitHub remote, open PRs and a built graphify-out/graph.json. Make sure gh auth status is OK.
  2. Start the server from a directory outside the repo:
    cd "$(mktemp -d)"
    graphify-mcp --graph /abs/path/to/repo/graphify-out/graph.json
    
  3. Call list_prs (or triage_prs) with no arguments.

Result of each variant over the MCP stdio protocol (same graph, same machine, same gh login):

server cwd arguments list_prs / triage_prs
non-git temp dir {} error: gh CLI not found or not authenticated. Run: gh auth login
non-git temp dir {"repo": "owner/name"} OK: Open PRs targeting main: 4
the repo itself {} OK: Open PRs targeting main: 4

Error output or graph output

Error: gh CLI not found or not authenticated. Run: gh auth login

Expected

At least one of:

  1. When repo is omitted, run gh with cwd set to the repository that holds the served graph (the git root of --graph), instead of the process cwd. Same for fetch_worktrees() and _detect_default_branch().
  2. Report the actual failure (as fix(mcp): enforce deterministic get_node resolution & graceful list_p… #3920 proposed), e.g. could not detect repository; pass repo=owner/name, and keep "not authenticated" for real auth failures (gh auth status non-zero).

Graphify version

0.9.121 (prs.py is byte-identical in 0.9.115)

Operating System

macOS 26.6.2 (arm64)

Python Version

3.13.15

Installation Method

uv tool install 'graphifyy[mcp]==0.9.121'

Additional Environment Details

gh 2.104.0, authenticated. MCP Python SDK 2.3.0, stdio transport.

Additional context

Workaround: pass repo="owner/name" explicitly on every PR tool call.

Activity

  1. github-actions commented on Nov 27, 2026

    @github-actions

    Thanks for opening this issue, @thomaswillner. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. thomaswillner commented on Nov 27, 2026

    @thomaswillner
    Author

    Context for maintainers: this was already reported as item 5 of #3917, which was closed as fixed in 0.9.94, but the fix (#3920) was closed without merging and the code on the default branch is unchanged. Details: #3917 (comment)

  3. added a commit that references this issue on Nov 28, 2026
    e453e0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions