list_languages
Retrieve all available languages for a translation project to manage multilingual content and streamline localization workflows.
Instructions
List languages in the project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No |
Implementation Reference
- src/server.ts:290-294 (handler)Handler function for the 'list_languages' tool. Resolves project ID, calls POEditor 'languages/list' API endpoint, and returns the result as formatted JSON text.async (args) => { const id = requireProjectId(args.project_id ?? null); const res = await poeditor("languages/list", { id: String(id) }); return { content: [{ type: "text", text: JSON.stringify(res.result ?? {}, null, 2) }] }; }
- src/server.ts:73-75 (schema)Zod schema defining the input parameters for the 'list_languages' tool (optional project_id).const ListLanguagesInput = z.object({ project_id: z.number().int().positive().optional() });
- src/server.ts:286-295 (registration)Registration of the 'list_languages' tool with the MCP server, including name, description, input schema, and handler function.server.tool( "list_languages", "List languages in the project.", ListLanguagesInput.shape, async (args) => { const id = requireProjectId(args.project_id ?? null); const res = await poeditor("languages/list", { id: String(id) }); return { content: [{ type: "text", text: JSON.stringify(res.result ?? {}, null, 2) }] }; } );
- src/server.ts:40-44 (helper)Helper function used by list_languages (and other tools) to resolve or require the project_id from args or env.function requireProjectId(argProjectId?: number | null) { const id = argProjectId ?? (PROJECT_ID ? Number(PROJECT_ID) : null); if (!id) throw new Error("project_id is required (either pass it to the tool or set POEDITOR_PROJECT_ID)"); return id; }
- src/server.ts:19-38 (helper)Core helper function used by list_languages handler to make authenticated API calls to POEditor.export async function poeditor(endpoint: string, form: Record<string, string>) { const body = new URLSearchParams({ api_token: API_TOKEN!, ...form }); const { body: resBody } = await request(`${API_BASE}/${endpoint}`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: body.toString() }); const text = await resBody.text(); let json: any; try { json = JSON.parse(text); } catch (e) { throw new Error(`POEditor: invalid JSON response: ${text}`); } const status = json?.response?.status; if (status !== "success") { const code = json?.response?.code; const message = json?.response?.message || "Unknown POEditor error"; throw new Error(`POEditor API error ${code ?? ""}: ${message}`); } return json; }