Skip to main content
Glama
translated

Lara Translate MCP Server

by translated

import_glossary_csv

Upload CSV content to import entries into a glossary. Supports unidirectional (table-uni) and multidirectional (table-multi) formats. Returns an import ID to monitor progress.

Instructions

Imports a CSV file into a glossary. Supports unidirectional and multidirectional formats. This is an async operation that returns an import job object containing an import_id. Poll with check_glossary_import_status using the returned import_id until the import is complete.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe glossary ID (format: gls_*, e.g., 'gls_xyz123')
csv_contentYesThe content of the CSV file to upload
content_typeYesThe format of the CSV file. 'csv/table-uni' for unidirectional, 'csv/table-multi' for multidirectionalcsv/table-uni
gzipNoWhether the CSV content is gzip compressed

Implementation Reference

  • The main handler function `importGlossaryCsv` that validates input via Zod schema, writes CSV content to a temp file, and calls `lara.glossaries.importCsv()`. Includes a 5MB size limit and cleans up the temp directory in a finally block.
    export async function importGlossaryCsv(args: any, lara: Translator) {
      const validatedArgs = importGlossaryCsvSchema.parse(args);
      const { id, csv_content, content_type, gzip } = validatedArgs;
    
      // File size limit: 5MB
      const MAX_CSV_SIZE = 5 * 1024 * 1024;
      if (Buffer.byteLength(csv_content, 'utf8') > MAX_CSV_SIZE) {
        throw new InvalidInputError("CSV file too large. Maximum allowed size is 5MB.");
      }
    
      const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'lara-csv-'));
      const tempFilePath = path.join(tempDir, 'import.csv');
    
      try {
        fs.writeFileSync(tempFilePath, csv_content, { mode: 0o600 });
    
        return await lara.glossaries.importCsv(id, tempFilePath, content_type, gzip);
      } finally {
        try {
          fs.rmSync(tempDir, { recursive: true, force: true });
        } catch (_) { /* best-effort cleanup */ }
      }
    }
  • Zod schema `importGlossaryCsvSchema` defining four input fields: id (glossary ID matching gls_* pattern), csv_content (the CSV file content string), content_type (enum csv/table-uni or csv/table-multi, defaults to csv/table-uni), and gzip (optional boolean).
    export const importGlossaryCsvSchema = z.object({
      id: z.string()
        .min(1)
        .max(255)
        .regex(/^gls_[a-zA-Z0-9_-]+$/, "Invalid glossary ID format")
        .describe("The glossary ID (format: gls_*, e.g., 'gls_xyz123')"),
      csv_content: z
        .string()
        .describe("The content of the CSV file to upload"),
      content_type: z
        .enum(["csv/table-uni", "csv/table-multi"])
        .default("csv/table-uni")
        .describe("The format of the CSV file. 'csv/table-uni' for unidirectional, 'csv/table-multi' for multidirectional"),
      gzip: z
        .boolean()
        .optional()
        .describe("Whether the CSV content is gzip compressed"),
    });
  • src/mcp/tools.ts:30-30 (registration)
    Import of `importGlossaryCsv` and `importGlossaryCsvSchema` from the tool module.
    import { importGlossaryCsv, importGlossaryCsvSchema } from "./tools/import_glossary_csv.js";
  • src/mcp/tools.ts:62-62 (registration)
    Registration of `import_glossary_csv` handler in the handlers record mapping tool names to handler functions.
    import_glossary_csv: importGlossaryCsv,
  • MCP tool definition including name, description, inputSchema (JSON schema from Zod), annotations (title, readOnlyHint false, destructiveHint false), and _meta invocation messages.
    {
      name: "import_glossary_csv",
      description:
        "Imports a CSV file into a glossary. Supports unidirectional and multidirectional formats. This is an async operation that returns an import job object containing an import_id. Poll with check_glossary_import_status using the returned import_id until the import is complete.",
      inputSchema: z.toJSONSchema(importGlossaryCsvSchema),
      annotations: {
        title: "Import glossary CSV",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false,
      },
      _meta: invocationMeta("Queuing glossary import…", "Glossary import queued"),
    },
Behavior4/5

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

Annotations already indicate readOnlyHint=false (mutation) and destructiveHint=false. The description adds key behavioral context: the operation is async and returns an import job object. It does not detail side effects on existing entries, but the polling guidance is valuable beyond annotations.

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 three sentences, each serving a purpose: stating the action, naming supported formats, and explaining async usage and polling. No extraneous text, front-loaded with the core purpose.

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 async nature, four parameters, and no output schema, the description adequately covers the import workflow and directs to a polling sibling. It could optionally mention expected CSV format details or size limits, but the current information suffices for correct usage.

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?

Schema description coverage is 100% with all four parameters well-documented in the input schema. The description adds no additional parameter-level details beyond what the schema already provides, meeting the baseline for high 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 the tool imports a CSV file into a glossary, specifying support for unidirectional and multidirectional formats. It distinguishes itself from related sibling tools like export_glossary, add_glossary_entry, and import_tmx by focusing on CSV import.

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 explicitly mentions the async nature and directs the agent to poll with check_glossary_import_status using the returned import_id. However, it does not compare to alternative import methods like import_tmx or add_glossary_entry, nor does it mention when not to use this tool.

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