Skip to main content
Glama
ExoCubeYT

OpenWA MCP Server

by ExoCubeYT

create_label

Create a new label or tag to organize your WhatsApp chats by session, name, and color.

Instructions

Create a new label/tag for organizing WhatsApp chats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID
nameYesLabel name
colorNoLabel color hex code

Implementation Reference

  • The tool is registered with the MCP server under the name 'create_label'.
    server.registerTool(
      "create_label",
      {
        description: "Create a new label/tag for organizing WhatsApp chats",
        inputSchema: {
          sessionId: z.string().describe("Session ID"),
          name: z.string().describe("Label name"),
          color: z.string().optional().describe("Label color hex code"),
        },
      },
      async ({ sessionId, name, color }) => {
        const data = await openwaClient({
          method: "POST",
          path: `/sessions/${sessionId}/labels`,
          body: { name, color },
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The handler function that executes the 'create_label' tool logic: sends a POST request to the OpenWA API to create a new label with sessionId, name, and optional color.
      async ({ sessionId, name, color }) => {
        const data = await openwaClient({
          method: "POST",
          path: `/sessions/${sessionId}/labels`,
          body: { name, color },
        });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Input schema for 'create_label' requiring sessionId (string), name (string), and optional color (hex string).
    {
      description: "Create a new label/tag for organizing WhatsApp chats",
      inputSchema: {
        sessionId: z.string().describe("Session ID"),
        name: z.string().describe("Label name"),
        color: z.string().optional().describe("Label color hex code"),
      },
    },
  • Helper function used by the handler to make HTTP requests to the OpenWA API backend.
    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;
      }
    }
  • src/index.ts:10-21 (registration)
    The label tool registration function is imported and invoked in the main entry point.
    import { registerLabelTools } from "./tools/labels.js";
    import { registerMediaTools } from "./tools/media.js";
    
    const server = new McpServer({ name: "openwa-mcp", version: "1.0.0" });
    
    registerSessionTools(server);
    registerMessageTools(server);
    registerBulkTools(server);
    registerGroupTools(server);
    registerContactTools(server);
    registerWebhookTools(server);
    registerLabelTools(server);
Behavior2/5

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

With no annotations, the description carries full burden but only states 'Create a new label'. It does not disclose behavioral traits like uniqueness constraints, permissions, or side effects.

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, front-loaded sentence with no unnecessary words. It is efficient and easy to parse.

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?

The description is adequate for a simple create tool, but it omits return value information (e.g., what the tool returns upon success). Given no output schema, this gap reduces completeness.

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%, so the schema already documents all parameters. The description adds no additional meaning beyond listing 'name', 'color', 'sessionId'.

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 action 'Create' and the resource 'label/tag' with context 'for organizing WhatsApp chats'. It effectively distinguishes from sibling tools like delete_label or get_labels.

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 is provided on when to use this tool versus alternatives (e.g., add_label_to_chat). There is no mention of context 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/ExoCubeYT/openwa-mcp'

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