Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

Replace Dataverse Role Privileges

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;
      }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by explicitly warning about the destructive nature ('removes all current privileges'), clarifying this is a complete replacement operation. However, it doesn't mention authentication requirements, rate limits, or what happens to existing privileges not in the new set.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with zero waste: first states the core action, second provides critical warning about destructive behavior, third gives usage context. Every sentence earns its place and the warning is appropriately front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation tool with no annotations and no output schema, the description does well by clearly explaining the replacement behavior and warning about data loss. However, it doesn't mention what the tool returns (success confirmation, error details) or potential side effects on users/teams with the role.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, so the baseline is 3. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions for 'roleId' and 'privileges', though it reinforces that privileges are being 'replaced' rather than added.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('completely replaces all existing privileges') and resource ('security role'), distinguishing it from siblings like 'add_privileges_to_role' and 'remove_privilege_from_role' which perform incremental modifications rather than full replacement.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('for comprehensive role permission restructuring'), but doesn't explicitly state when not to use it or name specific alternatives like 'add_privileges_to_role' for incremental changes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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