Skip to main content
Glama
YCloud-Developers

YCloud WhatsApp API MCP Server

wa_business_retrieve

Retrieve WhatsApp Business Account details by ID to access account information and manage business profiles.

Instructions

Retrieve a WABA

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • The execution handler for the 'wa_business_retrieve' tool. Dynamically constructs and sends an HTTP request to the corresponding YCloud WhatsApp Business Account API endpoint using axios, handles path/query/body params, and returns JSON response or error.
    async (args: Record<string, any>) => {
      try {
        // 解析URL中的路径参数
        let url = `${apiBaseUrl}${path}`;
        Object.keys(args).forEach(key => {
          if (path.includes(`{${key}}`)) {
            url = url.replace(`{${key}}`, encodeURIComponent(String(args[key])));
            delete args[key];
          }
        });
        
        // 提取请求体和查询参数
        const { body, ...queryParams } = args as Record<string, any>;
        
        // 设置请求选项
        const requestOptions: any = {
          url,
          method: method.toUpperCase(),
          headers: { 
            'Content-Type': 'application/json',
            ...headers
          },
          params: Object.keys(queryParams).length > 0 ? queryParams : undefined,
          data: body,
        };
        
        // 发送请求
        const response = await axios(requestOptions);
        return {
          content: [{ type: 'text' as const, text: JSON.stringify(response.data, null, 2) }]
        };
      } catch (error: unknown) {
        if (axios.isAxiosError(error) && error.response) {
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                error: true,
                status: error.response.status,
                message: error.response.data?.message || error.message,
                data: error.response.data
              }, null, 2)
            }]
          };
        }
        return {
          content: [{
            type: 'text' as const,
            text: JSON.stringify({
              error: true,
              message: error instanceof Error ? error.message : String(error)
            }, null, 2)
          }]
        };
      }
    }
  • Helper function to extract Zod parameter schemas from OpenAPI operation spec for input validation of the tool, including path, query params, and body.
    function extractParamsSchema(operation: any): any {
      const properties: Record<string, any> = {};
      const required: string[] = [];
    
      // 处理路径参数
      if (operation.parameters) {
        operation.parameters.forEach((param: any) => {
          if (param.in === 'path' || param.in === 'query') {
            let schema;
            switch (param.schema?.type) {
              case 'string':
                schema = z.string();
                break;
              case 'integer':
                schema = z.number().int();
                break;
              case 'number':
                schema = z.number();
                break;
              case 'boolean':
                schema = z.boolean();
                break;
              default:
                schema = z.any();
            }
            
            properties[param.name] = schema;
            if (param.required) {
              required.push(param.name);
            }
          }
        });
      }
    
      // 处理请求体
      if (operation.requestBody) {
        properties['body'] = z.any();
        required.push('body');
      }
    
      return properties;
    }
  • src/tools.ts:101-104 (registration)
    Naming logic that transforms OpenAPI operationId containing 'whatsapp_business_account' (e.g., 'whatsapp_business_account-retrieve') into the MCP tool name 'wa_business_retrieve' by extracting the action.
    } else if (operationId.includes('whatsapp_business_account')) {
      // 从operationId中提取动作部分(list, retrieve等)
      const action = operationId.split('-')[1] || '';
      operationId = `wa_business_${action}`;
  • src/tools.ts:155-219 (registration)
    The server.tool() registration call that registers the 'wa_business_retrieve' tool with its schema and shared handler, ensuring no duplicates.
    if (!registeredTools.has(toolName)) {
      server.tool(
        toolName,
        description,
        paramsSchema,
        async (args: Record<string, any>) => {
          try {
            // 解析URL中的路径参数
            let url = `${apiBaseUrl}${path}`;
            Object.keys(args).forEach(key => {
              if (path.includes(`{${key}}`)) {
                url = url.replace(`{${key}}`, encodeURIComponent(String(args[key])));
                delete args[key];
              }
            });
            
            // 提取请求体和查询参数
            const { body, ...queryParams } = args as Record<string, any>;
            
            // 设置请求选项
            const requestOptions: any = {
              url,
              method: method.toUpperCase(),
              headers: { 
                'Content-Type': 'application/json',
                ...headers
              },
              params: Object.keys(queryParams).length > 0 ? queryParams : undefined,
              data: body,
            };
            
            // 发送请求
            const response = await axios(requestOptions);
            return {
              content: [{ type: 'text' as const, text: JSON.stringify(response.data, null, 2) }]
            };
          } catch (error: unknown) {
            if (axios.isAxiosError(error) && error.response) {
              return {
                content: [{
                  type: 'text' as const,
                  text: JSON.stringify({
                    error: true,
                    status: error.response.status,
                    message: error.response.data?.message || error.message,
                    data: error.response.data
                  }, null, 2)
                }]
              };
            }
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify({
                  error: true,
                  message: error instanceof Error ? error.message : String(error)
                }, null, 2)
              }]
            };
          }
        }
      );
      registeredTools.add(toolName);
      registeredToolsCount++;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Retrieve' implies a read-only operation, but it doesn't specify if this requires authentication, has rate limits, returns structured data, or handles errors. For a tool with no annotations, this minimal description leaves critical behavioral traits unaddressed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words, making it front-loaded and easy to parse. However, it may be overly concise given the lack of context around 'WABA' and the parameter, slightly reducing clarity.

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 the tool's complexity (a retrieval operation with 1 parameter), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It doesn't explain what a WABA is, what the 'id' parameter entails, or what the tool returns, leaving significant gaps for an AI agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter ('id') with 0% description coverage, meaning the schema provides no semantic information. The description does not explain what 'id' represents (e.g., a WABA identifier, format, or source), failing to compensate for the low schema coverage. This leaves the parameter's meaning ambiguous.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Retrieve a WABA' states a verb ('Retrieve') and resource ('WABA'), but 'WABA' is an acronym that may not be universally understood without context. It doesn't distinguish this tool from sibling retrieval tools like 'wa_phone_retrieve' or 'wa_template_get', which follow similar naming patterns. The purpose is somewhat clear but lacks specificity about what a WABA represents.

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. With sibling tools like 'wa_business_list' (which likely lists multiple WABAs) and other retrieve tools, there's no indication of whether this is for fetching a single business by ID or how it differs from similar operations. The description offers no context for selection among retrieval tools.

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/YCloud-Developers/ycloud-whatsapp-mcp-server'

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