get_keys_tool
Extract all localization keys from Xcode String Catalog (.xcstrings) files to support iOS/macOS project translation workflows and localization management.
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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- Handler function for the 'get_keys_tool' MCP tool. It validates the xcstrings file, extracts base keys using extract_base_keys, and returns a formatted list of keys or an error message. Registered via @mcp.tool() decorator.@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")