Skip to main content
Glama
translated

Lara Translate MCP Server

by translated

import_tmx

Update a translation memory by importing a TMX file. Returns an import ID to track the asynchronous operation until completion.

Instructions

Imports a TMX file into a translation memory. This is an async operation that returns an import job object containing an import_id. Poll with check_import_status using the returned import_id until the import is complete.

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 main handler function for the import_tmx tool. Validates input args, enforces a 5MB limit on TMX content, writes the content to a temp file, calls lara.memories.importTmx, and cleans up the temp file afterwards.
    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;
      if (Buffer.byteLength(tmx_content, 'utf8') > MAX_TMX_SIZE) {
        throw new InvalidInputError("TMX file too large. Maximum allowed size is 5MB.");
      }
    
      const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'lara-tmx-'));
      const tempFilePath = path.join(tempDir, 'import.tmx');
    
      try {
        fs.writeFileSync(tempFilePath, tmx_content, { mode: 0o600 });
    
        return await lara.memories.importTmx(id, tempFilePath);
      } finally {
        try {
          fs.rmSync(tempDir, { recursive: true, force: true });
        } catch (_) { /* best-effort cleanup */ }
      }
    }
  • Zod schema defining the input parameters for import_tmx: id (memory ID, format mem_xyz123) and tmx_content (the TMX file content string).
    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:56-68 (registration)
    Registration of import_tmx in the handlers map, mapping the tool name 'import_tmx' to the importTmx handler function.
      import_tmx: importTmx,
      check_import_status: checkImportStatus,
      get_glossary: getGlossary,
      create_glossary: createGlossary,
      update_glossary: updateGlossary,
      delete_glossary: deleteGlossary,
      import_glossary_csv: importGlossaryCsv,
      check_glossary_import_status: checkGlossaryImportStatus,
      export_glossary: exportGlossary,
      get_glossary_counts: getGlossaryCounts,
      add_glossary_entry: addGlossaryEntry,
      delete_glossary_entry: deleteGlossaryEntry,
    };
  • Tool definition for import_tmx including name, description, inputSchema (generated from importTmxSchema via z.toJSONSchema), annotations (title, readOnlyHint, destructiveHint, openWorldHint), and invocation meta.
    {
      name: "import_tmx",
      description:
        "Imports a TMX file into a translation memory. This is an async operation that returns an import job object containing an import_id. Poll with check_import_status using the returned import_id until the import is complete.",
      inputSchema: z.toJSONSchema(importTmxSchema),
      annotations: {
        title: "Import TMX file",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false,
      },
      _meta: invocationMeta("Queuing TMX import…", "TMX import queued"),
    },
  • Helper narrate function case for import_tmx: returns a human-readable message when the tool completes, including the job ID if present.
    case "import_tmx":
      return `Queued TMX import${result?.id ? " (job " + result.id + ")" : ""}`;
Behavior4/5

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

The description discloses the async operation and return of an import job object, which goes beyond the annotations. Annotations indicate non-destructive mutation, which aligns with the description. No contradictions.

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 two sentences, front-loaded with the core purpose, and efficiently conveys the async behavior and polling requirement without extraneous content.

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?

Without an output schema, the description explains the return value (import job object with import_id) and references the polling tool. It sufficiently covers the workflow but omits potential error conditions or constraints.

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

Parameters3/5

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

The input schema has 100% coverage with descriptions for both parameters. The description does not add additional parameter information, so it meets the baseline for high schema coverage.

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 it imports a TMX file into a translation memory, distinguishing it from siblings like import_glossary_csv for glossaries and check_import_status for polling.

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 explains the async nature and instructs to poll with check_import_status, providing a clear usage flow. It does not explicitly state when not to use the tool, but the context of the sibling tools implies the primary use case.

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

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