@@ -20,6 +20,7 @@ import {
2020 CreateRepositorySchema ,
2121 ForkRepositorySchema ,
2222 GetFileContentsSchema ,
23+ GetIssueSchema ,
2324 GitHubCommitSchema ,
2425 GitHubContentSchema ,
2526 GitHubCreateUpdateFileResponseSchema ,
@@ -691,6 +692,29 @@ async function searchUsers(
691692 return SearchUsersResponseSchema . parse ( await response . json ( ) ) ;
692693}
693694
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+
694718server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
695719 return {
696720 tools : [
@@ -778,6 +802,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
778802 description : "Search for users on GitHub" ,
779803 inputSchema : zodToJsonSchema ( SearchUsersSchema ) ,
780804 } ,
805+ {
806+ name : "get_issue" ,
807+ description : "Get details of a specific issue in a GitHub repository." ,
808+ inputSchema : zodToJsonSchema ( GetIssueSchema )
809+ }
781810 ] ,
782811 } ;
783812} ) ;
@@ -972,6 +1001,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
9721001 return { content : [ { type : "text" , text : JSON . stringify ( results , null , 2 ) } ] } ;
9731002 }
9741003
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+
9751014 default :
9761015 throw new Error ( `Unknown tool: ${ request . params . name } ` ) ;
9771016 }
0 commit comments