Skip to main content
Glama

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
NameRequiredDescriptionDefault
account_idNoInstagram business account ID (optional)
limitNoNumber of posts to retrieve (max 100)
afterNoPagination cursor

Implementation Reference

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

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/mcpware/instagram-mcp'

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