Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

Assign Role to User

assign_role_to_user

Assign security roles to users to grant appropriate access permissions for their job functions and responsibilities in Microsoft Dataverse.

Instructions

Assigns a security role to a specific user, granting them all the permissions defined in that role. Use this to provide users with the appropriate access levels for their job functions and responsibilities.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roleIdYesID of the role to assign
userIdYesID of the user to assign the role to

Implementation Reference

  • The async handler function that performs the core logic: posts to Dataverse API to associate a role with a user and returns success or error response.
    async (params) => {
      try {
        await client.post(`systemusers(${params.userId})/systemuserroles_association/$ref`, {
          "@odata.id": `${client['config'].dataverseUrl}/api/data/v9.2/roles(${params.roleId})`
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully assigned role to user.`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error assigning role to user: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod-based input schema defining required parameters: roleId and userId.
    inputSchema: {
      roleId: z.string().describe("ID of the role to assign"),
      userId: z.string().describe("ID of the user to assign the role to")
    }
  • The server.registerTool call that registers the tool with name, metadata, schema, and handler function.
    server.registerTool(
      "assign_role_to_user",
      {
        title: "Assign Role to User",
        description: "Assigns a security role to a specific user, granting them all the permissions defined in that role. Use this to provide users with the appropriate access levels for their job functions and responsibilities.",
        inputSchema: {
          roleId: z.string().describe("ID of the role to assign"),
          userId: z.string().describe("ID of the user to assign the role to")
        }
      },
      async (params) => {
        try {
          await client.post(`systemusers(${params.userId})/systemuserroles_association/$ref`, {
            "@odata.id": `${client['config'].dataverseUrl}/api/data/v9.2/roles(${params.roleId})`
          });
    
          return {
            content: [
              {
                type: "text",
                text: `Successfully assigned role to user.`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error assigning role to user: ${error instanceof Error ? error.message : 'Unknown error'}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • src/index.ts:193-193 (registration)
    Invocation of the registration function in the main server setup.
    assignRoleToUserTool(server, dataverseClient);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the effect ('granting them all the permissions defined in that role') but fails to cover critical aspects like required authentication, potential side effects (e.g., overwriting existing roles), rate limits, or error conditions. This is inadequate for a mutation tool with security implications.

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 front-loaded with the core purpose in the first sentence, followed by usage context. Both sentences are relevant and non-redundant, though it could be slightly more concise by integrating the second sentence's intent more tightly.

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

Completeness2/5

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

Given the complexity of a security-related mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on permissions needed, response format, error handling, or how it interacts with sibling tools like 'remove_role_from_user'. More context is required for safe and effective use.

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 input schema already documents both parameters (roleId and userId) adequately. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Assigns a security role to a specific user') and the resource involved, making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'assign_role_to_team' or 'remove_role_from_user', which would be needed for a score of 5.

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 provides implied usage context ('to provide users with the appropriate access levels for their job functions'), but lacks explicit guidance on when to use this tool versus alternatives like 'assign_role_to_team' or prerequisites such as required permissions. No when-not-to-use scenarios or clear alternatives are mentioned.

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