Skip to main content
Glama

get_issue_comments

Retrieve comments for a specific GitHub issue by providing repository owner, name, and issue number, with optional pagination.

Instructions

Get comments for a specific issue in a GitHub repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner
repoYesRepository name
issue_numberYesIssue number
pageNoPage number
per_pageNoNumber of records per page

Implementation Reference

  • Handler/implementation for get_issue_comments tool. Calls octokit.rest.issues.listComments with owner, repo, issue_number, page, per_page parameters, formats results as markdown, and handles empty results and errors.
    async ({ owner, repo, issue_number, page, per_page }) => {
    	try {
    		const response = await octokit.rest.issues.listComments({
    			owner,
    			repo,
    			issue_number,
    			page,
    			per_page,
    		})
    
    		// Format the response as clean markdown
    		const comments = response.data
    
    		if (comments.length === 0) {
    			return {
    				content: [
    					{ type: "text", text: "No comments found for this issue." },
    				],
    			}
    		}
    
    		let markdown = `# Comments for Issue #${issue_number}\n\n`
    		markdown += `Showing ${comments.length} comment(s) - Page ${page}\n`
    		if (comments.length === per_page) {
    			markdown += `*Note: More comments may be available. Use 'page' parameter to see next page.*\n`
    		}
    		markdown += `\n`
    
    		comments.forEach((comment, index) => {
    			markdown += `## Comment ${index + 1}\n\n`
    			markdown += `- **Author**: ${comment.user?.login || "Unknown"}\n`
    			markdown += `- **Created**: ${new Date(comment.created_at).toLocaleDateString()}\n`
    			markdown += `- **Updated**: ${new Date(comment.updated_at).toLocaleDateString()}\n\n`
    			markdown += `**Content**:\n${comment.body}\n\n`
    			markdown += `---\n\n`
    		})
    
    		return {
    			content: [{ type: "text", text: markdown }],
    		}
    	} catch (e: any) {
    		return {
    			content: [{ type: "text", text: `Error: ${e.message}` }],
    		}
    	}
    },
  • Input schema for get_issue_comments tool using Zod validation: owner (string), repo (string), issue_number (number), page (number, optional, default 1), per_page (number, optional, default 10).
    {
    	owner: z.string().describe("Repository owner"),
    	repo: z.string().describe("Repository name"),
    	issue_number: z.number().describe("Issue number"),
    	page: z.number().optional().default(1).describe("Page number"),
    	per_page: z
    		.number()
    		.optional()
    		.default(10)
    		.describe("Number of records per page"),
  • Registration of 'get_issue_comments' tool via server.tool() call with name, description, schema, and handler. Contained within the registerIssueTools function.
    // Tool: Get Issue Comments
    server.tool(
    	"get_issue_comments",
    	"Get comments for a specific issue in a GitHub repository.",
    	{
    		owner: z.string().describe("Repository owner"),
    		repo: z.string().describe("Repository name"),
    		issue_number: z.number().describe("Issue number"),
    		page: z.number().optional().default(1).describe("Page number"),
    		per_page: z
    			.number()
    			.optional()
    			.default(10)
    			.describe("Number of records per page"),
    	},
    	async ({ owner, repo, issue_number, page, per_page }) => {
    		try {
    			const response = await octokit.rest.issues.listComments({
    				owner,
    				repo,
    				issue_number,
    				page,
    				per_page,
    			})
    
    			// Format the response as clean markdown
    			const comments = response.data
    
    			if (comments.length === 0) {
    				return {
    					content: [
    						{ type: "text", text: "No comments found for this issue." },
    					],
    				}
    			}
    
    			let markdown = `# Comments for Issue #${issue_number}\n\n`
    			markdown += `Showing ${comments.length} comment(s) - Page ${page}\n`
    			if (comments.length === per_page) {
    				markdown += `*Note: More comments may be available. Use 'page' parameter to see next page.*\n`
    			}
    			markdown += `\n`
    
    			comments.forEach((comment, index) => {
    				markdown += `## Comment ${index + 1}\n\n`
    				markdown += `- **Author**: ${comment.user?.login || "Unknown"}\n`
    				markdown += `- **Created**: ${new Date(comment.created_at).toLocaleDateString()}\n`
    				markdown += `- **Updated**: ${new Date(comment.updated_at).toLocaleDateString()}\n\n`
    				markdown += `**Content**:\n${comment.body}\n\n`
    				markdown += `---\n\n`
    			})
    
    			return {
    				content: [{ type: "text", text: markdown }],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • Parent function registerIssueTools that wraps all issue tool registrations (including get_issue_comments). Called from src/index.ts line 16.
    export function registerIssueTools(server: McpServer, octokit: Octokit) {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It fails to disclose behavioral traits such as pagination, ordering, authentication requirements, or read-only nature, leaving the agent with minimal insight into tool behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that efficiently conveys the core action without wasted words, though it could be slightly expanded to include pagination context without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description lacks mentions of pagination parameters (page, per_page) and the return format, leaving the agent underinformed for complete usage despite schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so parameters are described in the schema. The description adds no additional meaning or constraints beyond the schema, earning a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'comments for a specific issue in a GitHub repository', distinguishing it from sibling tools like 'add_issue_comment' and 'get_issue'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving issue comments but provides no explicit guidance on when to use this tool versus alternatives like 'get_pull_request_comments' for PR comments or 'get_issue' for issue details.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hithereiamaliff/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server