@@ -20,6 +20,7 @@ import {
20
20
CreateRepositorySchema ,
21
21
ForkRepositorySchema ,
22
22
GetFileContentsSchema ,
23
+ GetIssueSchema ,
23
24
GitHubCommitSchema ,
24
25
GitHubContentSchema ,
25
26
GitHubCreateUpdateFileResponseSchema ,
@@ -691,6 +692,29 @@ async function searchUsers(
691
692
return SearchUsersResponseSchema . parse ( await response . json ( ) ) ;
692
693
}
693
694
695
+ async function getIssue (
696
+ owner : string ,
697
+ repo : string ,
698
+ issueNumber : number
699
+ ) : Promise < GitHubIssue > {
700
+ const response = await fetch (
701
+ `https://api.github.com/repos/${ owner } /${ repo } /issues/${ issueNumber } ` ,
702
+ {
703
+ headers : {
704
+ Authorization : `token ${ GITHUB_PERSONAL_ACCESS_TOKEN } ` ,
705
+ Accept : "application/vnd.github.v3+json" ,
706
+ "User-Agent" : "github-mcp-server" ,
707
+ } ,
708
+ }
709
+ ) ;
710
+
711
+ if ( ! response . ok ) {
712
+ throw new Error ( `Github API error: ${ response . statusText } ` ) ;
713
+ }
714
+
715
+ return GitHubIssueSchema . parse ( await response . json ( ) ) ;
716
+ }
717
+
694
718
server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
695
719
return {
696
720
tools : [
@@ -778,6 +802,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
778
802
description : "Search for users on GitHub" ,
779
803
inputSchema : zodToJsonSchema ( SearchUsersSchema ) ,
780
804
} ,
805
+ {
806
+ name : "get_issue" ,
807
+ description : "Get details of a specific issue in a GitHub repository." ,
808
+ inputSchema : zodToJsonSchema ( GetIssueSchema )
809
+ }
781
810
] ,
782
811
} ;
783
812
} ) ;
@@ -972,6 +1001,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
972
1001
return { content : [ { type : "text" , text : JSON . stringify ( results , null , 2 ) } ] } ;
973
1002
}
974
1003
1004
+ case "get_issue" : {
1005
+ const args = z . object ( {
1006
+ owner : z . string ( ) ,
1007
+ repo : z . string ( ) ,
1008
+ issue_number : z . number ( )
1009
+ } ) . parse ( request . params . arguments ) ;
1010
+ const issue = await getIssue ( args . owner , args . repo , args . issue_number ) ;
1011
+ return { toolResult : issue } ;
1012
+ }
1013
+
975
1014
default :
976
1015
throw new Error ( `Unknown tool: ${ request . params . name } ` ) ;
977
1016
}
0 commit comments