Skip to main content
Glama
wsapi-chat

WSAPI WhatsApp MCP Server

by wsapi-chat

whatsapp_get_group

Retrieve detailed information about a specific WhatsApp group using its unique Group ID to access group metadata, participants, and settings.

Instructions

Get information about a specific group.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupIdYesGroup ID (with @g.us)

Implementation Reference

  • The main ToolHandler implementation for 'whatsapp_get_group'. Defines the tool name, description, inline inputSchema, and the async handler function. The handler validates input using getGroupSchema and calls wsapiClient.get(`/groups/${groupId}`) to retrieve group information.
    export const getGroup: ToolHandler = {
      name: 'whatsapp_get_group',
      description: 'Get information about a specific group.',
      inputSchema: {
        type: 'object',
        properties: { groupId: { type: 'string', description: 'Group ID (with @g.us)' } },
        required: ['groupId'],
      },
      handler: async (args: any) => {
        const input = validateInput(getGroupSchema, args);
        const result = await wsapiClient.get(`/groups/${input.groupId}`);
        return { success: true, group: result };
      },
    };
  • Zod validation schema used in the handler for input validation. Defines required 'groupId' field using groupIdSchema (z.string().regex(/@g\.us$/)).
    export const getGroupSchema = z.object({
      groupId: groupIdSchema,
    });
  • src/server.ts:53-79 (registration)
    Registers all tools including groupTools (which contains whatsapp_get_group) by iterating over tool categories and adding each ToolHandler to the server's tools Map keyed by name.
    private setupToolHandlers(): void {
      logger.info('Setting up tool handlers');
    
      // Register all tool categories
      const toolCategories = [
        messagingTools,
        contactTools,
        groupTools,
        chatTools,
        sessionTools,
        instanceTools,
        accountTools,
      ];
    
      toolCategories.forEach(category => {
        Object.values(category).forEach(tool => {
          if (this.tools.has(tool.name)) {
            logger.warn(`Tool ${tool.name} already registered, skipping`);
            return;
          }
          this.tools.set(tool.name, tool);
          logger.debug(`Registered tool: ${tool.name}`);
        });
      });
    
      logger.info(`Registered ${this.tools.size} tools`);
    }
  • Base schema for groupId validation used by getGroupSchema. Ensures group ID ends with @g.us.
    const groupIdSchema = z.string().regex(/@g\.us$/);
  • Helper function used in the handler to validate input against the schema, throwing detailed errors if invalid.
    export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T {
      const result = schema.safeParse(data);
      if (!result.success) {
        const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`);
        throw new Error(`Validation failed: ${errors.join(', ')}`);
      }
      return result.data;
    }

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/wsapi-chat/wsapi-mcp'

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