Skip to main content
Glama

localizationUpdate

Update translation content in localization files by modifying specific keys and language values to maintain accurate multilingual resources.

Instructions

更新現有翻譯項目的內容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
keyYes
updateDataYes

Implementation Reference

  • Core handler method that loads the CSV data, finds the entry by key, applies partial updates to language fields, writes back to file, and updates cache. Handles errors and validation.
    static async updateEntry(
      filePath: string,
      key: string,
      updateData: Partial<Omit<LocalizationEntry, 'Key'>>
    ): Promise<string> {
      try {
        const records = await this.getCSVData(filePath);
    
        // 找到要更新的項目索引
        const index = records.findIndex(entry => entry.Key === key);
        if (index === -1) {
          return `錯誤: Key "${key}" 不存在`;
        }
    
        // 更新欄位 (確保過濾掉任何undefined值)
        const validUpdateData = Object.fromEntries(
          Object.entries(updateData).filter(([_, value]) => value !== undefined)
        ) as Record<string, string>;
        
        records[index] = {
          ...records[index],
          ...validUpdateData
        };
    
        // 寫回檔案並更新緩存
        await this.writeCSVData(filePath, records);
    
        return `成功更新Key "${key}"`;
      } catch (error) {
        console.error(`更新翻譯項失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
        throw error;
      }
    }
  • main.ts:372-395 (registration)
    MCP server tool registration for 'localizationUpdate', including Zod input schema validation and wrapper handler that delegates to LocalizationTool.updateEntry.
    server.tool("localizationUpdate",
        "更新現有翻譯項目的內容",
        {
            filePath: z.string(),
            key: z.string(),
            updateData: z.object({
                "zh-TW": z.string().optional(),
                "zh-CN": z.string().optional(),
                en: z.string().optional()
            }).passthrough()
        },
        async ({ filePath, key, updateData }) => {
            try {
                const result = await LocalizationTool.updateEntry(filePath, key, updateData as Partial<Omit<LocalizationEntry, "Key">>);
                return {
                    content: [{ type: "text", text: result }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `更新失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }]
                };
            }
        }
    );
  • TypeScript interface defining the structure of a localization entry used for type safety in update operations and data handling.
    export interface LocalizationEntry {
      Key: string;
      'zh-TW': string;
      'zh-CN': string;
      en: string;
      [key: string]: string; // 其他可能的語言欄位
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's an update operation but doesn't mention permissions needed, whether changes are reversible, potential side effects, or response format. For a mutation tool with zero annotation coverage, this is insufficient.

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, efficient sentence in Chinese that directly states the tool's purpose without any unnecessary words. It's appropriately sized 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?

For a mutation tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain parameter meanings, behavioral traits, or what to expect upon execution, leaving significant gaps for an AI agent.

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?

Schema description coverage is 0%, so parameters are undocumented in the schema. The description doesn't explain what 'filePath', 'key', or 'updateData' represent or how they should be used. It fails to compensate for the lack of schema documentation.

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 '更新現有翻譯項目的內容' clearly states the action (update) and target (existing translation items). It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like 'localizationAdd' or 'localizationDelete'.

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?

The description provides no guidance on when to use this tool versus alternatives like 'localizationAdd' (for new items) or 'localizationDelete' (for removal). It doesn't mention prerequisites, context, or exclusions for usage.

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/GonTwVn/GonMCPtool'

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