Skip to main content
Glama
GalvinGao

SimpleLocalize MCP Server

by GalvinGao

get_translations_for_keys

Fetch translations for specific keys from SimpleLocalize localization projects, optionally filtered by namespace, to retrieve all available language versions and review status.

Instructions

Get translations for specific translation keys.

This endpoint fetches translations for a list of specified keys, optionally filtered by namespace. Returns all available translations for each key across all languages in the project.

Args: keys: List of translation keys to fetch translations for (required) namespace: Optional namespace to filter the translations (if not provided, fetches from all namespaces)

Returns: List of dictionaries containing: - key (str): Translation key - namespace (str): Namespace for the key - translations (List[dict]): List of translations with fields: - language (str): Language code
- text (str): Translation text - reviewStatus (str): Review status (REVIEWED, NOT_REVIEWED) - lastModifiedAt (str): Last modification timestamp

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keysYes
namespaceNo

Implementation Reference

  • main.py:401-507 (handler)
    The handler function decorated with @mcp.tool(), which registers and implements the 'get_translations_for_keys' tool. It fetches translations for given keys (optionally namespaced) from the SimpleLocalize API, groups them by key/namespace, and returns structured results including all languages, texts, review status, and timestamps.
    @mcp.tool()
    async def get_translations_for_keys(keys: List[str], namespace: str = None) -> List[dict]:
        """Get translations for specific translation keys.
        
        This endpoint fetches translations for a list of specified keys, optionally filtered by namespace.
        Returns all available translations for each key across all languages in the project.
        
        Args:
            keys: List of translation keys to fetch translations for (required)
            namespace: Optional namespace to filter the translations (if not provided, fetches from all namespaces)
        
        Returns:
            List of dictionaries containing:
                - key (str): Translation key
                - namespace (str): Namespace for the key
                - translations (List[dict]): List of translations with fields:
                    - language (str): Language code  
                    - text (str): Translation text
                    - reviewStatus (str): Review status (REVIEWED, NOT_REVIEWED)
                    - lastModifiedAt (str): Last modification timestamp
        """
        if not keys:
            raise ValueError("At least one key is required")
        
        try:
            # Build query parameters for fetching all translations
            endpoint = "/api/v2/translations"
            params = []
            
            # If namespace is specified, add it to the query
            if namespace:
                params.append(f"namespace={namespace}")
            
            # Add size parameter to get more results (max 500 per API docs)
            params.append("size=500")
            
            # Build full endpoint URL with query parameters
            if params:
                endpoint += "?" + "&".join(params)
            
            result = await make_simplelocalize_request("GET", endpoint)
            
            data = result.get("data", [])
            
            # Create a set for faster lookup
            keys_set = set(keys)
            
            # Group translations by key and namespace
            keys_map = {}
            
            for item in data:
                item_key = item.get("key", "")
                item_namespace = item.get("namespace", "")
                language = item.get("language", "")
                text = item.get("text", "")
                review_status = item.get("reviewStatus", "")
                last_modified_at = item.get("lastModifiedAt", "")
                
                # Only include if the key is in our requested keys list
                if item_key in keys_set:
                    # If namespace filter is specified, only include matching items
                    if namespace is not None and item_namespace != namespace:
                        continue
                        
                    # Create a unique identifier for the key/namespace combination
                    key_id = f"{item_namespace}:{item_key}" if item_namespace else item_key
                    
                    if key_id not in keys_map:
                        keys_map[key_id] = {
                            "key": item_key,
                            "namespace": item_namespace,
                            "translations": []
                        }
                    
                    # Add translation if it has content
                    if text and language:
                        keys_map[key_id]["translations"].append({
                            "language": language,
                            "text": text,
                            "reviewStatus": review_status,
                            "lastModifiedAt": last_modified_at
                        })
            
            # Convert to list and ensure we have entries for all requested keys
            results = []
            for key in keys:
                # Check both with and without namespace
                key_id = f"{namespace}:{key}" if namespace else key
                key_id_no_namespace = key
                
                if key_id in keys_map:
                    results.append(keys_map[key_id])
                elif key_id_no_namespace in keys_map:
                    results.append(keys_map[key_id_no_namespace])
                else:
                    # Add empty entry for keys that don't have translations
                    results.append({
                        "key": key,
                        "namespace": namespace or "",
                        "translations": []
                    })
            
            return results
            
        except SimpleLocalizeError as e:
            return [{"error": str(e)}]
Behavior3/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 describes the return format in detail, including fields like 'reviewStatus' and 'lastModifiedAt', which adds useful context beyond basic fetching. However, it lacks information on error handling, rate limits, authentication needs, or whether this is a read-only operation, leaving some behavioral aspects unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by detailed parameter and return explanations. Every sentence adds value: the first states the action, the second clarifies scope, and the subsequent sections provide necessary details without redundancy. It efficiently covers key information in a compact format.

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

Completeness4/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 (2 parameters, no output schema, no annotations), the description is largely complete. It explains the purpose, parameters, and return structure thoroughly. However, it lacks details on error cases or operational constraints (e.g., rate limits), which would enhance completeness for a tool with no annotations.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must fully compensate. It clearly explains both parameters: 'keys' as a required list of translation keys to fetch, and 'namespace' as an optional filter. The description adds essential meaning beyond the bare schema, specifying that namespace filters translations and defaults to all namespaces if not provided.

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

Purpose5/5

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

The description clearly states the specific action ('fetches translations') and resource ('for a list of specified keys'), distinguishing it from siblings like 'create_translation_keys' (creation) or 'get_missing_translations' (missing items). It explicitly mentions the scope ('across all languages in the project'), making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: for fetching translations for specific keys, optionally filtered by namespace. It implies usage versus alternatives by specifying it returns 'all available translations' for given keys, but does not explicitly state when not to use it or name specific sibling alternatives for different scenarios.

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/GalvinGao/mcp-simplelocalize'

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