Skip to content

Commit 25d1a1c

Browse files
Merge pull request #254 from Aschent89/feature/get-issue-details
Feature/get_issue [github]
2 parents cb8d4e4 + 9038094 commit 25d1a1c

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/github/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ MCP Server for the GitHub API, enabling file operations, repository management,
180180
- `sha` (optional string): branch name
181181
- Returns: List of commits
182182

183+
17. `get_issue`
184+
- Gets the contents of an issue within a repository
185+
- Inputs:
186+
- `owner` (string): Repository owner
187+
- `repo` (string): Repository name
188+
- `issue_number` (number): Issue number to retrieve
189+
- Returns: Github Issue object & details
190+
183191
## Search Query Syntax
184192

185193
### Code Search

src/github/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
694718
server.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
}

src/github/schemas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,12 @@ export const IssueCommentSchema = z.object({
677677
body: z.string()
678678
});
679679

680+
export const GetIssueSchema = z.object({
681+
owner: z.string().describe("Repository owner (username or organization)"),
682+
repo: z.string().describe("Repository name"),
683+
issue_number: z.number().describe("Issue number")
684+
});
685+
680686
// Export types
681687
export type GitHubAuthor = z.infer<typeof GitHubAuthorSchema>;
682688
export type GitHubFork = z.infer<typeof GitHubForkSchema>;

0 commit comments

Comments
 (0)