Skip to main content
Glama
iamnotagentleman

Localizable XStrings MCP Server

apply_tool

Translate iOS/macOS app strings by applying translations to Xcode String Catalogs (.xcstrings files) for target languages.

Instructions

MCP tool to translate and apply translations to xcstrings file.

Args:
    file_path (str): Path to the .xcstrings file
    target_language (str): Target language code
    app_description (str): Optional description of the app for better translation context

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
target_languageYes
app_descriptionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the MCP tool 'apply_tool'. It is decorated with @mcp.tool() for registration and implements the core logic: input validation, warning for existing translations, calling translate_and_apply helper, and formatting results.
    @mcp.tool()
    def apply_tool(file_path: str, target_language: str, app_description: str = "") -> str:
        """
        MCP tool to translate and apply translations to xcstrings file.
    
        Args:
            file_path (str): Path to the .xcstrings file
            target_language (str): Target language code
            app_description (str): Optional description of the app for better translation context
    
        Returns:
            str: Application 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}"
    
            # Check if target language already exists
            supported_languages = get_supported_languages(file_path)
            
            if target_language in supported_languages:
                warning_msg = f"Warning: {target_language} translations already exist in this file.\n"
                warning_msg += f"Using apply_tool will overwrite existing translations.\n"
                warning_msg += f"Consider using apply_missing_tool instead to only translate missing keys.\n\n"
                return warning_msg
            else:
                warning_msg = ""
    
            # Translate and apply in one step
            app_desc = app_description if app_description else None
            applied_translations, backup_path, summary, skipped_keys = translate_and_apply(file_path, target_language, app_description=app_desc)
            if not applied_translations and not skipped_keys:
                return "Error: Translation failed or returned no results"
    
            result = [
                f"Summary: {summary}",
                f"Backup created: {backup_path}",
            ]
            
            if applied_translations:
                result.append(f"\nTranslated strings ({len(applied_translations)}):\n")
                for key, value in applied_translations.items():
                    result.append(f"{key}: {value}")
            
            if skipped_keys:
                result.append(f"\n\nSkipped strings ({len(skipped_keys)}):\n")
                for key, reason in skipped_keys.items():
                    result.append(f"{key}: {reason}")
            
            return "\n".join(result)
    
        except Exception as e:
            return format_error_message(e, "Failed to apply translations")
Behavior2/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. It mentions translation and application to a file, implying a write operation, but doesn't cover critical aspects like permissions needed, whether the operation is destructive or reversible, rate limits, or error handling beyond a generic 'error message.' For a tool that modifies files, this is a significant gap in transparency.

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 well-structured with clear sections for purpose, arguments, and returns, making it easy to parse. It's concise, with each sentence serving a purpose, though it could be slightly more front-loaded by emphasizing the core action earlier. There's minimal waste, but it's not perfectly optimized for immediate understanding.

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 complexity of a file translation tool with 3 parameters and no annotations, the description is moderately complete. It explains the purpose and parameters, and an output schema exists, so return values don't need elaboration. However, it lacks details on behavioral traits like side effects or error conditions, making it adequate but with clear gaps for safe operation.

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 includes an 'Args' section that lists parameters with brief explanations, adding meaning beyond the input schema, which has 0% description coverage. It clarifies that 'app_description' is optional and for 'better translation context.' However, it doesn't detail formats (e.g., for 'target_language' codes) or provide examples, so it only partially compensates for the schema's lack of descriptions.

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 and apply translations to xcstrings file.' It specifies the verb ('translate and apply') and resource ('xcstrings file'), making the function understandable. However, it doesn't explicitly differentiate from sibling tools like 'translate_tool' or 'apply_missing_tool,' which might have overlapping functions, so it doesn't reach the highest 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. With sibling tools such as 'translate_tool' and 'apply_missing_tool,' there's no indication of context, prerequisites, or exclusions. This lack of differentiation leaves the agent without clear usage instructions.

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