Skip to content

Commit 5e1350d

Browse files
Merge pull request #503 from modelcontextprotocol/justin/github-prs
[GitHub] Add PR listing, reading, reviewing, and merging tools
2 parents a2967d1 + de256a4 commit 5e1350d

File tree

3 files changed

+385
-217
lines changed

3 files changed

+385
-217
lines changed

src/github/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,95 @@ MCP Server for the GitHub API, enabling file operations, repository management,
188188
- `issue_number` (number): Issue number to retrieve
189189
- Returns: Github Issue object & details
190190

191+
18. `get_pull_request`
192+
- Get details of a specific pull request
193+
- Inputs:
194+
- `owner` (string): Repository owner
195+
- `repo` (string): Repository name
196+
- `pull_number` (number): Pull request number
197+
- Returns: Pull request details including diff and review status
198+
199+
19. `list_pull_requests`
200+
- List and filter repository pull requests
201+
- Inputs:
202+
- `owner` (string): Repository owner
203+
- `repo` (string): Repository name
204+
- `state` (optional string): Filter by state ('open', 'closed', 'all')
205+
- `head` (optional string): Filter by head user/org and branch
206+
- `base` (optional string): Filter by base branch
207+
- `sort` (optional string): Sort by ('created', 'updated', 'popularity', 'long-running')
208+
- `direction` (optional string): Sort direction ('asc', 'desc')
209+
- `per_page` (optional number): Results per page (max 100)
210+
- `page` (optional number): Page number
211+
- Returns: Array of pull request details
212+
213+
20. `create_pull_request_review`
214+
- Create a review on a pull request
215+
- Inputs:
216+
- `owner` (string): Repository owner
217+
- `repo` (string): Repository name
218+
- `pull_number` (number): Pull request number
219+
- `body` (string): Review comment text
220+
- `event` (string): Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT')
221+
- `commit_id` (optional string): SHA of commit to review
222+
- `comments` (optional array): Line-specific comments, each with:
223+
- `path` (string): File path
224+
- `position` (number): Line position in diff
225+
- `body` (string): Comment text
226+
- Returns: Created review details
227+
228+
21. `merge_pull_request`
229+
- Merge a pull request
230+
- Inputs:
231+
- `owner` (string): Repository owner
232+
- `repo` (string): Repository name
233+
- `pull_number` (number): Pull request number
234+
- `commit_title` (optional string): Title for merge commit
235+
- `commit_message` (optional string): Extra detail for merge commit
236+
- `merge_method` (optional string): Merge method ('merge', 'squash', 'rebase')
237+
- Returns: Merge result details
238+
239+
22. `get_pull_request_files`
240+
- Get the list of files changed in a pull request
241+
- Inputs:
242+
- `owner` (string): Repository owner
243+
- `repo` (string): Repository name
244+
- `pull_number` (number): Pull request number
245+
- Returns: Array of changed files with patch and status details
246+
247+
23. `get_pull_request_status`
248+
- Get the combined status of all status checks for a pull request
249+
- Inputs:
250+
- `owner` (string): Repository owner
251+
- `repo` (string): Repository name
252+
- `pull_number` (number): Pull request number
253+
- Returns: Combined status check results and individual check details
254+
255+
24. `update_pull_request_branch`
256+
- Update a pull request branch with the latest changes from the base branch (equivalent to GitHub's "Update branch" button)
257+
- Inputs:
258+
- `owner` (string): Repository owner
259+
- `repo` (string): Repository name
260+
- `pull_number` (number): Pull request number
261+
- `expected_head_sha` (optional string): The expected SHA of the pull request's HEAD ref
262+
- Returns: Success message when branch is updated
263+
264+
25. `get_pull_request_comments`
265+
- Get the review comments on a pull request
266+
- Inputs:
267+
- `owner` (string): Repository owner
268+
- `repo` (string): Repository name
269+
- `pull_number` (number): Pull request number
270+
- Returns: Array of pull request review comments with details like the comment text, author, and location in the diff
271+
272+
26. `get_pull_request_reviews`
273+
- Get the reviews on a pull request
274+
- Inputs:
275+
- `owner` (string): Repository owner
276+
- `repo` (string): Repository name
277+
- `pull_number` (number): Pull request number
278+
- Returns: Array of pull request reviews with details like the review state (APPROVED, CHANGES_REQUESTED, etc.), reviewer, and review body
279+
191280
## Search Query Syntax
192281

193282
### Code Search

src/github/common/types.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,42 @@ export const GitHubSearchResponseSchema = z.object({
204204
items: z.array(GitHubRepositorySchema),
205205
});
206206

207+
// Pull request schemas
208+
export const GitHubPullRequestRefSchema = z.object({
209+
label: z.string(),
210+
ref: z.string(),
211+
sha: z.string(),
212+
user: GitHubIssueAssigneeSchema,
213+
repo: GitHubRepositorySchema,
214+
});
215+
216+
export const GitHubPullRequestSchema = z.object({
217+
url: z.string(),
218+
id: z.number(),
219+
node_id: z.string(),
220+
html_url: z.string(),
221+
diff_url: z.string(),
222+
patch_url: z.string(),
223+
issue_url: z.string(),
224+
number: z.number(),
225+
state: z.string(),
226+
locked: z.boolean(),
227+
title: z.string(),
228+
user: GitHubIssueAssigneeSchema,
229+
body: z.string().nullable(),
230+
created_at: z.string(),
231+
updated_at: z.string(),
232+
closed_at: z.string().nullable(),
233+
merged_at: z.string().nullable(),
234+
merge_commit_sha: z.string().nullable(),
235+
assignee: GitHubIssueAssigneeSchema.nullable(),
236+
assignees: z.array(GitHubIssueAssigneeSchema),
237+
requested_reviewers: z.array(GitHubIssueAssigneeSchema),
238+
labels: z.array(GitHubLabelSchema),
239+
head: GitHubPullRequestRefSchema,
240+
base: GitHubPullRequestRefSchema,
241+
});
242+
207243
// Export types
208244
export type GitHubAuthor = z.infer<typeof GitHubAuthorSchema>;
209245
export type GitHubRepository = z.infer<typeof GitHubRepositorySchema>;
@@ -218,4 +254,6 @@ export type GitHubIssueAssignee = z.infer<typeof GitHubIssueAssigneeSchema>;
218254
export type GitHubLabel = z.infer<typeof GitHubLabelSchema>;
219255
export type GitHubMilestone = z.infer<typeof GitHubMilestoneSchema>;
220256
export type GitHubIssue = z.infer<typeof GitHubIssueSchema>;
221-
export type GitHubSearchResponse = z.infer<typeof GitHubSearchResponseSchema>;
257+
export type GitHubSearchResponse = z.infer<typeof GitHubSearchResponseSchema>;
258+
export type GitHubPullRequest = z.infer<typeof GitHubPullRequestSchema>;
259+
export type GitHubPullRequestRef = z.infer<typeof GitHubPullRequestRefSchema>;

0 commit comments

Comments
 (0)