Skip to main content
Glama

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
NameRequiredDescriptionDefault
media_idYesMedia ID
limitNoNumber of comments to return
afterNoPagination cursor

Implementation Reference

  • 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 };
        }
      }
    );

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/mikusnuz/meta-mcp'

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