Skip to main content
Glama

lokalise_create_keys

Add new translation keys to your Lokalise project for UI text or content. Specify key names, platforms, and optional translations to prepare new features or initial content for localization.

Instructions

Adds new UI text or content to be translated (up to 1000 keys per request). Required: projectId, keys array with {key_name, platforms}. Optional per key: description, tags, translations. Use for new features, initial setup, or content expansion. Returns: Created keys with IDs and any errors. Tip: Include base language translations to speed up workflow. Pairs with: lokalise_list_keys to verify.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID to create keys in
keysYesArray of key objects to create (1-1000 keys)

Implementation Reference

  • Registration of the 'lokalise_create_keys' MCP tool using server.tool() with description, schema (CreateKeysToolArgs.shape), and handler (handleCreateKeys).
    // Create Keys Tool
    server.tool(
    	"lokalise_create_keys",
    	"Adds new UI text or content to be translated (up to 1000 keys per request). Required: projectId, keys array with {key_name, platforms}. Optional per key: description, tags, translations. Use for new features, initial setup, or content expansion. Returns: Created keys with IDs and any errors. Tip: Include base language translations to speed up workflow. Pairs with: lokalise_list_keys to verify.",
    	CreateKeysToolArgs.shape,
    	handleCreateKeys,
    );
  • MCP tool handler that delegates to keysController.createKeys() and formats the response for MCP.
    async function handleCreateKeys(args: CreateKeysToolArgsType) {
    	const methodLogger = Logger.forContext(
    		"tools/keys.tool.ts",
    		"handleCreateKeys",
    	);
    	methodLogger.debug(
    		`Creating ${args.keys.length} keys in project ${args.projectId}...`,
    		args,
    	);
    
    	try {
    		const result = await keysController.createKeys(args);
    		methodLogger.debug("Got the response from the controller", result);
    
    		return {
    			content: [
    				{
    					type: "text" as const,
    					text: result.content,
    				},
    			],
    		};
    	} catch (error) {
    		methodLogger.error("Error in handleCreateKeys", { error, args });
    		throw formatErrorForMcpTool({
    			error,
    			message: "Failed to create keys",
    		});
    	}
    }
  • Zod schema defining the input arguments: projectId (string), keys array (1-1000 items) each with key_name, description, platforms, translations, and tags.
    export const CreateKeysToolArgs = z
    	.object({
    		projectId: z.string().describe("Project ID to create keys in"),
    		keys: z
    			.array(
    				z.object({
    					key_name: z.string().describe("Name of the key"),
    					description: z
    						.string()
    						.optional()
    						.describe("Description of the translation key"),
    					platforms: z
    						.array(z.enum(["ios", "android", "web", "other"]))
    						.min(1)
    						.describe("Platforms this key belongs to (required)"),
    					translations: z
    						.array(
    							z.object({
    								language_iso: z.string().describe("Language ISO code"),
    								translation: z.string().describe("Translation text"),
    							}),
    						)
    						.optional()
    						.describe("Initial translations for the key"),
    					tags: z
    						.array(z.string())
    						.optional()
    						.describe("Tags to organize the key"),
    				}),
    			)
    			.min(1)
    			.max(1000)
    			.describe("Array of key objects to create (1-1000 keys)"),
    	})
    	.strict();
    
    export type CreateKeysToolArgsType = z.infer<typeof CreateKeysToolArgs>;
  • Service layer function that calls the Lokalise API (api.keys().create()) to actually create keys in the project.
    export async function createKeys(
    	options: CreateKeysParams,
    ): Promise<BulkResult<Key>> {
    	const methodLogger = serviceLogger.forMethod("createKeys");
    
    	try {
    		methodLogger.debug("Calling Lokalise Keys API - create", {
    			projectId: options.project_id,
    			keysCount: options.keys.length,
    		});
    
    		const api = getLokaliseApi();
    
    		// Prepare API parameters
    		const apiParams = {
    			keys: options.keys.map((key) => ({
    				key_name: key.key_name,
    				description: key.description,
    				platforms: key.platforms,
    				translations: key.translations || [],
    				tags: key.tags || [],
    			})),
    		};
    
    		const result = await api
    			.keys()
    			.create(apiParams, { project_id: options.project_id });
    
    		methodLogger.debug("Lokalise Keys API call successful - create", {
    			projectId: options.project_id,
    			createdCount: result.items?.length || 0,
    			errorsCount: result.errors?.length || 0,
    		});
    
    		return result;
    	} catch (error: unknown) {
    		methodLogger.error("Lokalise Keys API call failed - create", {
    			error: (error as Error).message,
    			projectId: options.project_id,
    		});
    
    		if ((error as ApiError).code === 404) {
    			throw createApiError(`Project not found: ${options.project_id}`, 404);
    		}
    		if ((error as ApiError).code === 403) {
    			throw createApiError("Access denied to this project", 403);
    		}
    		if ((error as ApiError).code === 401) {
    			throw createApiError("Invalid API key", 401);
    		}
    
    		throw createUnexpectedError(
    			`Failed to create keys in project ${options.project_id}: ${(error as Error).message}`,
    		);
    	}
    }
Behavior3/5

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

No annotations provided, so description carries full burden. Discloses key limit, optional fields, and return structure (IDs and errors). Does not mention permissions, error handling, or idempotency.

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?

Three sentences, front-loaded with action and limit, includes tip and pairing suggestion. No unnecessary words.

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?

Describes return structure and includes operational tips. Lacks output schema, but description covers basics. Could mention error scenarios or rate limits for completeness.

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 coverage is 100%, so baseline is 3. Description adds minimal extra meaning beyond schema (e.g., tip about base language translations). Does not explain platform values or tag usage.

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?

Description clearly states verb ('Adds') and resource ('UI text or content to be translated'), with explicit limit of 1000 keys. Distinguishes from siblings like lokalise_create_project.

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?

States when to use: 'new features, initial setup, or content expansion.' Pairs with lokalise_list_keys to verify. Lacks explicit when-not-to-use, but context is clear.

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/AbdallahAHO/lokalise-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server