Skip to main content
Glama

localizationFindLongValues

Identify translation entries exceeding a specified character count in localization files to maintain consistency and readability across languages.

Instructions

查找超過特定字數的翻譯項目

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
thresholdYes
languageNo
limitNo

Implementation Reference

  • main.ts:456-475 (registration)
    Registers the MCP tool 'localizationFindLongValues' with input schema (filePath: string, threshold: number, optional language and limit) and delegates execution to LocalizationTool.findLongValues from tools/localizationTool.ts.
    server.tool("localizationFindLongValues",
        "查找超過特定字數的翻譯項目",
        {
            filePath: z.string(),
            threshold: z.number(),
            language: z.string().optional(),
            limit: z.number().optional()
        },
        async ({ filePath, threshold, language = '', limit = 50 }) => {
            try {
                const results = await LocalizationTool.findLongValues(filePath, threshold, language, limit);
                return {
                    content: [{ type: "text", text: JSON.stringify(results, null, 2) }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `搜尋超長文字失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }]
                };
            }
        }
  • Core handler implementation: Loads CSV data via cached getCSVData, iterates over entries and languages, collects those exceeding threshold length, sorts by descending length, limits results, returns LongValueResult.
    static async findLongValues(
      filePath: string, 
      threshold: number, 
      language: string = '', 
      limit: number = 50
    ): Promise<LongValueResult> {
      try {
        if (threshold <= 0) {
          throw new Error('字數閾值必須大於0');
        }
    
        const records = await this.getCSVData(filePath);
        
        // 用於存儲結果的陣列
        const longValues: Array<{
          key: string;
          language: string;
          value: string;
          length: number;
        }> = [];
    
        // 遍歷所有記錄
        for (const entry of records) {
          if (!entry.Key) continue;
    
          // 取得要檢查的語言欄位
          const languagesToCheck = language 
            ? [language] 
            : Object.keys(entry).filter(key => key !== 'Key');
    
          // 檢查每個語言欄位
          for (const lang of languagesToCheck) {
            if (entry[lang] && entry[lang].length > threshold) {
              longValues.push({
                key: entry.Key,
                language: lang,
                value: entry[lang],
                length: entry[lang].length
              });
            }
          }
        }
    
        // 依長度降序排序
        longValues.sort((a, b) => b.length - a.length);
    
        // 限制返回數量
        const limitedResults = longValues.slice(0, limit);
    
        return {
          totalResults: longValues.length,
          entries: limitedResults
        };
      } catch (error) {
        console.error(`搜尋長文字失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
        throw error;
      }
    }
  • TypeScript interface defining the output schema for the tool's results: total count and array of long value entries with key, language, value, and length.
    export interface LongValueResult {
      totalResults: number;
      entries: Array<{
        key: string;
        language: string;
        value: string;
        length: number;
      }>;
    }
  • Zod schema defining the input parameters for the tool: required filePath and threshold, optional language and limit.
    {
        filePath: z.string(),
        threshold: z.number(),
        language: z.string().optional(),
        limit: z.number().optional()
  • Cached CSV data loader used by the handler: reads and parses CSV file content, handles manual parsing fallback, manages 30s cache to avoid repeated reads.
    private static async getCSVData(filePath: string, force = false): Promise<LocalizationEntry[]> {
      const now = Date.now();
      const cached = this.cache.get(filePath);
    
      // 如果緩存有效且不需要強制重新讀取
      if (!force && cached && (now - cached.timestamp < this.CACHE_EXPIRY)) {
        return cached.data;
      }
    
      try {
        // 讀取並解析CSV檔案
        const content = await this.readCSVFileRaw(filePath);
        const records = this.parseCSVContent(content);
        
        // 更新緩存
        this.cache.set(filePath, {
          data: records,
          timestamp: now
        });
        
        return records;
      } catch (error) {
        console.error(`解析CSV檔案失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
        throw error;
      }
    }
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 the tool finds items but doesn't describe what 'finds' entails—whether it returns a list, modifies data, requires specific permissions, has rate limits, or what happens on errors. For a tool with 4 parameters and no annotation coverage, this is a significant gap in behavioral context.

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 unnecessary words. It's appropriately sized and front-loaded, with every part contributing to understanding the core function.

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 (4 parameters, 0% schema coverage, no annotations, no output schema), the description is incomplete. It doesn't explain parameters, return values, error conditions, or behavioral traits. For a tool that likely interacts with localization files and has multiple configuration options, this leaves too many gaps for effective agent use.

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 schema description coverage is 0%, meaning none of the 4 parameters have descriptions in the schema. The tool description doesn't explain any parameters—it doesn't mention 'filePath', 'threshold', 'language', or 'limit'. The agent must guess parameter meanings from their names alone, which is inadequate given the low schema coverage.

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 tool's purpose: '查找超過特定字數的翻譯項目' (Find translation items exceeding a specific character count). It specifies a verb ('查找' - find) and resource ('翻譯項目' - translation items) with a specific scope (exceeding character count). However, it doesn't explicitly differentiate from sibling tools like 'localizationFindMissing' or 'localizationSearch', which prevents a perfect score.

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. There's no mention of prerequisites, when-not-to-use scenarios, or comparisons to sibling tools like 'localizationFindMissing' (for missing translations) or 'localizationSearch' (for general searching). The agent must infer usage from the purpose alone.

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