Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

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; }

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