@@ -19,12 +19,22 @@ import (
1919
2020// GetPullRequest creates a tool to get details of a specific pull request.
2121func GetPullRequest(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
22- return mcp.NewTool("get_pull_request ",
23- mcp.WithDescription(t("TOOL_GET_PULL_REQUEST_DESCRIPTION ", "Get details of a specific pull request in a GitHub repository.")),
22+ return mcp.NewTool("pull_request_read ",
23+ mcp.WithDescription(t("TOOL_PULL_REQUEST_READ_DESCRIPTION ", "Get information on a specific pull request in GitHub repository.")),
2424 mcp.WithToolAnnotation(mcp.ToolAnnotation{
25- Title: t("TOOL_GET_PULL_REQUEST_USER_TITLE", "Get pull request details"),
25+ Title: t("TOOL_GET_PULL_REQUEST_USER_TITLE", "Get pull requests details. "),
2626 ReadOnlyHint: ToBoolPtr(true),
2727 }),
28+ mcp.WithString("method",
29+ mcp.Required(),
30+ mcp.Description(`Action to perform with pull requests in GitHub.
31+ Possible options:
32+ 1. get - Get details of a specific pull request in a GitHub repository.
33+ 2. get_diff - Get the diff of a pull request.
34+ 3. get_files - Get the files changed in a specific pull request.
35+ 4. get_status - Get status of a pull request.
36+ `),
37+ ),
2838 mcp.WithString("owner",
2939 mcp.Required(),
3040 mcp.Description("Repository owner"),
@@ -56,6 +66,8 @@ func GetPullRequest(getClient GetClientFn, t translations.TranslationHelperFunc)
5666 if err != nil {
5767 return nil, fmt.Errorf("failed to get GitHub client: %w", err)
5868 }
69+
70+
5971 pr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber)
6072 if err != nil {
6173 return ghErrors.NewGitHubAPIErrorResponse(ctx,
@@ -1870,6 +1882,33 @@ func RequestCopilotReview(getClient GetClientFn, t translations.TranslationHelpe
18701882 }
18711883}
18721884
1885+ func GetPullRequest() {
1886+ pr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber)
1887+ if err != nil {
1888+ return ghErrors.NewGitHubAPIErrorResponse(ctx,
1889+ "failed to get pull request",
1890+ resp,
1891+ err,
1892+ ), nil
1893+ }
1894+ defer func() { _ = resp.Body.Close() }()
1895+
1896+ if resp.StatusCode != http.StatusOK {
1897+ body, err := io.ReadAll(resp.Body)
1898+ if err != nil {
1899+ return nil, fmt.Errorf("failed to read response body: %w", err)
1900+ }
1901+ return mcp.NewToolResultError(fmt.Sprintf("failed to get pull request: %s", string(body))), nil
1902+ }
1903+
1904+ r, err := json.Marshal(pr)
1905+ if err != nil {
1906+ return nil, fmt.Errorf("failed to marshal response: %w", err)
1907+ }
1908+
1909+ return mcp.NewToolResultText(string(r)), nil
1910+ }
1911+
18731912// newGQLString like takes something that approximates a string (of which there are many types in shurcooL/githubv4)
18741913// and constructs a pointer to it, or nil if the string is empty. This is extremely useful because when we parse
18751914// params from the MCP request, we need to convert them to types that are pointers of type def strings and it's
0 commit comments