Skip to content

feat: add zen_review and zen_review_resume MCP tools#8

Merged
mgreau merged 1 commit intomainfrom
mcp-review-tools
Apr 16, 2026
Merged

feat: add zen_review and zen_review_resume MCP tools#8
mgreau merged 1 commit intomainfrom
mcp-review-tools

Conversation

@mgreau
Copy link
Copy Markdown
Owner

@mgreau mgreau commented Apr 16, 2026

What

Add two new MCP tools (zen_review, zen_review_resume) and extract PR review worktree creation into a shared internal/review package.

Why

The worktree creation logic was duplicated between the CLI (cmd/review.go) and the MCP server would need its own copy. Extracting it into a shared package lets both callers reuse the same code while keeping MCP-safe (no stdout writes).

Supersedes #5 with fixes for:

  • stdout pollution: review.CreateWorktree accepts a Logger parameter — CLI passes ui.LogInfo, MCP passes nil to avoid corrupting the stdio-based MCP protocol
  • missing timeouts: git subprocesses (fetch, worktree add) now use exec.CommandContext with a 2-minute timeout, consistent with the codebase pattern established in github: add 30s timeout to all API calls #4
  • unsafe lock removal: os.Remove(lockFile) replaced with RemoveStaleLock (only removes if the holding process is dead)

Notes

  • ensureClaudeCommand("review-pr") auto-installs the /review-pr Claude command from the embedded FS before launching review sessions (both zen review and zen review resume)
  • DetectRepo is the non-interactive equivalent of detectRepoForPR — returns an error on ambiguity instead of prompting
  • The ReviewResult struct moved from cmd/review.go to internal/review as review.Result

Extract worktree creation logic into shared internal/review package
used by both CLI and MCP server. The review package accepts a Logger
parameter so MCP callers pass nil to avoid stdout pollution over stdio.

Also:
- Add ensureClaudeCommand to auto-install /review-pr before sessions
- Use exec.CommandContext with 2m timeout on git subprocesses
- Export RemoveStaleLock and use it instead of unconditional os.Remove
@mgreau mgreau merged commit d3debea into main Apr 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant