Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_azure_ad_devices

Destructive

Manage Azure AD registered devices by listing, enabling, disabling, or deleting them, and handling compliance and BitLocker keys.

Instructions

Manage devices registered in Azure AD including device compliance, BitLocker keys, and device actions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAzure AD device management action
deviceIdNoObject ID of the device
filterNoOData filter string

Implementation Reference

  • The core handler function implementing manage_azure_ad_devices tool logic. Handles actions: list_devices, get_device, enable_device, disable_device, delete_device using Microsoft Graph /devices endpoint.
    export async function handleAzureAdDevices(
      graphClient: Client,
      args: AzureAdDeviceArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      let apiPath = '';
      let result: any;
    
      switch (args.action) {
        case 'list_devices':
          apiPath = '/devices';
          if (args.filter) {
            apiPath += `?$filter=${encodeURIComponent(args.filter)}`;
          }
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'get_device':
          if (!args.deviceId) {
            throw new McpError(ErrorCode.InvalidParams, 'deviceId is required for get_device');
          }
          apiPath = `/devices/${args.deviceId}`;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'enable_device':
        case 'disable_device':
          if (!args.deviceId) {
            throw new McpError(ErrorCode.InvalidParams, `deviceId is required for ${args.action}`);
          }
          // Note: Enabling/Disabling devices is done via update, setting accountEnabled
          // This requires Device.ReadWrite.All permission.
          apiPath = `/devices/${args.deviceId}`;
          await graphClient.api(apiPath).patch({
            accountEnabled: args.action === 'enable_device'
          });
          result = { message: `Device ${args.action === 'enable_device' ? 'enabled' : 'disabled'} successfully` };
          break;
    
        case 'delete_device':
          if (!args.deviceId) {
            throw new McpError(ErrorCode.InvalidParams, 'deviceId is required for delete_device');
          }
          // Requires Device.ReadWrite.All permission.
          apiPath = `/devices/${args.deviceId}`;
          await graphClient.api(apiPath).delete();
          result = { message: 'Device deleted successfully' };
          break;
    
        default:
          throw new McpError(ErrorCode.InvalidParams, `Invalid action: ${args.action}`);
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
  • Zod schema defining the input parameters (action, deviceId, filter) for the manage_azure_ad_devices tool, used for validation.
    export const azureAdDeviceSchema = z.object({
      action: z.enum(['list_devices', 'get_device', 'enable_device', 'disable_device', 'delete_device']).describe('Azure AD device management action'),
      deviceId: z.string().optional().describe('Object ID of the device'),
      filter: z.string().optional().describe('OData filter string'),
    });
  • src/server.ts:564-584 (registration)
    MCP server registration of the 'manage_azure_ad_devices' tool, linking schema, metadata annotations, and handler function.
    this.server.tool(
      "manage_azure_ad_devices",
      "Manage devices registered in Azure AD including device compliance, BitLocker keys, and device actions.",
      azureAdDeviceSchema.shape,
      {"readOnlyHint":false,"destructiveHint":true,"idempotentHint":false},
      wrapToolHandler(async (args: AzureAdDeviceArgs) => {
        // Validate credentials only when tool is executed (lazy loading)
        this.validateCredentials();
        try {
          return await handleAzureAdDevices(this.getGraphClient(), args);
        } catch (error) {
          if (error instanceof McpError) {
            throw error;
          }
          throw new McpError(
            ErrorCode.InternalError,
            `Error executing tool: ${error instanceof Error ? error.message : 'Unknown error'}`
          );
        }
      })
    );
  • Tool metadata including description, title, and annotations (readOnlyHint, destructiveHint, etc.) for manage_azure_ad_devices.
    manage_azure_ad_devices: {
      description: "Manage devices registered in Azure AD including device compliance, BitLocker keys, and device actions.",
      title: "Azure AD Device Manager",
      annotations: { title: "Azure AD Device Manager", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }
Behavior3/5

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

Annotations indicate destructiveHint=true, readOnlyHint=false, and idempotentHint=false, covering safety and idempotency. The description adds context by mentioning 'device compliance, BitLocker keys, and device actions,' which hints at sensitive operations like key management and device state changes. However, it doesn't disclose critical behavioral traits like authentication requirements, rate limits, or side effects of actions like 'delete_device,' which are important given the destructive nature. No contradiction with annotations exists.

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 a single, efficient sentence that front-loads the core purpose and lists key capabilities. It avoids redundancy and waste, making it easy to parse. However, it could be slightly more structured by separating the main action from the examples, but this is minor.

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?

Given the tool's complexity (3 parameters, destructive operations, no output schema) and rich annotations, the description is minimally adequate. It covers the scope but lacks details on output format, error handling, or integration with sibling tools. For a destructive tool with multiple actions, more context on consequences or usage scenarios would improve completeness, but annotations help mitigate some gaps.

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%, with clear descriptions for 'action' (enum values), 'deviceId', and 'filter'. The description adds no parameter-specific semantics beyond what the schema provides, such as explaining when 'deviceId' is required or how 'filter' works with OData. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate with additional insights.

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 tool's purpose: 'Manage devices registered in Azure AD including device compliance, BitLocker keys, and device actions.' It specifies the verb ('manage') and resource ('devices registered in Azure AD'), and lists key capabilities. However, it doesn't explicitly differentiate from sibling tools like 'manage_intune_windows_devices' or 'manage_intune_macos_devices', which reduces clarity about its specific scope within the broader device management context.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools, prerequisites, or contextual factors like permissions or Azure AD vs. Intune management. For example, it doesn't clarify if this is for Azure AD-specific device actions versus broader device management in other tools, leaving the agent to infer usage from the tool name alone.

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/DynamicEndpoints/m365-core-mcp'

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