add_glossary_entry
Add or replace an entry in a Lara Translate glossary. Supports both monodirectional (first term as source) and multidirectional entries.
Instructions
Adds or replaces an entry in a glossary in your Lara Translate account. Supports both monodirectional and multidirectional glossaries.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The glossary ID (format: gls_*, e.g., 'gls_xyz123') | |
| terms | Yes | Array of terms with language and value. For monodirectional glossaries, the first term is the source and the rest are targets. For multidirectional glossaries, all terms are treated equally. Use the list_languages tool to get supported language codes. | |
| guid | No | Optional entry identifier. Use this for multidirectional glossaries or to update a specific entry. |
Implementation Reference
- The handler function that adds or replaces a glossary entry. Parses input with Zod schema, then calls lara.glossaries.addOrReplaceEntry(id, terms, guid) or lara.glossaries.addOrReplaceEntry(id, terms) depending on whether an optional guid is provided.
export async function addGlossaryEntry(args: unknown, lara: Translator) { const { id, terms, guid } = addGlossaryEntrySchema.parse(args); if (guid !== undefined) { return await lara.glossaries.addOrReplaceEntry(id, terms, guid); } return await lara.glossaries.addOrReplaceEntry(id, terms); } - Zod schema defining the input validation for add_glossary_entry. Validates id (format gls_*), terms (array of {language, value}), and optional guid.
export const addGlossaryEntrySchema = 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')"), terms: z.array(z.object({ language: z.string().describe("The language code of the term. Use the list_languages tool to get supported languages."), value: z.string().describe("The term value in the specified language"), })).min(1).describe( "Array of terms with language and value. For monodirectional glossaries, the first term is the source and the rest are targets. For multidirectional glossaries, all terms are treated equally. Use the list_languages tool to get supported language codes." ), guid: z.string().optional().describe( "Optional entry identifier. Use this for multidirectional glossaries or to update a specific entry." ), }); - src/mcp/tools.ts:453-480 (registration)Tool definition registration in the toolDefinitions array. Registers the tool name 'add_glossary_entry' with its description, input schema, and annotations (title, readOnlyHint=false, destructiveHint=false).
name: "add_glossary_entry", description: "Adds or replaces an entry in a glossary in your Lara Translate account. Supports both monodirectional and multidirectional glossaries.", inputSchema: z.toJSONSchema(addGlossaryEntrySchema), annotations: { title: "Add or replace glossary entry", readOnlyHint: false, destructiveHint: false, openWorldHint: false, }, }, { name: "delete_glossary_entry", description: "Deletes an entry from a glossary in your Lara Translate account. Use term for monodirectional glossaries or guid for multidirectional glossaries.", inputSchema: z.toJSONSchema(deleteGlossaryEntrySchema), annotations: { title: "Delete glossary entry", readOnlyHint: false, destructiveHint: true, openWorldHint: false, }, }, ]; async function ListTools() { return { tools: toolDefinitions }; } - src/mcp/tools.ts:66-68 (registration)Registration of the handler function in the handlers record mapping 'add_glossary_entry' to the imported addGlossaryEntry function.
add_glossary_entry: addGlossaryEntry, delete_glossary_entry: deleteGlossaryEntry, }; - src/mcp/tools.ts:34-34 (registration)Import statement importing addGlossaryEntry and addGlossaryEntrySchema from the dedicated module file.
import { addGlossaryEntry, addGlossaryEntrySchema } from "./tools/add_glossary_entry.js";