Skip to main content
Glama

send_message

Send text or media messages to Instagram or Facebook Messenger users using their platform APIs.

Instructions

Send a message to a user on Instagram or Facebook Messenger. Can send text or media (image, video, audio).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesPlatform to send message on
recipientIdYesThe user ID to send the message to
textNoText message content (optional if sending media)
mediaUrlNoURL of media to send (optional)
mediaTypeNoType of media being sent
isHumanAgentNoSet to true if message is from human agent (extends messaging window)

Implementation Reference

  • Main handler for the 'send_message' MCP tool. Parses arguments with Zod schema and delegates to platform-specific API functions.
    case 'send_message': {
      const params = SendMessageSchema.parse(args);
      if (params.platform === 'instagram') {
        result = await api.sendInstagramMessage({
          recipientId: params.recipientId,
          text: params.text,
          mediaUrl: params.mediaUrl,
          mediaType: params.mediaType,
          isHumanAgent: params.isHumanAgent
        });
      } else {
        result = await api.sendFacebookMessage({
          recipientId: params.recipientId,
          text: params.text,
          mediaUrl: params.mediaUrl,
          mediaType: params.mediaType,
          isHumanAgent: params.isHumanAgent
        });
      }
      break;
    }
  • Zod schema used for input validation in the send_message handler.
    const SendMessageSchema = z.object({
      platform: z.enum(['instagram', 'facebook']),
      recipientId: z.string(),
      text: z.string().optional(),
      mediaUrl: z.string().optional(),
      mediaType: z.enum(['image', 'video', 'audio']).optional(),
      isHumanAgent: z.boolean().optional()
    });
  • src/index.ts:104-119 (registration)
    Tool registration in the ListTools response, defining name, description, and JSON schema for inputs.
    {
      name: 'send_message',
      description: 'Send a message to a user on Instagram or Facebook Messenger. Can send text or media (image, video, audio).',
      inputSchema: {
        type: 'object',
        properties: {
          platform: { type: 'string', enum: ['instagram', 'facebook'], description: 'Platform to send message on' },
          recipientId: { type: 'string', description: 'The user ID to send the message to' },
          text: { type: 'string', description: 'Text message content (optional if sending media)' },
          mediaUrl: { type: 'string', description: 'URL of media to send (optional)' },
          mediaType: { type: 'string', enum: ['image', 'video', 'audio'], description: 'Type of media being sent' },
          isHumanAgent: { type: 'boolean', description: 'Set to true if message is from human agent (extends messaging window)' }
        },
        required: ['platform', 'recipientId']
      }
    },
  • Core implementation for sending messages (text or media) to Instagram via Facebook Graph API.
    export async function sendInstagramMessage(options: SendMessageOptions): Promise<any> {
      const { recipientId, text, mediaUrl, mediaType, isHumanAgent = false } = options;
    
      const payload: any = {
        recipient: { id: recipientId }
      };
    
      if (text) {
        payload.message = { text };
      } else if (mediaUrl && mediaType) {
        payload.message = {
          attachment: {
            type: mediaType,
            payload: {
              url: mediaUrl,
              is_reusable: true
            }
          }
        };
      }
    
      if (isHumanAgent) {
        payload.messaging_type = 'MESSAGE_TAG';
        payload.tag = 'HUMAN_AGENT';
      }
    
      return makeApiCall({
        method: 'POST',
        endpoint: `/me/messages`,
        data: payload
      });
    }
  • Core implementation for sending messages (text or media) to Facebook Messenger via Facebook Graph API.
    export async function sendFacebookMessage(options: SendMessageOptions): Promise<any> {
      const { recipientId, text, mediaUrl, mediaType, isHumanAgent = false } = options;
    
      const payload: any = {
        recipient: { id: recipientId },
        access_token: config.fbPageAccessToken
      };
    
      if (text) {
        payload.message = { text };
      } else if (mediaUrl && mediaType) {
        payload.message = {
          attachment: {
            type: mediaType,
            payload: {
              url: mediaUrl,
              is_reusable: true
            }
          }
        };
      }
    
      if (isHumanAgent) {
        payload.messaging_type = 'MESSAGE_TAG';
        payload.tag = 'HUMAN_AGENT';
      }
    
      return makeApiCall({
        method: 'POST',
        endpoint: `/${config.fbPageId}/messages`,
        data: payload
      });
    }
Behavior2/5

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

With no annotations, the description carries full burden. It states the tool sends messages but doesn't disclose behavioral traits like authentication requirements, rate limits, whether messages are reversible, delivery confirmation, or error handling. This is inadequate for a mutation tool.

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, efficient sentence that front-loads the core purpose and key capabilities. Every word earns its place with no redundancy or unnecessary details.

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

Completeness2/5

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

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks information about behavioral aspects like permissions, side effects, response format, and error conditions, which are critical for proper usage.

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 schema fully documents all 6 parameters. The description adds minimal value by mentioning platforms and media types, which are already covered by the schema's enum and descriptions. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('send a message'), target ('to a user'), platforms ('Instagram or Facebook Messenger'), and content types ('text or media'). It distinguishes from read-only sibling tools like get_conversation_messages, but doesn't explicitly differentiate from send_reaction or reply_to_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 on when to use this tool versus alternatives like send_reaction or reply_to_comment. It mentions platforms and content types but doesn't provide context about appropriate scenarios, prerequisites, or exclusions.

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

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