ig_get_comments
Retrieve comments from Instagram posts using the media ID to analyze engagement and user feedback.
Instructions
Get comments on a specific Instagram media post.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_id | Yes | Media ID | |
| limit | No | Number of comments to return | |
| after | No | Pagination cursor |
Implementation Reference
- src/tools/instagram/comments.ts:7-28 (handler)The `ig_get_comments` tool is registered and implemented directly within the `server.tool` call, handling input validation, API interaction via `client.ig`, and formatting the response.
server.tool( "ig_get_comments", "Get comments on a specific Instagram media post.", { media_id: z.string().describe("Media ID"), limit: z.number().optional().describe("Number of comments to return"), after: z.string().optional().describe("Pagination cursor"), }, async ({ media_id, limit, after }) => { try { const params: Record<string, unknown> = { fields: "id,text,username,timestamp,like_count,replies{id,text,username,timestamp}", }; if (limit) params.limit = limit; if (after) params.after = after; const { data, rateLimit } = await client.ig("GET", `/${media_id}/comments`, params); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Get comments failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );