get_media_posts
Retrieve recent Instagram posts with engagement metrics to analyze performance and content effectiveness.
Instructions
Get recent media posts from Instagram account with engagement metrics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | No | Instagram business account ID (optional) | |
| limit | No | Number of posts to retrieve (max 100) | |
| after | No | Pagination cursor |
Implementation Reference
- src/client.ts:256-270 (handler)The core handler implementation for retrieving media posts from the Instagram API.
async getMediaPosts( limit = 25, after?: string, accountId?: string ): Promise<IGMedia[]> { const id = accountId ?? this.aid(); const fields = "id,media_type,media_url,permalink,thumbnail_url,caption,timestamp,like_count,comments_count"; const params: Record<string, string> = { fields, limit: String(Math.min(limit, 100)), }; if (after) params.after = after; const data = await this.request("GET", `${id}/media`, { params }); return data.data ?? []; - src/index.ts:68-80 (registration)Registration of the get_media_posts MCP tool.
{ name: "get_media_posts", description: "Get recent media posts from Instagram account with engagement metrics", inputSchema: { type: "object" as const, properties: { account_id: { type: "string", description: "Instagram business account ID (optional)" }, limit: { type: "integer", description: "Number of posts to retrieve (max 100)", minimum: 1, maximum: 100, default: 25 }, after: { type: "string", description: "Pagination cursor" }, }, }, }, - src/index.ts:355-358 (handler)Tool execution logic that invokes the client method getMediaPosts.
case "get_media_posts": { const posts = await c.getMediaPosts(args.limit ?? 25, args.after, args.account_id); return JSON.stringify({ posts, count: posts.length }, null, 2); }