@@ -56,6 +56,8 @@ import {
56
56
UpdateIssueOptionsSchema ,
57
57
GetPullRequestCommentsSchema ,
58
58
PullRequestCommentSchema ,
59
+ GetPullRequestReviewsSchema ,
60
+ PullRequestReviewSchema ,
59
61
type FileOperation ,
60
62
type GitHubCommit ,
61
63
type GitHubContent ,
@@ -904,6 +906,29 @@ async function getPullRequestComments(
904
906
return z . array ( PullRequestCommentSchema ) . parse ( await response . json ( ) ) ;
905
907
}
906
908
909
+ async function getPullRequestReviews (
910
+ owner : string ,
911
+ repo : string ,
912
+ pullNumber : number
913
+ ) : Promise < z . infer < typeof PullRequestReviewSchema > [ ] > {
914
+ const response = await fetch (
915
+ `https://api.github.com/repos/${ owner } /${ repo } /pulls/${ pullNumber } /reviews` ,
916
+ {
917
+ headers : {
918
+ Authorization : `token ${ GITHUB_PERSONAL_ACCESS_TOKEN } ` ,
919
+ Accept : "application/vnd.github.v3+json" ,
920
+ "User-Agent" : "github-mcp-server" ,
921
+ } ,
922
+ }
923
+ ) ;
924
+
925
+ if ( ! response . ok ) {
926
+ throw new Error ( `GitHub API error: ${ response . statusText } ` ) ;
927
+ }
928
+
929
+ return z . array ( PullRequestReviewSchema ) . parse ( await response . json ( ) ) ;
930
+ }
931
+
907
932
async function getPullRequestStatus (
908
933
owner : string ,
909
934
repo : string ,
@@ -1078,6 +1103,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
1078
1103
name : "get_pull_request_comments" ,
1079
1104
description : "Get the review comments on a pull request" ,
1080
1105
inputSchema : zodToJsonSchema ( GetPullRequestCommentsSchema )
1106
+ } ,
1107
+ {
1108
+ name : "get_pull_request_reviews" ,
1109
+ description : "Get the reviews on a pull request" ,
1110
+ inputSchema : zodToJsonSchema ( GetPullRequestReviewsSchema )
1081
1111
}
1082
1112
] ,
1083
1113
} ;
@@ -1334,6 +1364,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1334
1364
return { content : [ { type : "text" , text : JSON . stringify ( comments , null , 2 ) } ] } ;
1335
1365
}
1336
1366
1367
+ case "get_pull_request_reviews" : {
1368
+ const args = GetPullRequestReviewsSchema . parse ( request . params . arguments ) ;
1369
+ const reviews = await getPullRequestReviews ( args . owner , args . repo , args . pull_number ) ;
1370
+ return { content : [ { type : "text" , text : JSON . stringify ( reviews , null , 2 ) } ] } ;
1371
+ }
1372
+
1337
1373
default :
1338
1374
throw new Error ( `Unknown tool: ${ request . params . name } ` ) ;
1339
1375
}
0 commit comments