Skip to main content
Glama
ExoCubeYT

OpenWA MCP Server

by ExoCubeYT

block_contact

Blocks a WhatsApp contact using session ID and contact ID to prevent further messages.

Instructions

Block a WhatsApp contact

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID
contactIdYesContact ID to block

Implementation Reference

  • The handler function for the 'block_contact' tool. It accepts sessionId and contactId inputs, makes a POST request to the OpenWA API endpoint /sessions/{sessionId}/contacts/{contactId}/block, and returns the result as text content.
    server.registerTool(
      "block_contact",
      {
        description: "Block a WhatsApp contact",
        inputSchema: {
          sessionId: z.string().describe("Session ID"),
          contactId: z.string().describe("Contact ID to block"),
        },
      },
      async ({ sessionId, contactId }) => {
        const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/contacts/${contactId}/block` });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Input schema for the 'block_contact' tool using Zod validation. Requires sessionId (string) and contactId (string, the contact to block).
    {
      description: "Block a WhatsApp contact",
      inputSchema: {
        sessionId: z.string().describe("Session ID"),
        contactId: z.string().describe("Contact ID to block"),
      },
  • The 'block_contact' tool is registered via server.registerTool() inside the registerContactTools function (line 5). The registration is triggered from src/index.ts line 19 where registerContactTools(server) is called.
    server.registerTool(
      "block_contact",
      {
        description: "Block a WhatsApp contact",
        inputSchema: {
          sessionId: z.string().describe("Session ID"),
          contactId: z.string().describe("Contact ID to block"),
        },
      },
      async ({ sessionId, contactId }) => {
        const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/contacts/${contactId}/block` });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The openwaClient helper function that executes the actual HTTP request. It takes a method, path, and optional body, sends a fetch request to the OpenWA API base URL with the X-API-Key header, and returns the parsed JSON response.
    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. The description does not disclose side effects (e.g., whether blocking destroys chat history), reversibility, or authentication needs. Only says 'Block'.

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 sentence with no extraneous words. Highly concise and front-loaded.

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?

Given no annotations or output schema, the description omits essential context for a destructive action. Does not cover behavior, prerequisites, or results.

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%, but parameter descriptions are minimal ('Session ID', 'Contact ID to block'). No additional meaning beyond the schema.

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 'Block a WhatsApp contact' clearly states the action and target resource. It is distinct from sibling tools like 'unblock_contact'.

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., removing a contact from a group). No prerequisites mentioned, such as requiring an active session.

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