Skip to main content
Glama

ig_send_message

Send direct messages to Instagram users who have previously messaged you. Requires 'instagram_manage_messages' permission. Message window: 24 hours for standard accounts, 7 days for human agents.

Instructions

Send a DM to a user. Requires 'instagram_manage_messages' permission. Can only message users who have messaged you first (24hr window for standard, 7-day for human agent).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipient_idYesInstagram-scoped user ID of the recipient
messageYesMessage text to send

Implementation Reference

  • The 'ig_send_message' tool handler. Calls Meta API POST to /{igUserId}/messages with recipient_id and message text. Uses client.ig() to send via Instagram Graph API.
    // ─── ig_send_message ─────────────────────────────────────────
    server.tool(
      "ig_send_message",
      "Send a DM to a user. Requires 'instagram_manage_messages' permission. Can only message users who have messaged you first (24hr window for standard, 7-day for human agent).",
      {
        recipient_id: z.string().describe("Instagram-scoped user ID of the recipient"),
        message: z.string().describe("Message text to send"),
      },
      async ({ recipient_id, message }) => {
        try {
          const { data, rateLimit } = await client.ig("POST", `/${client.igUserId}/messages`, {
            recipient: JSON.stringify({ id: recipient_id }),
            message: JSON.stringify({ text: message }),
            messaging_type: "RESPONSE",
          });
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Send message failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Input schema for ig_send_message using Zod: recipient_id (string) and message (string).
    {
      recipient_id: z.string().describe("Instagram-scoped user ID of the recipient"),
      message: z.string().describe("Message text to send"),
    },
  • Tool registration via server.tool('ig_send_message', ...) inside registerIgMessagingTools().
    // ─── ig_send_message ─────────────────────────────────────────
    server.tool(
      "ig_send_message",
      "Send a DM to a user. Requires 'instagram_manage_messages' permission. Can only message users who have messaged you first (24hr window for standard, 7-day for human agent).",
      {
        recipient_id: z.string().describe("Instagram-scoped user ID of the recipient"),
        message: z.string().describe("Message text to send"),
      },
      async ({ recipient_id, message }) => {
        try {
          const { data, rateLimit } = await client.ig("POST", `/${client.igUserId}/messages`, {
            recipient: JSON.stringify({ id: recipient_id }),
            message: JSON.stringify({ text: message }),
            messaging_type: "RESPONSE",
          });
          return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Send message failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • src/index.ts:48-48 (registration)
    Registration call: registerIgMessagingTools(server, client) in the main entry point.
    registerIgMessagingTools(server, client);
  • MetaClient.ig() helper method that performs the HTTP request to the Instagram Graph API base URL (graph.facebook.com/v25.0) with the Instagram access token.
    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);
    }
Behavior4/5

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

With no annotations provided, the description carries full burden. It discloses permission requirements and the messaging window constraint, which are critical behavioral traits. It doesn't cover failure scenarios or rate limits, but the given info is substantial.

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?

Two short sentences: first states purpose, second lists requirements and constraints. No unnecessary words, perfectly front-loaded and efficient.

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

Completeness4/5

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

For a simple tool with 2 parameters and no output schema, the description covers the essential behavioral context: permission and window constraint. It lacks mention of response or error handling, but given the tool's simplicity, it is largely complete.

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?

The input schema already provides 100% coverage with descriptions for both parameters. The description adds the phrase 'Instagram-scoped user ID' for recipient_id, which is slightly more specific, but overall adds limited new meaning beyond the schema.

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 clearly states 'Send a DM to a user,' which is a specific verb+resource. Among many sibling tools, none other seem to send direct messages, so it is well-distinguished.

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

Usage Guidelines4/5

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

It mentions the required permission 'instagram_manage_messages' and the important constraint of the 24-hour window (or 7-day for human agent). This provides clear context for when the tool can be used, though it does not explicitly contrast with alternatives.

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