Skip to main content
Glama

localizationSearch

Search for translation items containing specific text in localization files to find and manage multilingual content across projects.

Instructions

搜尋包含特定文字的翻譯項目

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes
searchTextYes
languageNo
limitNo

Implementation Reference

  • main.ts:323-343 (registration)
    Registration of the 'localizationSearch' MCP tool, including description, Zod input schema, and thin async handler that delegates to LocalizationTool.searchEntries and formats the response.
    server.tool("localizationSearch",
        "搜尋包含特定文字的翻譯項目",
        {
            filePath: z.string(),
            searchText: z.string(),
            language: z.string().optional(),
            limit: z.number().optional()
        },
        async ({ filePath, searchText, language = '', limit = 10 }) => {
            try {
                const results = await LocalizationTool.searchEntries(filePath, searchText, language, limit);
                return {
                    content: [{ type: "text", text: JSON.stringify(results, null, 2) }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `搜尋失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }]
                };
            }
        }
    );
  • Zod input schema defining parameters for the localizationSearch tool: filePath (string), searchText (string), optional language (string), optional limit (number).
    {
        filePath: z.string(),
        searchText: z.string(),
        language: z.string().optional(),
        limit: z.number().optional()
    },
  • Core helper function LocalizationTool.searchEntries that loads CSV data from file, performs case-insensitive text search in specified language or all languages (excluding Key), limits results, and returns SearchResult with total and entries.
    static async searchEntries(
      filePath: string,
      searchText: string,
      language: string = '',
      limit: number = 10
    ): Promise<SearchResult> {
      try {
        const records = await this.getCSVData(filePath);
        const searchTextLower = searchText.toLowerCase();
    
        // 搜尋邏輯
        let results: LocalizationEntry[] = [];
    
        if (language) {
          // 僅搜尋指定語言
          results = records.filter(entry =>
            entry[language] && entry[language].toLowerCase().includes(searchTextLower)
          );
        } else {
          // 搜尋所有欄位
          results = records.filter(entry =>
            Object.entries(entry).some(([key, value]) => 
              key !== 'Key' && value && value.toLowerCase().includes(searchTextLower)
            )
          );
        }
    
        // 限制返回數量
        const limitedResults = results.slice(0, limit);
    
        return {
          totalResults: results.length,
          entries: limitedResults
        };
      } catch (error) {
        console.error(`搜尋文字失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
        throw error;
      }
    }
  • Type definition for SearchResult returned by searchEntries.
    export interface SearchResult {
      totalResults: number;
      entries: LocalizationEntry[];
    }
  • Type definition for individual localization entry in CSV.
    export interface LocalizationEntry {
      Key: string;
      'zh-TW': string;
      'zh-CN': string;
      en: string;
      [key: string]: string; // 其他可能的語言欄位
    }
Behavior1/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 but provides minimal information. It doesn't indicate whether this is a read-only operation, what permissions are required, whether it searches across multiple files or languages by default, what format the results are in, or any performance characteristics. The single sentence offers almost no behavioral context beyond the basic action.

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 extremely concise - a single Chinese sentence that directly states the tool's function. There's no wasted language or unnecessary elaboration. However, this conciseness comes at the cost of completeness, as it omits important contextual information that would help an agent use the tool effectively.

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 a tool with 4 parameters (2 required), no annotations, no output schema, and 0% schema description coverage, the description is completely inadequate. It doesn't explain what the tool returns, how results are structured, what happens when no matches are found, or provide any context about the localization system being searched. For a search tool with multiple parameters and no structured documentation, this single-sentence description leaves critical gaps.

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?

With 0% schema description coverage for all 4 parameters, the description provides no information about any parameters. It mentions '特定文字' (specific text) which vaguely relates to 'searchText', but doesn't explain the filePath, language, or limit parameters at all. The description fails to compensate for the complete lack of schema documentation, leaving most parameters semantically undefined.

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

Purpose3/5

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

The description '搜尋包含特定文字的翻譯項目' (Search for translation items containing specific text) clearly states the tool's purpose as searching translation items. However, it doesn't specify what type of translation items (localization files, database entries, etc.) or distinguish it from sibling tools like 'localizationFindLongValues' or 'localizationFindMissing' that also search localization data. The purpose is understandable but lacks specificity about the resource being searched.

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. With multiple sibling localization tools (localizationFindLongValues, localizationFindMissing, localizationGetByKey, search_code), there's no indication of when this text-based search is preferred over other search methods or what context triggers its use. The description is purely functional without any usage context.

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