MCPcopy Index your code
hub / github.com/github/github-mcp-server / GetPullRequestStatus

Function GetPullRequestStatus

pkg/github/pullrequests.go:250–294  ·  view source on GitHub ↗
(ctx context.Context, client *github.Client, owner, repo string, pullNumber int)

Source from the content-addressed store, hash-verified

248}
249
250func GetPullRequestStatus(ctx context.Context, client *github.Client, owner, repo string, pullNumber int) (*mcp.CallToolResult, error) {
251 pr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber)
252 if err != nil {
253 return ghErrors.NewGitHubAPIErrorResponse(ctx,
254 "failed to get pull request",
255 resp,
256 err,
257 ), nil
258 }
259 defer func() { _ = resp.Body.Close() }()
260
261 if resp.StatusCode != http.StatusOK {
262 body, err := io.ReadAll(resp.Body)
263 if err != nil {
264 return nil, fmt.Errorf("failed to read response body: %w", err)
265 }
266 return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get pull request", resp, body), nil
267 }
268
269 // Get combined status for the head SHA
270 status, resp, err := client.Repositories.GetCombinedStatus(ctx, owner, repo, *pr.Head.SHA, nil)
271 if err != nil {
272 return ghErrors.NewGitHubAPIErrorResponse(ctx,
273 "failed to get combined status",
274 resp,
275 err,
276 ), nil
277 }
278 defer func() { _ = resp.Body.Close() }()
279
280 if resp.StatusCode != http.StatusOK {
281 body, err := io.ReadAll(resp.Body)
282 if err != nil {
283 return nil, fmt.Errorf("failed to read response body: %w", err)
284 }
285 return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get combined status", resp, body), nil
286 }
287
288 r, err := json.Marshal(status)
289 if err != nil {
290 return nil, fmt.Errorf("failed to marshal response: %w", err)
291 }
292
293 return utils.NewToolResultText(string(r)), nil
294}
295
296func GetPullRequestCheckRuns(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {
297 // First get the PR to get the head SHA

Callers 1

PullRequestReadFunction · 0.85

Calls 2

NewToolResultTextFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected