ig_get_media_list
Retrieve Instagram media posts from an account with pagination controls to manage content lists efficiently.
Instructions
Get list of media published on the Instagram account.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results (max 100, default 25) | |
| after | No | Pagination cursor for next page | |
| before | No | Pagination cursor for previous page |
Implementation Reference
- src/tools/instagram/media.ts:7-29 (handler)Handler implementation of ig_get_media_list tool.
server.tool( "ig_get_media_list", "Get list of media published on the Instagram account.", { limit: z.number().optional().describe("Number of results (max 100, default 25)"), after: z.string().optional().describe("Pagination cursor for next page"), before: z.string().optional().describe("Pagination cursor for previous page"), }, async ({ limit, after, before }) => { try { const params: Record<string, unknown> = { fields: "id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,like_count,comments_count", }; if (limit) params.limit = limit; if (after) params.after = after; if (before) params.before = before; const { data, rateLimit } = await client.ig("GET", `/${client.igUserId}/media`, params); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Get media list failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );