MCPcopy
hub / github.com/github/github-mcp-server / PullRequestRead

Function PullRequestRead

pkg/github/pullrequests.go:27–161  ·  view source on GitHub ↗

PullRequestRead creates a tool to get details of a specific pull request.

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

25
26// PullRequestRead creates a tool to get details of a specific pull request.
27func PullRequestRead(t translations.TranslationHelperFunc) inventory.ServerTool {
28 schema := &jsonschema.Schema{
29 Type: "object",
30 Properties: map[string]*jsonschema.Schema{
31 "method": {
32 Type: "string",
33 Description: `Action to specify what pull request data needs to be retrieved from GitHub.
34Possible options:
35 1. get - Get details of a specific pull request.
36 2. get_diff - Get the diff of a pull request.
37 3. get_status - Get combined commit status of a head commit in a pull request.
38 4. get_files - Get the list of files changed in a pull request. Use with pagination parameters to control the number of results returned.
39 5. get_commits - Get the list of commits on a pull request. Use with pagination parameters to control the number of results returned.
40 6. get_review_comments - Get review threads on a pull request. Each thread contains logically grouped review comments made on the same code location during pull request reviews. Returns threads with metadata (isResolved, isOutdated, isCollapsed) and their associated comments. Use cursor-based pagination (perPage, after) to control results.
41 7. get_reviews - Get the reviews on a pull request. When asked for review comments, use get_review_comments method. Use with pagination parameters to control the number of results returned.
42 8. get_comments - Get comments on a pull request. Use this if user doesn't specifically want review comments. Use with pagination parameters to control the number of results returned.
43 9. get_check_runs - Get check runs for the head commit of a pull request. Check runs are the individual CI/CD jobs and checks that run on the PR.
44`,
45 Enum: []any{"get", "get_diff", "get_status", "get_files", "get_commits", "get_review_comments", "get_reviews", "get_comments", "get_check_runs"},
46 },
47 "owner": {
48 Type: "string",
49 Description: "Repository owner",
50 },
51 "repo": {
52 Type: "string",
53 Description: "Repository name",
54 },
55 "pullNumber": {
56 Type: "number",
57 Description: "Pull request number",
58 },
59 },
60 Required: []string{"method", "owner", "repo", "pullNumber"},
61 }
62 WithPagination(schema)
63 // get_review_comments uses GraphQL cursor-based pagination and accepts the
64 // `after` cursor. Other methods rely on the `page`/`perPage` parameters
65 // added by WithPagination and ignore `after`.
66 schema.Properties["after"] = &jsonschema.Schema{
67 Type: "string",
68 Description: "Cursor for pagination, used only by the get_review_comments method. Pass the endCursor from the previous page's PageInfo to fetch the next page.",
69 }
70
71 return NewTool(
72 ToolsetMetadataPullRequests,
73 mcp.Tool{
74 Name: "pull_request_read",
75 Description: t("TOOL_PULL_REQUEST_READ_DESCRIPTION", "Get information on a specific pull request in GitHub repository."),
76 Annotations: &mcp.ToolAnnotations{
77 Title: t("TOOL_GET_PULL_REQUEST_USER_TITLE", "Get details for a single pull request"),
78 ReadOnlyHint: true,
79 },
80 InputSchema: schema,
81 },
82 []scopes.Scope{scopes.Repo},
83 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
84 method, err := RequiredParam[string](args, "method")

Callers 9

AllToolsFunction · 0.85
Test_GetPullRequestFunction · 0.85
Test_GetPullRequestFilesFunction · 0.85
TestGetPullRequestDiffFunction · 0.85

Calls 15

NewToolResultErrorFunction · 0.92
WithPaginationFunction · 0.85
NewToolFunction · 0.85
RequiredIntFunction · 0.85
OptionalPaginationParamsFunction · 0.85
GetPullRequestFunction · 0.85
GetPullRequestDiffFunction · 0.85
GetPullRequestStatusFunction · 0.85
GetPullRequestFilesFunction · 0.85
GetPullRequestCommitsFunction · 0.85

Tested by 8

Test_GetPullRequestFunction · 0.68
Test_GetPullRequestFilesFunction · 0.68
TestGetPullRequestDiffFunction · 0.68