Skip to content

[Feature] Add ccpr_review MCP tool #58

@hidetzu

Description

@hidetzu

Summary

Expose ccpr review --format json as an MCP tool named ccpr_review, served by the existing ccpr-mcp binary. The tool returns PR metadata, comments, and the
local-Git-generated diff in a single structured response.

Motivation

  • This is the headline use case in CLAUDE.md — "developer runs ccpr review --format json, passes the output to Claude Code, and Claude generates review comments."
    Today this still requires a manual pipe.
  • ccpr_list is already wired up; extending the same internal/app pattern to review is the natural next step and validates that the shared use case approach scales.
  • review --format json is already an object-typed payload ({metadata, comments, diff}), so it maps directly onto an MCP tool output schema without a wrapper.

Proposed Solution

Scope

  • New MCP tool: ccpr_review.
  • Input: PR URL preferred (mirroring CLAUDE.md "The primary input is a CodeCommit PR URL"). Also accept repo + prId + region as secondary, matching the CLI's --repo /
    --pr-id flags.
  • Output: the existing ccpr review --format json schema — top-level object with metadata, comments, diff. No wrapper needed.
  • Reuse the internal use case: extract the CLI's review pipeline into internal/app/review.go so the CLI and MCP paths share validation, AWS resolution, comment fetching,
    and diff generation.
  • cmd/ccpr-mcp/main.go registers ccpr_review alongside ccpr_list.

Out of scope

  • --format patch and --format summary over MCP. MCP consumers want structured data; the CLI keeps these formats for human use.
  • Line-level comment objects beyond what review --format json already returns.
  • Any change to the ccpr CLI behavior or its existing JSON output.

Implementation plan

  1. Update docs first, per the spec-driven rule in CLAUDE.md:
    - docs/use-cases.md: scenario where Claude Code fetches a full PR review payload via MCP.
    - docs/requirements.md: extend FR-18 (or add a sibling) to cover ccpr_review.
    - docs/spec.md: input schema (URL vs. repo/prId/region), output schema (reuse review --format json), error handling.
  2. Extract the review use case into internal/app/review.go and migrate cmd/ccpr/review.go to call it.
  3. Register ccpr_review in cmd/ccpr-mcp/main.go.
  4. Extend the existing newServer() smoke test so a tool-schema regression in ccpr_review is caught at build time, just like ccpr_list.
  5. Update README.md / README.ja.md with the new MCP tool.

Acceptance criteria

  • ccpr_review is callable from an MCP client and returns the same payload as ccpr review --format json.
  • The CLI ccpr review continues to work with no behavioral or output changes (existing golden tests in cmd/ccpr/testdata/ still pass).
  • ccpr_list is unaffected.
  • Docs (use-cases / requirements / spec / json-schema / README) updated.
  • make build / make build-mcp / make test / make vet / make lint all pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions