Content-Length: 460625 | pFad | http://github.com/github/github-mcp-server/pull/816

24 Add a new tool to find closing PRs for issues by lumaxis · Pull Request #816 · github/github-mcp-server · GitHub
Skip to content

Add a new tool to find closing PRs for issues #816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

lumaxis
Copy link

@lumaxis lumaxis commented Aug 4, 2025

This PR adds a new tool that uses closedByPullRequestsReferences on Issue to specifically find PRs in a repo that closed the specified issues. We'd like to use this to find code changes that solved similar issues to a given new issue.

@lumaxis lumaxis requested a review from Copilot August 4, 2025 14:54
Copilot

This comment was marked as outdated.

@lumaxis lumaxis requested a review from Copilot August 4, 2025 16:26
Copilot

This comment was marked as outdated.

@lumaxis lumaxis marked this pull request as ready for review August 5, 2025 09:09
@lumaxis lumaxis requested a review from a team as a code owner August 5, 2025 09:09
@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 09:09
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 09:27
Copilot

This comment was marked as outdated.

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 10:24
@lumaxis lumaxis force-pushed the lumaxis/add-tool-issue-closing-pr branch from ec67616 to 94af699 Compare August 5, 2025 10:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new tool called find_closing_pull_requests that leverages GitHub's GraphQL API to find pull requests that closed specific issues using the closedByPullRequestsReferences field. This functionality helps identify code changes that resolved similar issues.

Key changes:

  • Added FindClosingPullRequests tool with advanced GraphQL parameters including pagination, filtering, and ordering options
  • Implemented helper functions OptionalIntArrayParam and RequiredIntArrayParam for handling integer array parameters
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/github/tools.go Added the new tool to the default toolset group
pkg/github/server.go Added helper functions for handling integer array parameters
pkg/github/issues.go Implemented the core FindClosingPullRequests tool with GraphQL queries
pkg/github/server_test.go Added unit tests for the new integer array parameter functions
pkg/github/find_closing_prs_integration_test.go Added integration tests for the new tool
e2e/e2e_test.go Added comprehensive end-to-end tests covering various scenarios
README.md Updated documentation with the new tool's parameters
Comments suppressed due to low confidence (2)

e2e/e2e_test.go:1737

  • The JSON field name closingPullRequests doesn't match the actual field name closing_pull_requests used in the response structure. This should be closing_pull_requests to match the API response format.
					} `json:"closingPullRequests"`

e2e/e2e_test.go:1738

  • The JSON field name totalCount doesn't match the actual field name total_count used in the response structure. This should be total_count to match the API response format.
					TotalCount int    `json:"totalCount"`

variables := map[string]any{
"owner": githubv4.String(owner),
"repo": githubv4.String(repo),
"number": githubv4.Int(issueNumber), // #nosec G115 - issueNumber validated to be positive
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references validation that doesn't exist. The function only checks if issueNumber < 0 but doesn't validate it to be positive (greater than 0). Consider adding proper validation or updating the comment to be accurate.

Copilot uses AI. Check for mistakes.

}

// Validate issue number (basic bounds check)
if issueNumber < 0 {
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue number validation should check for both negative values and zero, as GitHub issue numbers start from 1. Consider changing the condition to issueNumber <= 0 for more accurate validation.

Suggested change
if issueNumber < 0 {
if issueNumber <= 0 {

Copilot uses AI. Check for mistakes.

variables["last"] = githubv4.Int(params.Last) // #nosec G115 - params.Last validated to be positive
variables["first"] = (*githubv4.Int)(nil)
} else {
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be positive
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments claim validation that doesn't match the actual validation logic. The validation only checks if values are non-negative, not positive. Update the comments to reflect the actual validation or improve the validation to match the comments.

Suggested change
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be positive
"number": githubv4.Int(issueNumber), // #nosec G115 - issueNumber validated to be non-negative
}
if params.Last != 0 {
variables["last"] = githubv4.Int(params.Last) // #nosec G115 - params.Last validated to be non-negative
variables["first"] = (*githubv4.Int)(nil)
} else {
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be non-negative

Copilot uses AI. Check for mistakes.

variables["last"] = githubv4.Int(params.Last) // #nosec G115 - params.Last validated to be positive
variables["first"] = (*githubv4.Int)(nil)
} else {
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be positive
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments claim validation that doesn't match the actual validation logic. The validation only checks if values are non-negative, not positive. Update the comments to reflect the actual validation or improve the validation to match the comments.

Suggested change
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be positive
"number": githubv4.Int(issueNumber), // #nosec G115 - issueNumber validated to be non-negative
}
if params.Last != 0 {
variables["last"] = githubv4.Int(params.Last) // #nosec G115 - params.Last validated to be non-negative
variables["first"] = (*githubv4.Int)(nil)
} else {
variables["first"] = githubv4.Int(params.First) // #nosec G115 - params.First validated to be non-negative

Copilot uses AI. Check for mistakes.

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/github-mcp-server/pull/816

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy