Skip to main content
Glama
ExoCubeYT

OpenWA MCP Server

by ExoCubeYT

add_label_to_chat

Add a label to a specific WhatsApp chat using session ID, label ID, and chat ID to organize conversations.

Instructions

Apply a label to a specific WhatsApp chat

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID
labelIdYesLabel ID to apply
chatIdYesChat ID to label

Implementation Reference

  • The 'add_label_to_chat' tool handler: registers with MCP server, accepts sessionId/labelId/chatId, and calls POST /sessions/{sessionId}/labels/{labelId}/chats with the chatId in the body.
    server.registerTool(
      "add_label_to_chat",
      {
        description: "Apply a label to a specific WhatsApp chat",
        inputSchema: {
          sessionId: z.string().describe("Session ID"),
          labelId: z.string().describe("Label ID to apply"),
          chatId: z.string().describe("Chat ID to label"),
        },
      },
      async ({ sessionId, labelId, chatId }) => {
        const data = await openwaClient({
          method: "POST",
          path: `/sessions/${sessionId}/labels/${labelId}/chats`,
          body: { chatId },
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Input schema for add_label_to_chat: sessionId (string), labelId (string), chatId (string) — all required.
      inputSchema: {
        sessionId: z.string().describe("Session ID"),
        labelId: z.string().describe("Label ID to apply"),
        chatId: z.string().describe("Chat ID to label"),
      },
    },
  • src/index.ts:10-10 (registration)
    Registration import: registerLabelTools is imported from ./tools/labels.js and called on line 21.
    import { registerLabelTools } from "./tools/labels.js";
  • src/index.ts:21-21 (registration)
    Registration call: registerLabelTools(server) which registers all label tools including add_label_to_chat.
    registerLabelTools(server);
  • The openwaClient helper function used by the handler to make HTTP requests to the OpenWA API.
    const BASE_URL = process.env.OPENWA_BASE_URL || "http://localhost:2785/api";
    const API_KEY = process.env.OPENWA_API_KEY || "";
    
    interface RequestOptions {
      method: string;
      path: string;
      body?: Record<string, unknown>;
    }
    
    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 provided; description does not disclose behavioral traits such as idempotency, required permissions, or side effects (e.g., if label already applied).

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?

Single, concise sentence that is front-loaded and contains 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?

Description covers the basic action, but lacks details on behavior when label already exists, effect on chat, and output expectations. Without output schema, more context would be helpful.

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 coverage is 100% and description adds no additional meaning beyond parameter names and types. Baseline score of 3 is appropriate.

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 specifies the action ('Apply a label') and the target resource ('specific WhatsApp chat'). It distinguishes from siblings like 'create_label' and 'remove_label_from_chat'.

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 (e.g., remove_label_from_chat). No prerequisites or context 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