Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_sensitivity_labels

Destructive

Configure and apply sensitivity labels to protect information through encryption, content marking, and classification policies in Microsoft 365.

Instructions

Manage sensitivity labels for information protection including encryption, content marking, and classification policies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on sensitivity label
labelIdNoSensitivity label ID for specific operations
displayNameNoDisplay name for the sensitivity label
descriptionNoDescription of the sensitivity label
tooltipNoTooltip text for the label
priorityNoLabel priority (higher number = higher priority)
isEnabledNoWhether the label is enabled
settingsNoLabel settings

Implementation Reference

  • Primary handler function executing the core logic for the 'manage_sensitivity_labels' tool. Handles CRUD operations and publishing using Microsoft Graph /security/informationProtection/sensitivityLabels endpoints.
    export async function handleSensitivityLabels(
      graphClient: Client,
      args: SensitivityLabelArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      let apiPath = '';
      let result: any;
    
      switch (args.action) {
        case 'list':
          // List all sensitivity labels
          apiPath = '/security/informationProtection/sensitivityLabels';
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'get':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for get action');
          }
          apiPath = `/security/informationProtection/sensitivityLabels/${args.labelId}`;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'create':
          if (!args.displayName) {
            throw new McpError(ErrorCode.InvalidParams, 'displayName is required for create action');
          }
          
          const sensitivityLabelPayload: any = {
            displayName: args.displayName,
            description: args.description || '',
            tooltip: args.tooltip || args.description || '',
            priority: args.priority || 0,
            isEnabled: args.isEnabled !== undefined ? args.isEnabled : true,
            labelActions: [],
            applicableTo: 'EmailMessage,File'
          };
    
          // Add settings if provided
          if (args.settings) {
            if (args.settings.contentMarking) {
              sensitivityLabelPayload.labelActions.push({
                '@odata.type': 'microsoft.graph.contentMarkingLabelAction',
                ...args.settings.contentMarking
              });
            }
    
            if (args.settings.encryption && args.settings.encryption.enabled) {
              sensitivityLabelPayload.labelActions.push({
                '@odata.type': 'microsoft.graph.encryptionLabelAction',
                ...args.settings.encryption
              });
            }
    
            if (args.settings.accessControl) {
              sensitivityLabelPayload.labelActions.push({
                '@odata.type': 'microsoft.graph.accessControlLabelAction',
                ...args.settings.accessControl
              });
            }
    
            if (args.settings.autoLabeling && args.settings.autoLabeling.enabled) {
              sensitivityLabelPayload.labelActions.push({
                '@odata.type': 'microsoft.graph.autoLabelingLabelAction',
                ...args.settings.autoLabeling
              });
            }
          }
    
          apiPath = '/security/informationProtection/sensitivityLabels';
          result = await graphClient.api(apiPath).post(sensitivityLabelPayload);
          break;
    
        case 'update':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for update action');
          }
    
          const updatePayload: any = {};
          if (args.displayName) updatePayload.displayName = args.displayName;
          if (args.description) updatePayload.description = args.description;
          if (args.tooltip) updatePayload.tooltip = args.tooltip;
          if (args.priority !== undefined) updatePayload.priority = args.priority;
          if (args.isEnabled !== undefined) updatePayload.isEnabled = args.isEnabled;
    
          // Handle settings updates
          if (args.settings) {
            updatePayload.labelActions = [];
            
            if (args.settings.contentMarking) {
              updatePayload.labelActions.push({
                '@odata.type': 'microsoft.graph.contentMarkingLabelAction',
                ...args.settings.contentMarking
              });
            }
    
            if (args.settings.encryption && args.settings.encryption.enabled) {
              updatePayload.labelActions.push({
                '@odata.type': 'microsoft.graph.encryptionLabelAction',
                ...args.settings.encryption
              });
            }
    
            if (args.settings.accessControl) {
              updatePayload.labelActions.push({
                '@odata.type': 'microsoft.graph.accessControlLabelAction',
                ...args.settings.accessControl
              });
            }
    
            if (args.settings.autoLabeling && args.settings.autoLabeling.enabled) {
              updatePayload.labelActions.push({
                '@odata.type': 'microsoft.graph.autoLabelingLabelAction',
                ...args.settings.autoLabeling
              });
            }
          }
    
          apiPath = `/security/informationProtection/sensitivityLabels/${args.labelId}`;
          result = await graphClient.api(apiPath).patch(updatePayload);
          break;
    
        case 'delete':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for delete action');
          }
          apiPath = `/security/informationProtection/sensitivityLabels/${args.labelId}`;
          await graphClient.api(apiPath).delete();
          result = { message: `Sensitivity label ${args.labelId} deleted successfully` };
          break;
    
        case 'publish':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for publish action');
          }
          
          // Create a label policy to publish the label
          const publishPayload = {
            displayName: `${args.displayName || 'Label'} Policy`,
            description: `Policy for publishing sensitivity label`,
            labels: [args.labelId],
            settings: {
              mandatory: false,
              requireJustification: false
            }
          };
    
          apiPath = '/security/informationProtection/labelPolicies';
          result = await graphClient.api(apiPath).post(publishPayload);
          break;
    
        default:
          throw new McpError(ErrorCode.InvalidParams, `Unknown action: ${args.action}`);
      }
    
      return {
        content: [{
          type: 'text',
          text: `Sensitivity Label ${args.action} operation completed:\n\n${JSON.stringify(result, null, 2)}`
        }]
      };
    }
  • Alternative handler for sensitivity labels in DLP context using /informationProtection/policy/labels endpoints.
    // DLP Sensitivity Labels Handler
    export async function handleDLPSensitivityLabels(
      graphClient: Client,
      args: DLPSensitivityLabelArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      let apiPath = '';
      let result: any;
    
      switch (args.action) {
        case 'list':
          apiPath = '/informationProtection/policy/labels';
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'get':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for get action');
          }
          apiPath = `/informationProtection/policy/labels/${args.labelId}`;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'create':
          if (!args.name) {
            throw new McpError(ErrorCode.InvalidParams, 'name is required for create action');
          }
          apiPath = '/informationProtection/policy/labels';
          const labelPayload = {
            name: args.name,
            description: args.description || '',
            color: args.settings?.color || 'blue',
            sensitivity: args.settings?.sensitivity || 0,
            tooltip: args.description || args.name,
            isActive: true
          };
          result = await graphClient.api(apiPath).post(labelPayload);
          break;
    
        case 'update':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for update action');
          }
          apiPath = `/informationProtection/policy/labels/${args.labelId}`;
          const updateLabelPayload = {
            name: args.name,
            description: args.description,
            color: args.settings?.color,
            sensitivity: args.settings?.sensitivity
          };
          result = await graphClient.api(apiPath).patch(updateLabelPayload);
          break;
    
        case 'delete':
          if (!args.labelId) {
            throw new McpError(ErrorCode.InvalidParams, 'labelId is required for delete action');
          }
          apiPath = `/informationProtection/policy/labels/${args.labelId}`;
          await graphClient.api(apiPath).delete();
          result = { message: 'Sensitivity label 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 input parameters and validation for the manage_sensitivity_labels tool.
    // Sensitivity Label Management
    export const sensitivityLabelSchema = z.object({
      action: z.enum(['list', 'get', 'create', 'update', 'delete', 'apply']).describe('Sensitivity label action'),
      labelId: z.string().optional().describe('Sensitivity label ID'),
      name: z.string().optional().describe('Label name'),
      description: z.string().optional().describe('Label description'),
      targetId: z.string().optional().describe('Target resource ID for label application'),
      settings: z.record(z.string(), z.any()).optional().describe('Label settings and policies'),
    });
  • MCP server tool registration for 'manage_sensitivity_labels' with schema, metadata annotations, and handler binding.
    const sensitivityLabelsMeta = getToolMetadata("manage_sensitivity_labels")!;
    this.server.tool(
      "manage_sensitivity_labels",
      sensitivityLabelsMeta.description,
      sensitivityLabelArgsSchema.shape,
      sensitivityLabelsMeta.annotations || {},
      wrapToolHandler(async (args: SensitivityLabelArgs) => {
        this.validateCredentials();
        try {
          return await handleSensitivityLabels(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.) used during registration.
    manage_sensitivity_labels: {
      description: "Manage sensitivity labels for information protection including encryption, content marking, and classification policies.",
      title: "Sensitivity Label Manager",
      annotations: { title: "Sensitivity Label Manager", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }
Behavior3/5

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

The description adds some behavioral context by mentioning encryption, content marking, and classification policies, which helps clarify the tool's scope beyond what annotations provide. However, it doesn't address important behavioral aspects like the implications of the destructiveHint=true annotation (what gets destroyed), authentication requirements, rate limits, or error handling. 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. It avoids unnecessary words and gets straight to the point. However, it could be slightly more structured by separating the different action types or providing a brief example of typical use cases.

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 (8 parameters with nested objects, multiple actions via enum, destructive operations), the description is somewhat incomplete. While annotations provide safety hints and the schema documents parameters well, the description doesn't explain the multi-action nature (list/get/create/update/delete/publish), output format expectations, or error scenarios. The absence of an output schema increases the need for more descriptive context.

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?

With 100% schema description coverage, the input schema comprehensively documents all 8 parameters including their types, descriptions, and constraints. The description adds minimal value by hinting at the settings structure (encryption, content marking) but doesn't provide additional semantic context beyond what's already in the schema. The baseline score of 3 is appropriate given the excellent 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 tool's purpose as managing sensitivity labels for information protection, specifying key functionalities like encryption, content marking, and classification policies. It uses specific verbs ('manage') and resources ('sensitivity labels'), but doesn't explicitly differentiate from sibling tools like 'manage_information_protection_policies' or 'manage_dlp_policies' that might handle related aspects.

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 prerequisites, context for choosing specific actions, or how it relates to sibling tools like 'manage_information_protection_policies' or 'manage_dlp_policies' that might overlap in information protection domains.

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