Skip to main content
Glama
translated

Lara Translate MCP Server

by translated

import_tmx

Upload TMX file content to update a translation memory in Lara Translate, enabling reuse of existing translations for consistent localization.

Instructions

Imports a TMX file into a translation memory in your Lara Translate account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the memory to update. Format: mem_xyz123.
tmx_contentYesThe content of the tmx file to upload.

Implementation Reference

  • The async importTmx function that parses arguments with the schema, checks TMX size limit, creates temp directory and file, imports via lara.memories.importTmx, and cleans up the temp file.
    export async function importTmx(args: any, lara: Translator) { const validatedArgs = importTmxSchema.parse(args); const { id, tmx_content } = validatedArgs; // File size limit: 5MB const MAX_TMX_SIZE = 5 * 1024 * 1024; // 5MB if (Buffer.byteLength(tmx_content, 'utf8') > MAX_TMX_SIZE) { throw new Error("TMX file too large. Maximum allowed size is 5MB."); } const tempDir = path.join(os.tmpdir(), 'lara-tmx-imports'); if (!fs.existsSync(tempDir)) { fs.mkdirSync(tempDir, { recursive: true }); } const tempFilePath = path.join(tempDir, `tmx-${Date.now()}-${Math.random().toString(36).slice(2)}.tmx`); try { fs.writeFileSync(tempFilePath, tmx_content); return await lara.memories.importTmx(id, tempFilePath); } catch (err) { throw err; } finally { if (fs.existsSync(tempFilePath)) { fs.unlinkSync(tempFilePath); } } }
  • Zod input validation schema for the import_tmx tool, defining 'id' (string, memory ID) and 'tmx_content' (string, TMX file content).
    export const importTmxSchema = z.object({ id: z .string() .describe( "The ID of the memory to update. Format: mem_xyz123." ), tmx_content: z .string() .describe( "The content of the tmx file to upload." ), });
  • src/mcp/tools.ts:36-45 (registration)
    Registration of tool handlers in the 'handlers' map, mapping 'import_tmx' to the importTmx function for dispatch in CallTool.
    const handlers: Record<string, Handler> = { translate: translateHandler, create_memory: createMemory, delete_memory: deleteMemory, update_memory: updateMemory, add_translation: addTranslation, delete_translation: deleteTranslation, import_tmx: importTmx, check_import_status: checkImportStatus, };
  • Registration of the 'import_tmx' tool metadata (name, description, inputSchema) in the ListTools response.
    { name: "import_tmx", description: "Imports a TMX file into a translation memory in your Lara Translate account.", inputSchema: z.toJSONSchema(importTmxSchema), },

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/translated/lara-mcp'

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