Skip to main content
Glama
GalvinGao

SimpleLocalize MCP Server

by GalvinGao

update_translations

Update multiple translations simultaneously in SimpleLocalize to manage localization changes efficiently. Modify up to 100 translation entries with key, language, and text values in one operation.

Instructions

Update translations in bulk with a single request.

This endpoint allows you to update multiple translations at once. You can update up to 100 translations in a single request. Each translation must specify the key, language, and text. Namespace is optional.

Args: translations: List of dictionaries containing translation information with fields: - key (required): Translation key - language (required): Language code - text (required): Translation text (max 65535 chars) - namespace (optional): Namespace for the key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
translationsYes

Implementation Reference

  • main.py:94-144 (handler)
    The core handler function for the 'update_translations' tool. It is decorated with @mcp.tool() for registration. Validates input translations, cleans them, enforces limit of 100, makes a bulk PATCH request to SimpleLocalize API's /api/v2/translations/bulk endpoint, handles failures, and returns status message.
    @mcp.tool() async def update_translations(translations: List[dict]) -> str: """Update translations in bulk with a single request. This endpoint allows you to update multiple translations at once. You can update up to 100 translations in a single request. Each translation must specify the key, language, and text. Namespace is optional. Args: translations: List of dictionaries containing translation information with fields: - key (required): Translation key - language (required): Language code - text (required): Translation text (max 65535 chars) - namespace (optional): Namespace for the key """ # Validate and clean input cleaned_translations = [] for trans in translations: if not all(k in trans for k in ["key", "language", "text"]): raise ValueError("Each translation must have 'key', 'language', and 'text' fields") cleaned_trans = { "key": trans["key"], "language": trans["language"], "text": trans["text"] } # Only include namespace if it exists if "namespace" in trans: cleaned_trans["namespace"] = trans["namespace"] cleaned_translations.append(cleaned_trans) if len(cleaned_translations) > 100: raise ValueError("Maximum 100 translations allowed per request") try: result = await make_simplelocalize_request( "PATCH", "/api/v2/translations/bulk", {"translations": cleaned_translations} ) if "failures" in result.get("data", {}): failures = result["data"]["failures"] if failures: return f"Some translations failed to update: {failures}" return f"Successfully updated {len(cleaned_translations)} translations" except SimpleLocalizeError as e: return str(e)
  • main.py:19-43 (helper)
    Helper utility function called by the update_translations handler (and other tools) to perform authenticated HTTP requests (POST, PATCH, GET) to the SimpleLocalize API with error handling and timeout.
    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)}")
  • main.py:94-94 (registration)
    The @mcp.tool() decorator registers the update_translations function as an MCP tool.
    @mcp.tool()
  • The docstring provides the input schema description for the tool, detailing the structure of the 'translations' parameter as a list of dicts with required 'key', 'language', 'text' fields and optional 'namespace'.
    """Update translations in bulk with a single request. This endpoint allows you to update multiple translations at once. You can update up to 100 translations in a single request. Each translation must specify the key, language, and text. Namespace is optional. Args: translations: List of dictionaries containing translation information with fields: - key (required): Translation key - language (required): Language code - text (required): Translation text (max 65535 chars) - namespace (optional): Namespace for the key """

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