remove_role_from_user
Remove security role assignments from users to revoke specific permissions when access requirements change or roles are updated.
Instructions
Removes a security role assignment from a specific user, revoking the permissions granted by that role. Use this when users change roles or no longer need certain access levels.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roleId | Yes | ID of the role to remove | |
| userId | Yes | ID of the user to remove the role from |
Implementation Reference
- src/tools/role-tools.ts:552-576 (handler)The core handler function that executes the tool logic: deletes the security role assignment from the user using the Dataverse API.async (params) => { try { await client.delete(`systemusers(${params.userId})/systemuserroles_association(${params.roleId})/$ref`); return { content: [ { type: "text", text: `Successfully removed role from user.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error removing role from user: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );
- src/tools/role-tools.ts:547-550 (schema)Zod input schema defining the required parameters: roleId (string) and userId (string).inputSchema: { roleId: z.string().describe("ID of the role to remove"), userId: z.string().describe("ID of the user to remove the role from") }
- src/tools/role-tools.ts:541-577 (registration)The registration function that registers the tool with the MCP server, including name, metadata, schema, and handler.export function removeRoleFromUserTool(server: McpServer, client: DataverseClient) { server.registerTool( "remove_role_from_user", { title: "Remove Role from User", description: "Removes a security role assignment from a specific user, revoking the permissions granted by that role. Use this when users change roles or no longer need certain access levels.", inputSchema: { roleId: z.string().describe("ID of the role to remove"), userId: z.string().describe("ID of the user to remove the role from") } }, async (params) => { try { await client.delete(`systemusers(${params.userId})/systemuserroles_association(${params.roleId})/$ref`); return { content: [ { type: "text", text: `Successfully removed role from user.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error removing role from user: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:194-194 (registration)Invocation of the tool registration function during server initialization.removeRoleFromUserTool(server, dataverseClient);