deepl_translate
Translate text between 30+ languages using DeepL's neural machine translation. Specify target language, optional source language, and formality level for natural-sounding output.
Instructions
Translate text using DeepL neural machine translation. Supports 30+ languages with high-quality, natural-sounding output.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to translate | |
| target_lang | Yes | Target language code (e.g., EN, KO, JA, DE, FR, ES, ZH) | |
| source_lang | No | Source language code (auto-detected if omitted) | |
| formality | No | Formality level (not all languages support this) |
Implementation Reference
- src/index.ts:14-40 (handler)The tool execution handler in src/index.ts iterates through all registered tools (including deepl_translate) and executes them by making a call to gatewayRequest using the endpoint defined in the tool definition.
// Register all tools for (const tool of allTools) { server.tool( tool.name, tool.description, tool.inputSchema.shape, async (params) => { const method = tool.method || "POST"; const result = await gatewayRequest(method, tool.endpoint, params as Record<string, unknown>); if (result.error) { return { content: [{ type: "text" as const, text: `Error (${result.status}): ${result.error}` }], isError: true, }; } const text = typeof result.data === "string" ? result.data : JSON.stringify(result.data, null, 2); return { content: [{ type: "text" as const, text }], }; }, ); } - src/tools/deepl.ts:8-14 (schema)Input schema definition for the deepl_translate tool.
inputSchema: z.object({ text: z.string().describe("Text to translate"), target_lang: z.string().describe("Target language code (e.g., EN, KO, JA, DE, FR, ES, ZH)"), source_lang: z.string().optional().describe("Source language code (auto-detected if omitted)"), formality: z.enum(["default", "more", "less", "prefer_more", "prefer_less"]).optional() .describe("Formality level (not all languages support this)"), }), - src/tools/deepl.ts:4-17 (registration)Definition and registration of the deepl_translate tool.
export const deeplTools: ToolDef[] = [ { name: "deepl_translate", description: "Translate text using DeepL neural machine translation. Supports 30+ languages with high-quality, natural-sounding output.", inputSchema: z.object({ text: z.string().describe("Text to translate"), target_lang: z.string().describe("Target language code (e.g., EN, KO, JA, DE, FR, ES, ZH)"), source_lang: z.string().optional().describe("Source language code (auto-detected if omitted)"), formality: z.enum(["default", "more", "less", "prefer_more", "prefer_less"]).optional() .describe("Formality level (not all languages support this)"), }), endpoint: "/v1/deepl/translate", }, ];