Skip to main content
Glama

ig_get_messages

Retrieve direct messages from a specific Instagram conversation using conversation ID, with options for pagination and message limits.

Instructions

Get messages in a specific DM conversation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idYesConversation ID
limitNoNumber of messages
afterNoPagination cursor

Implementation Reference

  • Implementation of the ig_get_messages tool handler, including schema validation and the API call logic.
    server.tool(
      "ig_get_messages",
      "Get messages in a specific DM conversation.",
      {
        conversation_id: z.string().describe("Conversation ID"),
        limit: z.number().optional().describe("Number of messages"),
        after: z.string().optional().describe("Pagination cursor"),
      },
      async ({ conversation_id, limit, after }) => {
        try {
          const params: Record<string, unknown> = {
            fields: "id,message,from,created_time,attachments",
          };
          if (limit) params.limit = limit;
          if (after) params.after = after;
          const { data, rateLimit } = await client.ig("GET", `/${conversation_id}/messages`, params);
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Get messages 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