Skip to main content
Glama
YCloud-Developers

YCloud WhatsApp API MCP Server

wa_template_edit

Edit WhatsApp message templates to update content, language, or structure for business communication through the YCloud API.

Instructions

Edit a template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
languageYes
bodyNo

Implementation Reference

  • src/tools.ts:99-101 (registration)
    Condition that maps original OpenAPI operation IDs containing 'template-edit-by-name-and-language' to the shortened tool name 'wa_template_edit'.
              operationId.includes('whatsapp_template-edit-by-name-and-language')) {
      operationId = 'wa_template_edit';
    } else if (operationId.includes('whatsapp_business_account')) {
  • Extracts Zod schemas for tool input parameters from the OpenAPI operation definition, handling path, query params, and request 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;
    }
  • The core handler function for wa_template_edit (and other tools), which constructs and sends an Axios HTTP request to the YCloud WhatsApp API endpoint matching the OpenAPI operation, 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)
          }]
        };
      }
    }
  • src/tools.ts:155-219 (registration)
    Registers the MCP tool using server.tool() with the name 'wa_template_edit', extracted description, generated paramsSchema, and the HTTP proxy handler.
    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++;
    }
  • src/index.ts:42-43 (registration)
    Calls registerYCloudTools which triggers the registration of wa_template_edit and other tools from the OpenAPI spec.
    const openApiSpec = await loadOpenApiSpec(openApiSpecPath);
    await registerYCloudTools(server, openApiSpec, apiBaseUrl, headers);
Behavior1/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. 'Edit a template' implies a mutation operation but reveals nothing about permissions, side effects, error handling, or response format. For a tool with 3 parameters and no output schema, this lack of transparency is critical and inadequate.

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 extremely concise with just three words, front-loading the core action. There is no wasted verbiage or redundancy. While under-specified, it is structurally efficient and earns full marks for brevity.

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

Completeness1/5

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

Given the tool's complexity (3 parameters, mutation operation, no annotations, no output schema, and multiple sibling tools), the description is severely incomplete. It fails to address key contextual elements like what 'editing' entails, how it differs from creation or deletion, what the parameters do, or what to expect upon execution. This inadequacy hinders effective tool use.

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

Parameters1/5

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

Schema description coverage is 0%, meaning none of the 3 parameters (name, language, body) are documented in the schema. The description adds no information about parameter meanings, formats, or constraints. For example, it doesn't clarify if 'name' refers to an existing template name, what 'language' codes are valid, or what 'body' should contain. This leaves parameters entirely unexplained.

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 'Edit a template' is a tautology that restates the tool name 'wa_template_edit' without adding meaningful context. It specifies the verb 'edit' and resource 'template' but lacks specificity about what aspects are editable or how this differs from sibling tools like wa_template_create or wa_template_update_profile. The purpose is clear at a basic level but fails to distinguish from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like wa_template_create, wa_template_delete, wa_template_get, and wa_template_list, there is no indication of prerequisites, appropriate contexts, or exclusions. This leaves the agent without direction on tool selection.

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