replace_role_privileges
Replace all existing security role privileges with a new set of permissions to restructure role access levels in Dataverse.
Instructions
Completely replaces all existing privileges in a security role with a new set of privileges. WARNING: This removes all current privileges and replaces them with the specified ones. Use this for comprehensive role permission restructuring.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| privileges | Yes | Array of privileges to replace existing privileges with | |
| roleId | Yes | ID of the role to replace privileges for |
Implementation Reference
- src/tools/role-tools.ts:421-452 (handler)Handler function that maps input privileges to the required format, calls the Dataverse 'ReplacePrivilegesRole' action, and returns success/error responses.async (params) => { try { const privileges = params.privileges.map(p => ({ PrivilegeId: p.privilegeId, Depth: getDepthValue(p.depth) })); await client.callAction('ReplacePrivilegesRole', { RoleId: params.roleId, Privileges: privileges }); return { content: [ { type: "text", text: `Successfully replaced role privileges with ${privileges.length} privilege(s).` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error replacing role privileges: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/role-tools.ts:413-419 (schema)Zod input schema defining roleId and privileges array with privilegeId and depth (Basic/Local/Deep/Global).inputSchema: { roleId: z.string().describe("ID of the role to replace privileges for"), privileges: z.array(z.object({ privilegeId: z.string().describe("ID of the privilege"), depth: z.enum(['Basic', 'Local', 'Deep', 'Global']).describe("Access level for the privilege") })).describe("Array of privileges to replace existing privileges with") }
- src/tools/role-tools.ts:407-454 (registration)Factory function exporting the registration of the 'replace_role_privileges' tool with MCP server, including title, description, schema, and handler.export function replaceRolePrivilegesTool(server: McpServer, client: DataverseClient) { server.registerTool( "replace_role_privileges", { title: "Replace Dataverse Role Privileges", description: "Completely replaces all existing privileges in a security role with a new set of privileges. WARNING: This removes all current privileges and replaces them with the specified ones. Use this for comprehensive role permission restructuring.", inputSchema: { roleId: z.string().describe("ID of the role to replace privileges for"), privileges: z.array(z.object({ privilegeId: z.string().describe("ID of the privilege"), depth: z.enum(['Basic', 'Local', 'Deep', 'Global']).describe("Access level for the privilege") })).describe("Array of privileges to replace existing privileges with") } }, async (params) => { try { const privileges = params.privileges.map(p => ({ PrivilegeId: p.privilegeId, Depth: getDepthValue(p.depth) })); await client.callAction('ReplacePrivilegesRole', { RoleId: params.roleId, Privileges: privileges }); return { content: [ { type: "text", text: `Successfully replaced role privileges with ${privileges.length} privilege(s).` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error replacing role privileges: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:189-189 (registration)Invocation of the replaceRolePrivilegesTool factory in the main server setup to register the tool.replaceRolePrivilegesTool(server, dataverseClient);
- src/tools/role-tools.ts:5-12 (helper)Utility function to convert privilege depth string ('Basic', 'Local', etc.) to numeric value used in the handler.function getDepthValue(depth: string): number { switch (depth) { case 'Basic': return 0; case 'Local': return 1; case 'Deep': return 2; case 'Global': return 3; default: return 0; }