lokalise_list_project_languages
Retrieve all languages in a translation project with optional progress percentages to audit coverage and identify incomplete translations.
Instructions
Shows which languages are currently being translated in a project. Required: projectId. Optional: includeProgress (shows completion %), limit, page. Use to audit translation coverage, identify incomplete languages, or prepare reports. Returns: Active languages with progress stats. Start here to understand project's localization scope.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID to list languages for | |
| includeProgress | No | Include translation progress percentages for each language |
Implementation Reference
- src/domains/languages/languages.tool.ts:290-296 (registration)Registration of the 'lokalise_list_project_languages' tool on the MCP server. Calls server.tool() with the tool name, description, schema shape, and handler function.
// Register project languages listing tool server.tool( "lokalise_list_project_languages", "Shows which languages are currently being translated in a project. Required: projectId. Optional: includeProgress (shows completion %), limit, page. Use to audit translation coverage, identify incomplete languages, or prepare reports. Returns: Active languages with progress stats. Start here to understand project's localization scope.", ListProjectLanguagesToolArgs.shape, handleListProjectLanguages, ); - The MCP tool handler function 'handleListProjectLanguages'. It receives typed args, logs, calls languagesController.listProjectLanguages(args), and formats the response as MCP text content.
async function handleListProjectLanguages( args: ListProjectLanguagesToolArgsType, ) { const methodLogger = Logger.forContext( "tools/languages.tool.ts", "handleListProjectLanguages", ); methodLogger.debug( `Getting Lokalise project languages for project ${args.projectId}...`, args, ); try { // Pass args directly to the controller const result = await languagesController.listProjectLanguages(args); methodLogger.debug("Got the response from the controller", result); // Format the response for the MCP tool return { content: [ { type: "text" as const, text: result.content, }, ], }; } catch (error) { methodLogger.error( `Error getting languages for project: ${args.projectId}`, error, ); return formatErrorForMcpTool(error); } } - Zod schema (ListProjectLanguagesToolArgs) and TypeScript type (ListProjectLanguagesToolArgsType) defining the input validation for the tool. Requires projectId (string), optional includeProgress (boolean, defaults to false).
/** * Zod schema for the list project languages tool arguments. */ export const ListProjectLanguagesToolArgs = z .object({ projectId: z.string().describe("Project ID to list languages for"), includeProgress: z .boolean() .optional() .default(false) .describe("Include translation progress percentages for each language"), }) .strict(); /** * TypeScript type inferred from the ListProjectLanguagesToolArgs Zod schema. */ export type ListProjectLanguagesToolArgsType = z.infer< typeof ListProjectLanguagesToolArgs >; - Controller function 'listProjectLanguages' that orchestrates the tool logic: validates projectId, calls languagesService.getProjectLanguages(), and formats the result via formatProjectLanguages().
); } } /** * @function listProjectLanguages * @description Lists all languages in a specific Lokalise project. * @memberof LanguagesController * @param {ListProjectLanguagesToolArgsType} args - Arguments containing project and language options * @returns {Promise<ControllerResponse>} A promise that resolves to the standard controller response containing the formatted languages list in Markdown. * @throws {McpError} Throws an McpError (handled by `handleControllerError`) if the service call fails or returns an error. */ async function listProjectLanguages( - Service function 'getProjectLanguages' that calls the Lokalise SDK (api.languages().list()) to fetch project languages from the API.
async function getProjectLanguages(projectId: string): Promise<Language[]> { const methodLogger = Logger.forContext( "services/vendor.lokalise.com.languages.service.ts", "getProjectLanguages", ); methodLogger.debug("Calling Lokalise API for project languages", { projectId, }); try { const api = getLokaliseApi(); // Use SDK to fetch project languages const response = await api.languages().list({ project_id: projectId }); methodLogger.debug( `Received project languages from Lokalise API: ${response.items.length} languages`, ); // Return the SDK response items directly as they match our Language type return response.items as Language[]; } catch (error) { methodLogger.error( "Service error fetching Lokalise project languages", error, ); // Rethrow other McpErrors if (error instanceof McpError) { throw error; } // Wrap any other unexpected errors throw createUnexpectedError( "Unexpected service error while fetching Lokalise project languages", error, ); } } /** * @function addProjectLanguages * @description Adds languages to a project in Lokalise using the official SDK. * @memberof VendorLanguagesService * @param {string} projectId - The project ID to add languages to. * @param {CreateLanguageParams[]} languages - Array of language data to add. * @returns {Promise<Language[]>} A promise that resolves to an array of added languages. * @throws {McpError} Throws an `McpError` if the API call fails. */ async function addProjectLanguages( projectId: string, languages: CreateLanguageParams[], ): Promise<Language[]> { const methodLogger = Logger.forContext( "services/vendor.lokalise.com.languages.service.ts", "addProjectLanguages", ); methodLogger.debug("Adding languages to Lokalise project", { projectId,