Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

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
NameRequiredDescriptionDefault
privilegesYesArray of privileges to replace existing privileges with
roleIdYesID of the role to replace privileges for

Implementation Reference

  • 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 }; } }
  • 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") }
  • 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);
  • 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; }

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/mwhesse/mcp-dataverse'

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