Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

Add Privileges to Dataverse Role

add_privileges_to_role

Grant specific permissions to security roles by adding privileges with defined access levels for operations like create, read, write, and delete on entities or system functions.

Instructions

Adds specific privileges with defined access levels to a security role. Use this to grant permissions for specific operations (create, read, write, delete, etc.) on entities or system functions. Each privilege can have different access levels (Basic, Local, Deep, Global).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privilegesYesArray of privileges to add to the role
roleIdYesID of the role to add privileges to

Implementation Reference

  • The core handler function that processes the tool input, maps privileges with depth values using getDepthValue helper, calls the Dataverse 'AddPrivilegesRole' action, and returns success or error response.
    async (params) => {
      try {
        const privileges = params.privileges.map(p => ({
          PrivilegeId: p.privilegeId,
          Depth: getDepthValue(p.depth)
        }));
    
        await client.callAction('AddPrivilegesRole', {
          RoleId: params.roleId,
          Privileges: privileges
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully added ${privileges.length} privilege(s) to role.`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error adding privileges to role: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
  • Zod input schema defining the parameters: roleId (string) and privileges (array of objects with privilegeId and depth enum).
      roleId: z.string().describe("ID of the role to add privileges to"),
      privileges: z.array(z.object({
        privilegeId: z.string().describe("ID of the privilege to add"),
        depth: z.enum(['Basic', 'Local', 'Deep', 'Global']).describe("Access level for the privilege")
      })).describe("Array of privileges to add to the role")
    }
  • The exported addPrivilegesToRoleTool function that performs the server.registerTool call for 'add_privileges_to_role', defining title, description, inputSchema, and handler.
    export function addPrivilegesToRoleTool(server: McpServer, client: DataverseClient) {
      server.registerTool(
        "add_privileges_to_role",
        {
          title: "Add Privileges to Dataverse Role",
          description: "Adds specific privileges with defined access levels to a security role. Use this to grant permissions for specific operations (create, read, write, delete, etc.) on entities or system functions. Each privilege can have different access levels (Basic, Local, Deep, Global).",
          inputSchema: {
            roleId: z.string().describe("ID of the role to add privileges to"),
            privileges: z.array(z.object({
              privilegeId: z.string().describe("ID of the privilege to add"),
              depth: z.enum(['Basic', 'Local', 'Deep', 'Global']).describe("Access level for the privilege")
            })).describe("Array of privileges to add to the role")
          }
        },
        async (params) => {
          try {
            const privileges = params.privileges.map(p => ({
              PrivilegeId: p.privilegeId,
              Depth: getDepthValue(p.depth)
            }));
    
            await client.callAction('AddPrivilegesRole', {
              RoleId: params.roleId,
              Privileges: privileges
            });
    
            return {
              content: [
                {
                  type: "text",
                  text: `Successfully added ${privileges.length} privilege(s) to role.`
                }
              ]
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `Error adding privileges to role: ${error instanceof Error ? error.message : 'Unknown error'}`
                }
              ],
              isError: true
            };
          }
        }
      );
    }
  • src/index.ts:187-187 (registration)
    Invocation of addPrivilegesToRoleTool in the main index file to register the tool on the MCP server instance.
    addPrivilegesToRoleTool(server, dataverseClient);
  • Helper utility function that converts the depth enum string to the numeric value required by the Dataverse API (Basic=0, Local=1, Deep=2, Global=3). 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;
      }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action ('Adds privileges') without disclosing behavioral traits like required permissions, whether this is idempotent, what happens on duplicate privileges, or error conditions. It mentions access levels but doesn't explain their implications or system impact.

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

Conciseness4/5

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

The description is appropriately sized with two sentences that efficiently convey purpose and key concepts. The first sentence states the core action, and the second provides important context about privilege types and access levels without unnecessary elaboration.

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

Completeness3/5

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

For a mutation tool with no annotations and no output schema, the description provides adequate basic information about what the tool does but lacks completeness regarding behavioral details, error handling, or response format. It covers the 'what' but not the 'how' or 'what happens after' sufficiently.

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?

Schema description coverage is 100%, so the baseline is 3. The description adds some context about privileges including operations (create/read/write/delete) and access levels (Basic/Local/Deep/Global), which provides meaning beyond the schema's technical parameter definitions, but doesn't fully explain how these map to the 'privilegeId' parameter.

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 verb ('Adds') and resource ('specific privileges...to a security role'), specifying the operation as granting permissions for create/read/write/delete operations on entities or system functions. It distinguishes from sibling tools like 'remove_privilege_from_role' and 'replace_role_privileges' by focusing on additive permission assignment.

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

Usage Guidelines3/5

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

The description implies usage context ('grant permissions for specific operations') but doesn't explicitly state when to use this tool versus alternatives like 'replace_role_privileges' or 'remove_privilege_from_role'. It mentions what the tool does but lacks explicit guidance on scenarios or prerequisites for use.

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