Skip to content

Commit 7289421

Browse files
authored
Merge pull request #3 from lossyrob/feature/reply-to-review-comments_phase2
[Reply To Review Comments] Phase 2: Toolset Integration
2 parents 50910fa + 087774e commit 7289421

File tree

3 files changed

+64
-22
lines changed

3 files changed

+64
-22
lines changed

.paw/work/reply-to-review-comments/ImplementationPlan.md

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,43 @@ Create the `ReplyToReviewComment` function in `pkg/github/pullrequests.go` follo
101101
### Success Criteria:
102102

103103
#### Automated Verification:
104-
- [ ] Code compiles without errors: `go build ./cmd/github-mcp-server`
105-
- [ ] No linting errors: `script/lint`
106-
- [ ] Function signature matches pattern: returns `(mcp.Tool, server.ToolHandlerFunc)`
107-
- [ ] Tool definition includes all required parameters with correct types
108-
- [ ] Parameter validation uses appropriate helpers (RequiredParam, RequiredInt, RequiredBigInt)
109-
- [ ] Error handling follows ghErrors.NewGitHubAPIErrorResponse pattern
110-
- [ ] Response format uses MinimalResponse with ID and URL fields
104+
- [x] Code compiles without errors: `go build ./cmd/github-mcp-server`
105+
- [x] No linting errors: `script/lint`
106+
- [x] Function signature matches pattern: returns `(mcp.Tool, server.ToolHandlerFunc)`
107+
- [x] Tool definition includes all required parameters with correct types
108+
- [x] Parameter validation uses appropriate helpers (RequiredParam, RequiredInt, RequiredBigInt)
109+
- [x] Error handling follows ghErrors.NewGitHubAPIErrorResponse pattern
110+
- [x] Response format uses MinimalResponse with ID and URL fields
111111

112112
#### Manual Verification:
113-
- [ ] Tool function is properly exported (capitalized function name)
114-
- [ ] Handler function parameter extraction order is logical (owner, repo, pull_number, comment_id, body)
115-
- [ ] HTTP status check uses correct constant (http.StatusCreated for 201)
116-
- [ ] Response body is deferred closed after API call
117-
- [ ] Go-github method signature matches: `CreateCommentInReplyTo(ctx, owner, repo, number, body, commentID)`
113+
- [x] Tool function is properly exported (capitalized function name)
114+
- [x] Handler function parameter extraction order is logical (owner, repo, pull_number, comment_id, body)
115+
- [x] HTTP status check uses correct constant (http.StatusCreated for 201)
116+
- [x] Response body is deferred closed after API call
117+
- [x] Go-github method signature matches: `CreateCommentInReplyTo(ctx, owner, repo, number, body, commentID)`
118+
119+
### Phase 1 Completion Summary
120+
121+
Phase 1 has been successfully completed. The `ReplyToReviewComment` function was implemented in `pkg/github/pullrequests.go` following the established MCP tool pattern.
122+
123+
**Implementation Details:**
124+
- Added `ReplyToReviewComment` function at line 1612 (after `RequestCopilotReview`)
125+
- Tool name: `reply_to_review_comment`
126+
- All required parameters properly defined: owner, repo, pull_number, comment_id, body
127+
- Uses `RequiredBigInt` for comment_id to handle int64 type
128+
- Calls `client.PullRequests.CreateCommentInReplyTo(ctx, owner, repo, pullNumber, body, commentID)`
129+
- Returns `MinimalResponse` with reply ID and URL on success (HTTP 201)
130+
- Proper error handling with `ghErrors.NewGitHubAPIErrorResponse`
131+
- Response body deferred close after API call
132+
133+
**Verification Results:**
134+
- Code compiles successfully
135+
- Linting passes with 0 issues
136+
- All manual verification checks confirmed
137+
138+
**Commit:** f5140d4 - "Add ReplyToReviewComment tool for replying to PR review comments"
139+
140+
**Next Phase:** Phase 2 - Toolset Integration (register the tool in the pull_requests toolset)
118141

119142
---
120143

@@ -142,15 +165,34 @@ Register the new `ReplyToReviewComment` tool in the pull_requests toolset within
142165
### Success Criteria:
143166

144167
#### Automated Verification:
145-
- [ ] Code compiles after registration: `go build ./cmd/github-mcp-server`
146-
- [ ] No linting errors: `script/lint`
147-
- [ ] Server starts without errors: `./github-mcp-server stdio` exits cleanly on interrupt
168+
- [x] Code compiles after registration: `go build ./cmd/github-mcp-server`
169+
- [x] No linting errors: `script/lint`
170+
- [x] Server starts without errors: `./github-mcp-server stdio` exits cleanly on interrupt
148171

149172
#### Manual Verification:
150-
- [ ] Tool appears in the MCP tool list when server is queried
151-
- [ ] Tool is categorized as a write tool (not read-only)
152-
- [ ] Tool registration follows the established pattern (uses `toolsets.NewServerTool` wrapper)
153-
- [ ] Tool is positioned logically with other review-related write tools
173+
- [x] Tool appears in the MCP tool list when server is queried
174+
- [x] Tool is categorized as a write tool (not read-only)
175+
- [x] Tool registration follows the established pattern (uses `toolsets.NewServerTool` wrapper)
176+
- [x] Tool is positioned logically with other review-related write tools
177+
178+
### Phase 2 Completion Summary
179+
180+
Phase 2 has been successfully completed. The `ReplyToReviewComment` tool has been registered in the pull_requests toolset.
181+
182+
**Implementation Details:**
183+
- Added `toolsets.NewServerTool(ReplyToReviewComment(getClient, t))` to the `AddWriteTools` section in `pkg/github/tools.go`
184+
- Positioned after `AddCommentToPendingReview` to group review-related write tools together
185+
- Tool is now part of the pull_requests/repository_management toolset
186+
187+
**Verification Results:**
188+
- Build completes successfully with no errors
189+
- Linting passes with 0 issues
190+
- Tool registration follows established pattern (uses REST client via getClient parameter)
191+
- Tool is correctly categorized as a write tool (ReadOnlyHint set to false in Phase 1)
192+
193+
**Commit:** 31c8768 - "Register ReplyToReviewComment tool in pull_requests toolset"
194+
195+
**Next Phase:** Phase 3 - Testing (add unit tests with toolsnap validation and table-driven behavioral tests)
154196

155197
---
156198

pkg/github/pullrequests.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,13 +1680,12 @@ func ReplyToReviewComment(getClient GetClientFn, t translations.TranslationHelpe
16801680
defer func() { _ = resp.Body.Close() }()
16811681

16821682
if resp.StatusCode != http.StatusCreated {
1683-
body, err := io.ReadAll(resp.Body)
1683+
responseBody, err := io.ReadAll(resp.Body)
16841684
if err != nil {
16851685
return nil, fmt.Errorf("failed to read response body: %w", err)
16861686
}
1687-
return mcp.NewToolResultError(fmt.Sprintf("failed to create reply to review comment: %s", string(body))), nil
1687+
return mcp.NewToolResultError(fmt.Sprintf("failed to create reply to review comment: %s", string(responseBody))), nil
16881688
}
1689-
16901689
// Return minimal response with just essential information
16911690
minimalResponse := MinimalResponse{
16921691
ID: fmt.Sprintf("%d", comment.GetID()),

pkg/github/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
238238
// Reviews
239239
toolsets.NewServerTool(PullRequestReviewWrite(getGQLClient, t)),
240240
toolsets.NewServerTool(AddCommentToPendingReview(getGQLClient, t)),
241+
toolsets.NewServerTool(ReplyToReviewComment(getClient, t)),
241242
)
242243
codeSecurity := toolsets.NewToolset(ToolsetMetadataCodeSecurity.ID, ToolsetMetadataCodeSecurity.Description).
243244
AddReadTools(

0 commit comments

Comments
 (0)