Skip to main content
Glama
ExoCubeYT

OpenWA MCP Server

by ExoCubeYT

send_file

Send a file to a WhatsApp chat by providing a public URL, filename, and optional caption.

Instructions

Send a file/document to a WhatsApp chat by providing a publicly accessible URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID to send from
chatIdYesTarget chat ID
urlYesPublic URL of the file
filenameYesFilename to display in the chat
captionNoOptional caption for the file

Implementation Reference

  • The handler function that executes the 'send_file' tool logic. It extracts sessionId, chatId, url, filename, and optional caption from the input, then makes a POST request to the OpenWA API endpoint /sessions/{sessionId}/messages/send-file with the body containing chatId, url, filename, and caption. It returns the JSON response as text content.
    server.registerTool(
      "send_file",
      {
        description: "Send a file/document to a WhatsApp chat by providing a publicly accessible URL",
        inputSchema: {
          sessionId: z.string().describe("Session ID to send from"),
          chatId: z.string().describe("Target chat ID"),
          url: z.string().describe("Public URL of the file"),
          filename: z.string().describe("Filename to display in the chat"),
          caption: z.string().optional().describe("Optional caption for the file"),
        },
      },
      async ({ sessionId, chatId, url, filename, caption }) => {
        const data = await openwaClient({
          method: "POST",
          path: `/sessions/${sessionId}/messages/send-file`,
          body: { chatId, url, filename, caption },
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Input schema for the 'send_file' tool: sessionId (string), chatId (string), url (string, public URL of the file), filename (string, filename to display in the chat), and optional caption (string).
    {
      description: "Send a file/document to a WhatsApp chat by providing a publicly accessible URL",
      inputSchema: {
        sessionId: z.string().describe("Session ID to send from"),
        chatId: z.string().describe("Target chat ID"),
        url: z.string().describe("Public URL of the file"),
        filename: z.string().describe("Filename to display in the chat"),
        caption: z.string().optional().describe("Optional caption for the file"),
      },
  • The 'send_file' tool is registered via server.registerTool('send_file', ...) inside the registerMessageTools function in src/tools/messages.ts. This function is called from src/index.ts (line 16) during server initialization.
    server.registerTool(
      "send_file",
      {
        description: "Send a file/document to a WhatsApp chat by providing a publicly accessible URL",
        inputSchema: {
          sessionId: z.string().describe("Session ID to send from"),
          chatId: z.string().describe("Target chat ID"),
          url: z.string().describe("Public URL of the file"),
          filename: z.string().describe("Filename to display in the chat"),
          caption: z.string().optional().describe("Optional caption for the file"),
        },
      },
      async ({ sessionId, chatId, url, filename, caption }) => {
        const data = await openwaClient({
          method: "POST",
          path: `/sessions/${sessionId}/messages/send-file`,
          body: { chatId, url, filename, caption },
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The openwaClient helper function is the underlying HTTP client used by the send_file handler. It takes method, path, and body parameters, constructs a URL using the OPENWA_BASE_URL env variable (default http://localhost:2785/api), includes the X-API-Key header, and performs the fetch request. The handler calls it with method: 'POST', path: `/sessions/${sessionId}/messages/send-file`, and body containing chatId, url, filename, caption.
    export async function openwaClient<T = unknown>(opts: RequestOptions): Promise<T> {
      const url = `${BASE_URL}${opts.path}`;
    
      const headers: Record<string, string> = {
        "Content-Type": "application/json",
        "X-API-Key": API_KEY,
      };
    
      const res = await fetch(url, {
        method: opts.method,
        headers,
        body: opts.body ? JSON.stringify(opts.body) : undefined,
      });
    
      const text = await res.text();
    
      if (!res.ok) {
        throw new Error(`OpenWA API ${res.status}: ${text}`);
      }
    
      try {
        return JSON.parse(text) as T;
      } catch {
        return text as T;
      }
    }
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It only states the action and the need for a public URL, but omits details like required session state, file size limits, error handling, or whether the tool is destructive. This is minimal disclosure 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?

A single, well-structured sentence that is front-loaded with the main purpose. No unnecessary words.

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?

For a simple tool with 5 parameters and no output schema, the description is adequate but lacks guidance on when to use this over other send tools. It does not explain return values or failure conditions, and the absence of annotations means the agent must infer behavior from the description alone.

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 has 100% parameter descriptions, so the baseline is 3. The description adds slight context for the url parameter ('publicly accessible'), but does not enhance meaning for other parameters like sessionId, chatId, filename, or caption 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 the verb 'Send', the resource 'file/document', and the method 'by providing a publicly accessible URL'. It effectively distinguishes from sibling tools like send_image, send_video, and send_audio which are for specific media types.

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

Usage Guidelines3/5

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

The description implies the tool should be used when the file is not covered by more specific media senders, but it does not explicitly state when to use send_file versus send_image, send_video, or send_audio. No alternatives or exclusions are provided.

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/ExoCubeYT/openwa-mcp'

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