Skip to main content
Glama
ExoCubeYT

OpenWA MCP Server

by ExoCubeYT

get_contacts

Retrieve all contacts saved in a WhatsApp session by providing the session ID.

Instructions

List all contacts stored in the WhatsApp session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID

Implementation Reference

  • The handler function for 'get_contacts' — makes a GET request to /sessions/{sessionId}/contacts and returns the result as text content.
    async ({ sessionId }) => {
      const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/contacts` });
      return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
    }
  • Input schema for 'get_contacts' — expects a single 'sessionId' parameter of type string.
    {
      description: "List all contacts stored in the WhatsApp session",
      inputSchema: {
        sessionId: z.string().describe("Session ID"),
      },
  • Registration of the 'get_contacts' tool via server.registerTool in the registerContactTools function.
    server.registerTool(
      "get_contacts",
      {
        description: "List all contacts stored in the WhatsApp session",
        inputSchema: {
          sessionId: z.string().describe("Session ID"),
        },
      },
      async ({ sessionId }) => {
        const data = await openwaClient({ method: "GET", path: `/sessions/${sessionId}/contacts` });
        return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
      }
    );
  • src/index.ts:19-19 (registration)
    Where registerContactTools is called to register all contact-related tools, including 'get_contacts', on the McpServer.
    registerContactTools(server);
  • The openwaClient helper function used by the handler to make HTTP requests to the OpenWA API.
    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, and the description only says 'List all contacts', which implies a read operation. However, it does not disclose any behavioral traits such as whether it returns cached data or has 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 clear sentence with no unnecessary words. It efficiently conveys the tool's purpose.

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

Completeness5/5

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

For a simple tool with one required parameter and no output schema, the description is complete. It tells the agent what the tool does and what input is needed.

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 schema has 100% coverage with a description for 'sessionId', but the description adds no additional meaning beyond the schema. The format or source of the session ID is not explained.

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 'List all contacts', specifying the verb and resource. It distinguishes itself from the sibling 'get_contact' which implies fetching a single contact.

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 implicitly suggests using this tool to list all contacts, but it does not explicitly mention when not to use it or alternatives like 'get_contact' for a single contact.

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