From 332a1be7944414f6b6a2f3ee69123ca46141cfd4 Mon Sep 17 00:00:00 2001 From: Chris Guillory Date: Sat, 1 Feb 2025 21:39:09 -0800 Subject: [PATCH 1/4] feat: add missing pull request operations to GitHub server --- src/github/index.ts | 127 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/src/github/index.ts b/src/github/index.ts index 3d60e8faf..807035327 100644 --- a/src/github/index.ts +++ b/src/github/index.ts @@ -148,6 +148,52 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { name: "get_issue", description: "Get details of a specific issue in a GitHub repository.", inputSchema: zodToJsonSchema(issues.GetIssueSchema) + }, + // Adding missing pull request operations + { + name: "get_pull_request", + description: "Get details of a specific pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema), + }, + { + name: "list_pull_requests", + description: "List and filter repository pull requests", + inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema), + }, + { + name: "create_pull_request_review", + description: "Create a review on a pull request", + inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema), + }, + { + name: "merge_pull_request", + description: "Merge a pull request", + inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema), + }, + { + name: "get_pull_request_files", + description: "Get the list of files changed in a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema), + }, + { + name: "get_pull_request_status", + description: "Get the combined status of all status checks for a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema), + }, + { + name: "update_pull_request_branch", + description: "Update a pull request branch with the latest changes from the base branch", + inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema), + }, + { + name: "get_pull_request_comments", + description: "Get the review comments on a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema), + }, + { + name: "get_pull_request_reviews", + description: "Get the reviews on a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema), } ], }; @@ -334,6 +380,87 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }; } + // Adding handlers for missing pull request operations + case "get_pull_request": { + const args = pulls.GetPullRequestSchema.parse(request.params.arguments); + const pullRequest = await pulls.getPullRequest(args.owner, args.repo, args.pull_number); + return { + content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], + }; + } + + case "list_pull_requests": { + const args = pulls.ListPullRequestsSchema.parse(request.params.arguments); + const { owner, repo, ...options } = args; + const pullRequests = await pulls.listPullRequests(owner, repo, options); + return { + content: [{ type: "text", text: JSON.stringify(pullRequests, null, 2) }], + }; + } + + case "create_pull_request_review": { + const args = pulls.CreatePullRequestReviewSchema.parse(request.params.arguments); + const { owner, repo, pull_number, ...options } = args; + const review = await pulls.createPullRequestReview(owner, repo, pull_number, options); + return { + content: [{ type: "text", text: JSON.stringify(review, null, 2) }], + }; + } + + case "merge_pull_request": { + const args = pulls.MergePullRequestSchema.parse(request.params.arguments); + const { owner, repo, pull_number, ...options } = args; + const result = await pulls.mergePullRequest(owner, repo, pull_number, options); + return { + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], + }; + } + + case "get_pull_request_files": { + const args = pulls.GetPullRequestFilesSchema.parse(request.params.arguments); + const files = await pulls.getPullRequestFiles(args.owner, args.repo, args.pull_number); + return { + content: [{ type: "text", text: JSON.stringify(files, null, 2) }], + }; + } + + case "get_pull_request_status": { + const args = pulls.GetPullRequestStatusSchema.parse(request.params.arguments); + const status = await pulls.getPullRequestStatus(args.owner, args.repo, args.pull_number); + return { + content: [{ type: "text", text: JSON.stringify(status, null, 2) }], + }; + } + + case "update_pull_request_branch": { + const args = pulls.UpdatePullRequestBranchSchema.parse(request.params.arguments); + await pulls.updatePullRequestBranch( + args.owner, + args.repo, + args.pull_number, + args.expected_head_sha + ); + return { + content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }], + }; + } + + case "get_pull_request_comments": { + const args = pulls.GetPullRequestCommentsSchema.parse(request.params.arguments); + const comments = await pulls.getPullRequestComments(args.owner, args.repo, args.pull_number); + return { + content: [{ type: "text", text: JSON.stringify(comments, null, 2) }], + }; + } + + case "get_pull_request_reviews": { + const args = pulls.GetPullRequestReviewsSchema.parse(request.params.arguments); + const reviews = await pulls.getPullRequestReviews(args.owner, args.repo, args.pull_number); + return { + content: [{ type: "text", text: JSON.stringify(reviews, null, 2) }], + }; + } + default: throw new Error(`Unknown tool: ${request.params.name}`); } From f30ceecb555c5d5ce653030bd537ab20c8d79efe Mon Sep 17 00:00:00 2001 From: Chris Guillory Date: Sat, 1 Feb 2025 21:43:15 -0800 Subject: [PATCH 2/4] refactor: remove unnecessary comments From 754a6c995727f864e283983510704ee585ab865e Mon Sep 17 00:00:00 2001 From: Chris Guillory Date: Tue, 4 Feb 2025 09:09:08 -0800 Subject: [PATCH 3/4] Remove unneeded comments added my Claude --- src/github/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/github/index.ts b/src/github/index.ts index 36aaadade..9d4068ec4 100644 --- a/src/github/index.ts +++ b/src/github/index.ts @@ -150,7 +150,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { description: "Get details of a specific issue in a GitHub repository.", inputSchema: zodToJsonSchema(issues.GetIssueSchema) }, - // Adding missing pull request operations { name: "get_pull_request", description: "Get details of a specific pull request", @@ -381,7 +380,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }; } - // Adding handlers for missing pull request operations case "get_pull_request": { const args = pulls.GetPullRequestSchema.parse(request.params.arguments); const pullRequest = await pulls.getPullRequest(args.owner, args.repo, args.pull_number); @@ -485,4 +483,4 @@ async function runServer() { runServer().catch((error) => { console.error("Fatal error in main():", error); process.exit(1); -}); \ No newline at end of file +}); From 4218d8da2c62d5a758a4bc0b94eb0069781b5931 Mon Sep 17 00:00:00 2001 From: Chris Guillory Date: Wed, 5 Feb 2025 00:41:34 -0800 Subject: [PATCH 4/4] reorder additions to index.ts --- src/github/index.ts | 236 ++++++++++++++++++++++---------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/src/github/index.ts b/src/github/index.ts index 9d4068ec4..694fc3ec9 100644 --- a/src/github/index.ts +++ b/src/github/index.ts @@ -100,6 +100,51 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { description: "Create a new pull request in a GitHub repository", inputSchema: zodToJsonSchema(pulls.CreatePullRequestSchema), }, + { + name: "get_pull_request", + description: "Get details of a specific pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema), + }, + { + name: "list_pull_requests", + description: "List and filter repository pull requests", + inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema), + }, + { + name: "create_pull_request_review", + description: "Create a review on a pull request", + inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema), + }, + { + name: "merge_pull_request", + description: "Merge a pull request", + inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema), + }, + { + name: "get_pull_request_files", + description: "Get the list of files changed in a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema), + }, + { + name: "get_pull_request_status", + description: "Get the combined status of all status checks for a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema), + }, + { + name: "update_pull_request_branch", + description: "Update a pull request branch with the latest changes from the base branch", + inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema), + }, + { + name: "get_pull_request_comments", + description: "Get the review comments on a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema), + }, + { + name: "get_pull_request_reviews", + description: "Get the reviews on a pull request", + inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema), + }, { name: "fork_repository", description: "Fork a GitHub repository to your account or specified organization", @@ -149,51 +194,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { name: "get_issue", description: "Get details of a specific issue in a GitHub repository.", inputSchema: zodToJsonSchema(issues.GetIssueSchema) - }, - { - name: "get_pull_request", - description: "Get details of a specific pull request", - inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema), - }, - { - name: "list_pull_requests", - description: "List and filter repository pull requests", - inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema), - }, - { - name: "create_pull_request_review", - description: "Create a review on a pull request", - inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema), - }, - { - name: "merge_pull_request", - description: "Merge a pull request", - inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema), - }, - { - name: "get_pull_request_files", - description: "Get the list of files changed in a pull request", - inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema), - }, - { - name: "get_pull_request_status", - description: "Get the combined status of all status checks for a pull request", - inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema), - }, - { - name: "update_pull_request_branch", - description: "Update a pull request branch with the latest changes from the base branch", - inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema), - }, - { - name: "get_pull_request_comments", - description: "Get the review comments on a pull request", - inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema), - }, - { - name: "get_pull_request_reviews", - description: "Get the reviews on a pull request", - inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema), } ], }; @@ -307,79 +307,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }; } - case "search_code": { - const args = search.SearchCodeSchema.parse(request.params.arguments); - const results = await search.searchCode(args); - return { - content: [{ type: "text", text: JSON.stringify(results, null, 2) }], - }; - } - - case "search_issues": { - const args = search.SearchIssuesSchema.parse(request.params.arguments); - const results = await search.searchIssues(args); - return { - content: [{ type: "text", text: JSON.stringify(results, null, 2) }], - }; - } - - case "search_users": { - const args = search.SearchUsersSchema.parse(request.params.arguments); - const results = await search.searchUsers(args); - return { - content: [{ type: "text", text: JSON.stringify(results, null, 2) }], - }; - } - - case "list_issues": { - const args = issues.ListIssuesOptionsSchema.parse(request.params.arguments); - const { owner, repo, ...options } = args; - const result = await issues.listIssues(owner, repo, options); - return { - content: [{ type: "text", text: JSON.stringify(result, null, 2) }], - }; - } - - case "update_issue": { - const args = issues.UpdateIssueOptionsSchema.parse(request.params.arguments); - const { owner, repo, issue_number, ...options } = args; - const result = await issues.updateIssue(owner, repo, issue_number, options); - return { - content: [{ type: "text", text: JSON.stringify(result, null, 2) }], - }; - } - - case "add_issue_comment": { - const args = issues.IssueCommentSchema.parse(request.params.arguments); - const { owner, repo, issue_number, body } = args; - const result = await issues.addIssueComment(owner, repo, issue_number, body); - return { - content: [{ type: "text", text: JSON.stringify(result, null, 2) }], - }; - } - - case "list_commits": { - const args = commits.ListCommitsSchema.parse(request.params.arguments); - const results = await commits.listCommits( - args.owner, - args.repo, - args.page, - args.perPage, - args.sha - ); - return { - content: [{ type: "text", text: JSON.stringify(results, null, 2) }], - }; - } - - case "get_issue": { - const args = issues.GetIssueSchema.parse(request.params.arguments); - const issue = await issues.getIssue(args.owner, args.repo, args.issue_number); - return { - content: [{ type: "text", text: JSON.stringify(issue, null, 2) }], - }; - } - case "get_pull_request": { const args = pulls.GetPullRequestSchema.parse(request.params.arguments); const pullRequest = await pulls.getPullRequest(args.owner, args.repo, args.pull_number); @@ -460,6 +387,79 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }; } + case "search_code": { + const args = search.SearchCodeSchema.parse(request.params.arguments); + const results = await search.searchCode(args); + return { + content: [{ type: "text", text: JSON.stringify(results, null, 2) }], + }; + } + + case "search_issues": { + const args = search.SearchIssuesSchema.parse(request.params.arguments); + const results = await search.searchIssues(args); + return { + content: [{ type: "text", text: JSON.stringify(results, null, 2) }], + }; + } + + case "search_users": { + const args = search.SearchUsersSchema.parse(request.params.arguments); + const results = await search.searchUsers(args); + return { + content: [{ type: "text", text: JSON.stringify(results, null, 2) }], + }; + } + + case "list_issues": { + const args = issues.ListIssuesOptionsSchema.parse(request.params.arguments); + const { owner, repo, ...options } = args; + const result = await issues.listIssues(owner, repo, options); + return { + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], + }; + } + + case "update_issue": { + const args = issues.UpdateIssueOptionsSchema.parse(request.params.arguments); + const { owner, repo, issue_number, ...options } = args; + const result = await issues.updateIssue(owner, repo, issue_number, options); + return { + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], + }; + } + + case "add_issue_comment": { + const args = issues.IssueCommentSchema.parse(request.params.arguments); + const { owner, repo, issue_number, body } = args; + const result = await issues.addIssueComment(owner, repo, issue_number, body); + return { + content: [{ type: "text", text: JSON.stringify(result, null, 2) }], + }; + } + + case "list_commits": { + const args = commits.ListCommitsSchema.parse(request.params.arguments); + const results = await commits.listCommits( + args.owner, + args.repo, + args.page, + args.perPage, + args.sha + ); + return { + content: [{ type: "text", text: JSON.stringify(results, null, 2) }], + }; + } + + case "get_issue": { + const args = issues.GetIssueSchema.parse(request.params.arguments); + const issue = await issues.getIssue(args.owner, args.repo, args.issue_number); + return { + content: [{ type: "text", text: JSON.stringify(issue, null, 2) }], + }; + } + default: throw new Error(`Unknown tool: ${request.params.name}`); }