lokalise_remove_projects_from_group
Remove specified projects from a user group to revoke team member access, limit project scope, or restructure permissions. All group members lose immediate access to those projects.
Instructions
Removes projects from a user group, revoking group member access to specified projects. Required: teamId, groupId, projectIds array. Use to limit project scope, offboard projects, or restructure access. Returns: Operation confirmation. Warning: All group members lose immediate project access.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| teamId | Yes | Team ID containing the user group | |
| groupId | Yes | User group ID | |
| projectIds | Yes | Project IDs to remove from the group |
Implementation Reference
- Handler function for the 'lokalise_remove_projects_from_group' tool. Calls usergroupsController.removeProjects and formats the response.
async function handleRemoveProjects(args: RemoveProjectsToolArgsType) { const methodLogger = Logger.forContext( "usergroups.tool.ts", "handleRemoveProjects", ); methodLogger.debug("Removing projects from user group...", args); try { const result = await usergroupsController.removeProjects(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 defining the input arguments: teamId (string), groupId (string|number), projectIds (array of string|number, min 1).
export const RemoveProjectsToolArgs = z .object({ teamId: z.string().describe("Team ID containing the user group"), groupId: z.union([z.string(), z.number()]).describe("User group ID"), projectIds: z .array(z.union([z.string(), z.number()])) .min(1) .describe("Project IDs to remove from the group"), }) .strict(); export type RemoveProjectsToolArgsType = z.infer<typeof RemoveProjectsToolArgs>; - src/domains/usergroups/usergroups.tool.ts:374-379 (registration)Registers the tool on the MCP server with name 'lokalise_remove_projects_from_group', description, schema, and handler.
server.tool( "lokalise_remove_projects_from_group", "Removes projects from a user group, revoking group member access to specified projects. Required: teamId, groupId, projectIds array. Use to limit project scope, offboard projects, or restructure access. Returns: Operation confirmation. Warning: All group members lose immediate project access.", RemoveProjectsToolArgs.shape, handleRemoveProjects, ); - Controller that validates inputs and delegates to usergroupsService.removeProjects, then formats via formatRemoveProjectsResult.
/** * Remove projects from a user group */ async function removeProjects( args: RemoveProjectsToolArgsType, ): Promise<ControllerResponse> { const methodLogger = Logger.forContext( "usergroups.controller.ts", "removeProjects", ); methodLogger.debug("Removing projects from user group...", args); try { // Validate inputs if (!args.teamId) { throw new McpError("Team ID is required.", ErrorType.API_ERROR); } if (!args.groupId) { throw new McpError("Group ID is required.", ErrorType.API_ERROR); } if (!args.projectIds || args.projectIds.length === 0) { throw new McpError( "At least one project ID is required.", ErrorType.API_ERROR, ); } // Call service layer const result = await usergroupsService.removeProjects(args); // Format response const formattedContent = formatRemoveProjectsResult( result, args.projectIds.length, ); methodLogger.debug("Projects removed successfully", { teamId: args.teamId, groupId: args.groupId, projectCount: args.projectIds.length, }); return { content: formattedContent, }; } catch (error: unknown) { throw handleControllerError(error, { source: "UsergroupsController.removeProjects", entityType: "UserGroup", entityId: String(args.groupId), operation: "removing projects", }); } } - Service layer that calls the Lokalise API client userGroups().remove_projects_from_group(teamId, groupId, projectIds).
async removeProjects(args: RemoveProjectsToolArgsType): Promise<UserGroup> { const methodLogger = logger.forMethod("removeProjects"); methodLogger.info("Removing projects from user group", { teamId: args.teamId, groupId: args.groupId, projectCount: args.projectIds.length, }); try { const api = getLokaliseApi(); // Convert project IDs to proper array type for SDK const projectIds = args.projectIds.map((id) => typeof id === "string" ? id : id.toString(), ); const result = await api .userGroups() .remove_projects_from_group(args.teamId, args.groupId, projectIds); methodLogger.info("Removed projects from user group successfully", { teamId: args.teamId, groupId: args.groupId, removedCount: args.projectIds.length, }); return result; } catch (error) { methodLogger.error("Failed to remove projects from user group", { error, args, }); throw createUnexpectedError( `Failed to remove projects from user group ${args.groupId}`, error, ); } },