lokalise_update_team_user
Update a team user's role (owner, admin, member, biller) to manage permissions and adjust access levels.
Instructions
Updates a team user's role (owner, admin, member, or biller). Required: teamId, userId, role. Use to manage permissions, promote/demote, or adjust access levels. Returns: Updated user profile with new role and permissions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| teamId | Yes | Team ID containing the user | |
| userId | Yes | User ID to update | |
| role | Yes | New role for the user |
Implementation Reference
- src/domains/teamusers/teamusers.tool.ts:195-200 (registration)Registration of the 'lokalise_update_team_user' tool on the MCP server with description, schema (UpdateTeamusersToolArgs.shape), and handler (handleUpdateTeamusers).
server.tool( "lokalise_update_team_user", "Updates a team user's role (owner, admin, member, or biller). Required: teamId, userId, role. Use to manage permissions, promote/demote, or adjust access levels. Returns: Updated user profile with new role and permissions.", UpdateTeamusersToolArgs.shape, handleUpdateTeamusers, ); - Handler function 'handleUpdateTeamusers' that receives args (teamId, userId, role), calls teamusersController.updateTeamusers(), and formats the result for MCP response.
/** * @function handleUpdateTeamusers * @description MCP Tool handler to update a teamusers's properties. * * @param {UpdateTeamusersToolArgsType} args - Arguments provided to the tool. * @returns {Promise<{ content: Array<{ type: 'text', text: string }> }>} Formatted response for the MCP. * @throws {McpError} Formatted error if the controller or service layer encounters an issue. */ async function handleUpdateTeamusers(args: UpdateTeamusersToolArgsType) { const methodLogger = Logger.forContext( "teamusers.tool.ts", "handleUpdateTeamusers", ); methodLogger.debug("Updating teamusers...", args); try { const result = await teamusersController.updateTeamusers(args); methodLogger.debug("Got the response from the controller", result); return { content: [ { type: "text" as const, text: result.content, }, ], }; } catch (error) { methodLogger.error("Tool failed", { error: (error as Error).message, args, }); return formatErrorForMcpTool(error); } } - Zod schema 'UpdateTeamusersToolArgs' defining input validation for update: teamId (string), userId (string|number), role (enum: owner, admin, member, biller).
/** * Zod schema for the update team user tool arguments. */ export const UpdateTeamusersToolArgs = z .object({ teamId: z.string().describe("Team ID containing the user"), userId: z.union([z.string(), z.number()]).describe("User ID to update"), role: z .enum(["owner", "admin", "member", "biller"]) .describe("New role for the user"), }) .strict(); export type UpdateTeamusersToolArgsType = z.infer< typeof UpdateTeamusersToolArgs >; - Controller 'updateTeamusers' that validates inputs (teamId, userId, role), calls teamusersService.update(), and formats response via formatUpdateTeamusersResult().
async function updateTeamusers( args: UpdateTeamusersToolArgsType, ): Promise<ControllerResponse> { const methodLogger = Logger.forContext( "teamusers.controller.ts", "updateTeamusers", ); methodLogger.debug("Updating team user...", args); try { // Validate inputs if (!args.teamId) { throw new McpError("Team ID is required.", ErrorType.API_ERROR); } if (!args.userId) { throw new McpError("User ID is required.", ErrorType.API_ERROR); } if (!args.role) { throw new McpError("Role is required.", ErrorType.API_ERROR); } // Call service layer const result = await teamusersService.update(args); // Format response const formattedContent = formatUpdateTeamusersResult(result); methodLogger.debug("Team user updated successfully", { teamId: args.teamId, userId: args.userId, newRole: args.role, }); return { content: formattedContent, }; } catch (error: unknown) { throw handleControllerError(error, { source: "TeamusersController.updateTeamusers", entityType: "TeamUser", entityId: String(args.userId), operation: "updating", }); } } - Service 'update' that calls the Lokalise SDK api.teamUsers().update() with userId, role params, and team_id query param.
async update(args: UpdateTeamusersToolArgsType): Promise<TeamUser> { const methodLogger = logger.forMethod("update"); methodLogger.info("Updating team user", { teamId: args.teamId, userId: args.userId, role: args.role, }); try { const api = getLokaliseApi(); const updateParams: TeamUserParams = { role: args.role, }; const result = await api .teamUsers() .update(args.userId, updateParams, { team_id: args.teamId }); methodLogger.info("Updated team user successfully", { teamId: args.teamId, userId: args.userId, newRole: args.role, }); return result; } catch (error) { methodLogger.error("Failed to update team user", { error, args }); throw createUnexpectedError( `Failed to update team user ${args.userId} in team ${args.teamId}`, error, ); } },