Skip to main content
Glama
GalvinGao

SimpleLocalize MCP Server

by GalvinGao

create_translation_keys

Generate multiple translation keys simultaneously for localization projects, supporting up to 100 keys per request with optional namespace and description fields.

Instructions

Create translation keys in bulk for a project.

This endpoint allows you to create multiple translation keys at once. You can create up to 100 translation keys in a single request. Each key must have a 'key' field, and optionally can include 'namespace' and 'description' fields.

Args: keys: List of dictionaries containing key information with fields: - key (required): Translation key (max 500 chars) - namespace (optional): Namespace for the key (max 128 chars) - description (optional): Description for translators (max 500 chars)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keysYes

Implementation Reference

  • main.py:44-93 (handler)
    The handler function decorated with @mcp.tool() that implements the create_translation_keys tool. It validates input, calls the SimpleLocalize API to create bulk translation keys, and handles responses and errors.
    @mcp.tool()
    async def create_translation_keys(keys: List[dict]) -> str:
        """Create translation keys in bulk for a project.
        
        This endpoint allows you to create multiple translation keys at once. You can create up to 100 translation keys in a single request.
        Each key must have a 'key' field, and optionally can include 'namespace' and 'description' fields.
        
        Args:
            keys: List of dictionaries containing key information with fields:
                - key (required): Translation key (max 500 chars)
                - namespace (optional): Namespace for the key (max 128 chars)
                - description (optional): Description for translators (max 500 chars)
        """
        # Validate and clean input
        cleaned_keys = []
        for key_info in keys:
            if not key_info.get("key"):
                raise ValueError("Each key must have a 'key' field")
                
            cleaned_key = {
                "key": key_info["key"]
            }
            
            # Only include optional fields if they exist
            if "namespace" in key_info:
                cleaned_key["namespace"] = key_info["namespace"]
            if "description" in key_info:
                cleaned_key["description"] = key_info["description"]
                
            cleaned_keys.append(cleaned_key)
    
        if len(cleaned_keys) > 100:
            raise ValueError("Maximum 100 keys allowed per request")
    
        try:
            result = await make_simplelocalize_request(
                "POST",
                "/api/v1/translation-keys/bulk",
                {"translationKeys": cleaned_keys}
            )
            
            if "failures" in result.get("data", {}):
                failures = result["data"]["failures"]
                if failures:
                    return f"Some keys failed to create: {failures}"
            
            return f"Successfully created {len(cleaned_keys)} translation keys"
        except SimpleLocalizeError as e:
            return str(e)
  • main.py:45-56 (schema)
    Type hints and docstring defining the input schema (List[dict] with key, optional namespace, description) and output (str response message).
    async def create_translation_keys(keys: List[dict]) -> str:
        """Create translation keys in bulk for a project.
        
        This endpoint allows you to create multiple translation keys at once. You can create up to 100 translation keys in a single request.
        Each key must have a 'key' field, and optionally can include 'namespace' and 'description' fields.
        
        Args:
            keys: List of dictionaries containing key information with fields:
                - key (required): Translation key (max 500 chars)
                - namespace (optional): Namespace for the key (max 128 chars)
                - description (optional): Description for translators (max 500 chars)
        """
  • main.py:44-44 (registration)
    The @mcp.tool() decorator registers the function as an MCP tool.
    @mcp.tool()
  • main.py:19-43 (helper)
    Helper function used by the tool to make authenticated HTTP requests to the SimpleLocalize API.
    async def make_simplelocalize_request(method: str, endpoint: str, json_data: dict | None = None) -> dict[str, Any]:
        """Make a request to the SimpleLocalize API with proper error handling."""
        headers = {
            "X-SimpleLocalize-Token": SIMPLELOCALIZE_API_KEY,
            "Content-Type": "application/json"
        }
        
        url = f"{SIMPLELOCALIZE_API_BASE}{endpoint}"
        
        async with httpx.AsyncClient() as client:
            try:
                if method.upper() == "POST":
                    response = await client.post(url, headers=headers, json=json_data, timeout=30.0)
                elif method.upper() == "PATCH":
                    response = await client.patch(url, headers=headers, json=json_data, timeout=30.0)
                elif method.upper() == "GET":
                    response = await client.get(url, headers=headers, timeout=30.0)
                else:
                    raise ValueError(f"Unsupported HTTP method: {method}")
                
                response.raise_for_status()
                return response.json()
            except httpx.HTTPError as e:
                raise SimpleLocalizeError(f"SimpleLocalize API error: {str(e)}")
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and adds valuable behavioral context: it discloses the bulk nature (up to 100 keys per request), required/optional fields, and character limits. However, it doesn't mention authentication needs, rate limits, or error handling.

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 a clear opening sentence, followed by details in bullet points. It's appropriately sized, though the 'Args:' section could be integrated more seamlessly. Every sentence adds value without redundancy.

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?

For a mutation tool with no annotations and no output schema, the description covers key aspects like parameters and constraints, but lacks information on return values, error conditions, or project context. Given the complexity, it's adequate but has clear gaps in completeness.

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 fully compensates by detailing the 'keys' parameter structure: it explains it's a list of dictionaries with required 'key' field and optional 'namespace' and 'description' fields, including character limits. This adds essential meaning beyond the bare schema.

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 ('create translation keys in bulk') and resource ('for a project'), distinguishing it from siblings like 'update_translations' or 'get_translations_for_keys'. The verb 'create' and scope 'bulk' provide precise purpose.

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

Usage Guidelines3/5

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

The description implies usage for bulk creation of translation keys, but does not explicitly state when to use this tool versus alternatives like 'duplicate_translation' or 'update_translations'. No exclusions or prerequisites are mentioned, leaving usage context somewhat vague.

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