Skip to main content
Glama

ig_get_media

Retrieve details of a specific Instagram media post using its media ID. Obtain caption, media type, URL, timestamp, like count, and comments count.

Instructions

Get details of a specific Instagram media post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
media_idYesMedia ID
fieldsNoComma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)

Implementation Reference

  • The main tool handler for 'ig_get_media'. Defines the tool on the MCP server with schema (media_id required, fields optional) and async function that calls MetaClient.ig() to fetch media details.
    // ─── ig_get_media ────────────────────────────────────────────
    server.tool(
      "ig_get_media",
      "Get details of a specific Instagram media post.",
      {
        media_id: z.string().describe("Media ID"),
        fields: z.string().optional().describe("Comma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)"),
      },
      async ({ media_id, fields }) => {
        try {
          const f = fields || "id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,like_count,comments_count";
          const { data, rateLimit } = await client.ig("GET", `/${media_id}`, { fields: f });
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Get media failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
  • The export function registerIgMediaTools() that registers 'ig_get_media' (and other media tools) on the McpServer instance.
    export function registerIgMediaTools(server: McpServer, client: MetaClient): void {
      // ─── ig_get_media_list ───────────────────────────────────────
      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 };
          }
        }
      );
    
      // ─── ig_get_media ────────────────────────────────────────────
      server.tool(
        "ig_get_media",
        "Get details of a specific Instagram media post.",
        {
          media_id: z.string().describe("Media ID"),
          fields: z.string().optional().describe("Comma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)"),
        },
        async ({ media_id, fields }) => {
          try {
            const f = fields || "id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,like_count,comments_count";
            const { data, rateLimit } = await client.ig("GET", `/${media_id}`, { fields: f });
            return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
          } catch (error) {
            return { content: [{ type: "text", text: `Get media failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
          }
        }
      );
  • Input schema for ig_get_media: media_id (required string) and fields (optional string) defined with Zod.
    {
      media_id: z.string().describe("Media ID"),
      fields: z.string().optional().describe("Comma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)"),
    },
  • src/index.ts:43-43 (registration)
    Where registerIgMediaTools is called to attach the tool to the live MCP server.
    registerIgMediaTools(server, client);
  • The MetaClient.ig() method that performs the actual Graph API request, called by the handler.
    async ig(
      method: string,
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      if (!this.config.instagramAccessToken) {
        throw new Error("INSTAGRAM_ACCESS_TOKEN is not configured.");
      }
      return this.request(IG_BASE, this.config.instagramAccessToken, method, path, params);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only says 'get details' without mentioning authentication, rate limits, or what happens if the media is not found. This is insufficient for an agent to understand side effects or prerequisites.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no fluff. It is front-loaded with the key action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description is minimally adequate for a simple retrieval tool. However, it lacks context about what fields are returned (though default fields are in the schema). For the number of siblings, it could benefit from more differentiation hints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's parameter descriptions; it merely restates the tool's purpose. Since the schema already explains parameters, this is adequate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get details of a specific Instagram media post' uses a specific verb (Get) and clear resource (details of a specific Instagram media post), effectively distinguishing it from siblings like ig_get_media_list (list) and ig_get_comment (comment).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For instance, it does not specify that this is for a single media post by ID while ig_get_media_list is for multiple posts. An agent would need to infer from the tool name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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