Context
PullRequestService.mjs has two execAsync calls (lines 44, 89) that invoke gh pr checkout and gh pr diff without passing {cwd: aiConfig.projectRoot}. When the MCP server process is spawned from a directory outside the git repo (e.g., CWD = / via stdio transport), both commands fail with exit code 1 because gh cannot resolve the repository context.
Root Cause
SyncService.mjs correctly passes {cwd} to all 5 of its execAsync calls (lines 134-148). PullRequestService.mjs does not — likely an oversight from when the service was first written.
Fix
Add {cwd: aiConfig.projectRoot} to both execAsync calls in PullRequestService.mjs:
- Line 44:
execAsync(\gh pr checkout ${prNumber}`, {cwd: aiConfig.projectRoot})`
- Line 89:
execAsync(\gh pr diff ${prNumber}`, {cwd: aiConfig.projectRoot})`
A2A Context (Fat Ticket)
Discovery Path
Found during PR review of #9894 — the get_pull_request_diff MCP tool returned GH_CLI_ERROR with exit code 1. The same gh pr diff 9894 command succeeded when run from the repo root via shell, confirming CWD as the differentiator.
Scope Boundary
Two-line fix. No architectural changes. No new dependencies.
Verification
After applying the fix, restart the MCP server and call get_pull_request_diff on any merged PR to confirm it returns diff output instead of an error.
Context
PullRequestService.mjshas twoexecAsynccalls (lines 44, 89) that invokegh pr checkoutandgh pr diffwithout passing{cwd: aiConfig.projectRoot}. When the MCP server process is spawned from a directory outside the git repo (e.g., CWD =/via stdio transport), both commands fail with exit code 1 becauseghcannot resolve the repository context.Root Cause
SyncService.mjscorrectly passes{cwd}to all 5 of itsexecAsynccalls (lines 134-148).PullRequestService.mjsdoes not — likely an oversight from when the service was first written.Fix
Add
{cwd: aiConfig.projectRoot}to bothexecAsynccalls inPullRequestService.mjs:execAsync(\gh pr checkout ${prNumber}`, {cwd: aiConfig.projectRoot})`execAsync(\gh pr diff ${prNumber}`, {cwd: aiConfig.projectRoot})`A2A Context (Fat Ticket)
Discovery Path
Found during PR review of #9894 — the
get_pull_request_diffMCP tool returnedGH_CLI_ERRORwith exit code 1. The samegh pr diff 9894command succeeded when run from the repo root via shell, confirming CWD as the differentiator.Scope Boundary
Two-line fix. No architectural changes. No new dependencies.
Verification
After applying the fix, restart the MCP server and call
get_pull_request_diffon any merged PR to confirm it returns diff output instead of an error.