get_issue
Retrieve details of a GitHub issue by providing owner, repository, and issue number.
Instructions
Get details of a specific issue in a GitHub repository.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | The owner of the repository | |
| repo | Yes | The name of the repository | |
| issue_number | Yes | The number of the issue |
Implementation Reference
- src/tools/issues.ts:15-42 (handler)The handler function that fetches a specific issue from GitHub using Octokit and formats the response as markdown text.
async ({ owner, repo, issue_number }) => { try { const response = await octokit.rest.issues.get({ owner, repo, issue_number, }) const i = response.data let text = `**#${i.number}: ${i.title}**\n` text += `State: ${i.state}\n` text += `URL: ${i.html_url}\n` text += `Author: ${i.user?.login || "unknown"}\n` text += `Created: ${i.created_at}\n` text += `Updated: ${i.updated_at}\n` if (i.assignees && i.assignees.length > 0) text += `Assignees: ${i.assignees.map(a => a.login).join(", ")}\n` if (i.labels && i.labels.length > 0) text += `Labels: ${i.labels.map(l => typeof l === "string" ? l : l.name).join(", ")}\n` if (i.milestone) text += `Milestone: ${i.milestone.title}\n` text += `Comments: ${i.comments}\n` if (i.body) text += `\n---\n${i.body}\n` return { content: [{ type: "text", text }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, - src/tools/issues.ts:10-14 (schema)Zod schema defining the input parameters for get_issue: owner (string), repo (string), issue_number (number).
{ owner: z.string().describe("The owner of the repository"), repo: z.string().describe("The name of the repository"), issue_number: z.number().describe("The number of the issue"), }, - src/tools/issues.ts:7-43 (registration)Registration of the 'get_issue' tool on the MCP server via server.tool(), inside the registerIssueTools function.
server.tool( "get_issue", "Get details of a specific issue in a GitHub repository.", { owner: z.string().describe("The owner of the repository"), repo: z.string().describe("The name of the repository"), issue_number: z.number().describe("The number of the issue"), }, async ({ owner, repo, issue_number }) => { try { const response = await octokit.rest.issues.get({ owner, repo, issue_number, }) const i = response.data let text = `**#${i.number}: ${i.title}**\n` text += `State: ${i.state}\n` text += `URL: ${i.html_url}\n` text += `Author: ${i.user?.login || "unknown"}\n` text += `Created: ${i.created_at}\n` text += `Updated: ${i.updated_at}\n` if (i.assignees && i.assignees.length > 0) text += `Assignees: ${i.assignees.map(a => a.login).join(", ")}\n` if (i.labels && i.labels.length > 0) text += `Labels: ${i.labels.map(l => typeof l === "string" ? l : l.name).join(", ")}\n` if (i.milestone) text += `Milestone: ${i.milestone.title}\n` text += `Comments: ${i.comments}\n` if (i.body) text += `\n---\n${i.body}\n` return { content: [{ type: "text", text }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, ) - src/index.ts:16-16 (registration)Top-level call that registers all issue tools (including get_issue) on the MCP server instance.
registerIssueTools(server, octokit) - src/tools/issues.ts:5-5 (helper)Helper function that encapsulates registration of all issue-related tools on the MCP server.
export function registerIssueTools(server: McpServer, octokit: Octokit) {