Skip to main content
Glama
iamnotagentleman

Localizable XStrings MCP Server

get_keys_tool

Extract all localization keys from Xcode String Catalog (.xcstrings) files to manage iOS/macOS project translations.

Instructions

MCP tool to get all localization keys from xcstrings file.

Args:
    file_path (str): Path to the .xcstrings file

Returns:
    str: List of all keys or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_keys_tool' MCP tool. It is decorated with @mcp.tool() which handles both registration and execution. Validates the input file, extracts keys using the helper function, and formats the output as a string.
    @mcp.tool()
    def get_keys_tool(file_path: str) -> str:
        """
        MCP tool to get all localization keys from xcstrings file.
    
        Args:
            file_path (str): Path to the .xcstrings file
    
        Returns:
            str: List of all 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}"
    
            keys = extract_base_keys(file_path)
            return f"Found {len(keys)} keys:\n" + "\n".join(keys)
        except Exception as e:
            return format_error_message(e, "Failed to get keys")
  • Helper function that implements the core logic of extracting all localization keys from the .xcstrings JSON file by loading and parsing the 'strings' dictionary keys.
    def extract_base_keys(file_path: str) -> List[str]:
        """
        Extract all string keys from a Localizable.xcstrings file.
        
        Args:
            file_path (str): Path to the .xcstrings file
            
        Returns:
            List[str]: List of all string keys
            
        Raises:
            FileNotFoundError: If the file doesn't exist
            json.JSONDecodeError: If the file is not valid JSON
            KeyError: If the file doesn't have the expected structure
        """
        if not os.path.exists(file_path):
            raise FileNotFoundError(f"File not found: {file_path}")
        
        with open(file_path, 'r', encoding='utf-8') as f:
            data = json.load(f)
        
        if 'strings' not in data:
            return []
        
        return list(data['strings'].keys())
  • Utility helper used by the handler to validate that the input file path exists and ends with .xcstrings extension.
    def validate_xcstrings_file(file_path: str) -> bool:
        """
        Validate if a file exists and has the .xcstrings extension.
        
        Args:
            file_path (str): Path to check
            
        Returns:
            bool: True if valid, False otherwise
        """
        if not os.path.exists(file_path):
            return False
        
        if not file_path.lower().endswith('.xcstrings'):
            return False
        
        return True
  • Utility helper used by the handler to format error messages consistently.
    def format_error_message(error: Exception, context: str = "") -> str:
        """
        Format error messages consistently.
        
        Args:
            error (Exception): The exception to format
            context (str): Additional context for the error
            
        Returns:
            str: Formatted error message
        """
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 states the tool reads from a file and returns a list or error, but lacks details on permissions needed, error handling specifics, file format expectations, or performance characteristics. This is a significant gap for a tool with no annotation coverage.

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: the first sentence states the purpose clearly, followed by structured sections for args and returns. There's no wasted text, though the 'MCP tool' prefix is slightly redundant. Overall, it's efficient and well-organized.

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's moderate complexity (file reading with one parameter) and the presence of an output schema (which covers return values), the description is minimally complete. It explains the purpose and parameters but lacks behavioral details and usage guidelines. With no annotations, it should do more to be fully helpful, but it meets basic requirements.

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 adds minimal semantics beyond the input schema: it specifies that 'file_path' is a 'Path to the .xcstrings file', which clarifies the file type. However, with 0% schema description coverage and only one parameter, this is adequate but not comprehensive. The baseline for low coverage is compensated slightly, but not fully.

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: 'get all localization keys from xcstrings file' with a specific verb ('get') and resource ('localization keys from xcstrings file'). It distinguishes from siblings like 'get_languages_tool' (which gets languages) and 'get_base_strings_tool' (which gets base strings), but doesn't explicitly contrast them, so it's not a perfect 5.

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 doesn't mention when to choose this over other sibling tools like 'get_base_strings_tool' or 'get_languages_tool', nor does it specify prerequisites or exclusions. Usage is implied by the purpose, but no explicit context is given.

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