Skip to main content
Glama
iamnotagentleman

Localizable XStrings MCP Server

translate_tool

Translate strings in iOS/macOS Xcode String Catalogs to target languages, returning translated keys for localization workflows.

Instructions

MCP tool to translate strings to target language and return translated keys.

Args:
    file_path (str): Path to the .xcstrings file
    target_language (str): Target language code

Returns:
    str: Translation result with translated keys or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
target_languageYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `translate_tool` function is the main handler for the MCP tool. It is registered via the `@mcp.tool()` decorator and implements the translation logic: validates the xcstrings file and language, fetches base language strings, translates them using `translate_strings`, handles skipped items, and formats the output.
    @mcp.tool()
    def translate_tool(file_path: str, target_language: str) -> str:
        """
        MCP tool to translate strings to target language and return translated keys.
    
        Args:
            file_path (str): Path to the .xcstrings file
            target_language (str): Target language code
    
        Returns:
            str: Translation result with translated keys or error message
        """
        try:
            if not validate_xcstrings_file(file_path):
                return f"Error: Invalid file path or not an .xcstrings file: {file_path}"
    
            if not validate_language_code(target_language):
                return f"Error: Invalid language code: {target_language}"
    
            # Get base keys
            base_keys = get_base_language_strings(file_path)
            if not base_keys:
                return "Error: No base language keys found"
    
            # Translate
            translated, skipped = translate_strings(base_keys, target_language)
            if not translated and not skipped:
                return "Error: Translation failed or returned no results"
    
            result = []
            if translated:
                result.append(f"Translated {len(translated)} strings to {target_language}:")
                for key, value in translated.items():
                    result.append(f"{key}: {value}")
            
            if skipped:
                result.append(f"\nSkipped {len(skipped)} strings:")
                for key, reason in skipped.items():
                    result.append(f"{key}: {reason}")
            
            return "\n".join(result)
        except Exception as e:
            return format_error_message(e, "Translation failed")
  • The `@mcp.tool()` decorator on line 76 registers the `translate_tool` function as an MCP tool.
    @mcp.tool()
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 translates strings and returns translated keys or an error message, but lacks details on permissions, rate limits, side effects (e.g., whether it modifies the file), or error conditions. This is inadequate for a tool that likely involves file operations and translation processes.

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 appropriately sized and front-loaded, starting with the core purpose followed by args and returns. The sentences are efficient, though the 'Args' and 'Returns' sections could be integrated more seamlessly. Overall, it avoids unnecessary verbosity.

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

Completeness3/5

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

Given the tool has an output schema (which covers return values), the description doesn't need to explain returns in detail. However, with no annotations, 2 parameters, and operations involving file translation, the description is minimally adequate but lacks context on error handling, file format specifics, or integration with sibling tools, leaving room for improvement.

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

Parameters3/5

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

The description lists both parameters (file_path and target_language) with brief explanations, adding meaning beyond the schema which has 0% description coverage. However, it doesn't elaborate on format expectations (e.g., valid language codes, file path requirements), leaving gaps. With 2 parameters and low schema coverage, this provides basic but incomplete compensation.

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: 'translate strings to target language and return translated keys.' It specifies the verb (translate), resource (strings/keys), and output (translated keys). However, it doesn't explicitly differentiate from sibling tools like 'translate_key_tool' or 'get_keys_tool,' which appear related to translation/key operations.

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. It mentions the tool translates strings from a .xcstrings file, but doesn't explain when to choose this over 'translate_key_tool' or other siblings, nor does it specify prerequisites 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/iamnotagentleman/localizable-xcstrings-mcp'

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