Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_sharepoint_governance_policies

Destructive

Configure and enforce SharePoint governance policies for sharing controls, access restrictions, and site lifecycle management to maintain compliance and security.

Instructions

Manage SharePoint governance policies including sharing controls, access restrictions, and site lifecycle management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on SharePoint governance policy
policyTypeYesType of SharePoint governance policy
policyIdNoSharePoint governance policy ID for specific operations
displayNameNoDisplay name for the policy
descriptionNoDescription of the policy
scopeNoPolicy scope
settingsNoPolicy settings

Implementation Reference

  • The core handler function implementing the manage_sharepoint_governance_policies tool. Handles actions like list, get, create, update, delete for SharePoint governance policies using mapped Graph API endpoints for sharing, access, information barriers, and retention labels.
    export async function handleSharePointGovernancePolicies(
      graphClient: Client,
      args: SharePointGovernancePolicyArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      let apiPath = '';
      let result: any;
    
      // Map policy types to API endpoints
      const policyEndpoints = {
        sharingPolicy: '/admin/sharepoint/settings/sharing',
        accessPolicy: '/admin/sharepoint/settings/conditionalAccess',
        informationBarrier: '/admin/sharepoint/settings/informationBarriers',
        retentionLabel: '/admin/sharepoint/settings/retentionLabels'
      };
    
      const endpoint = policyEndpoints[args.policyType];
      if (!endpoint) {
        throw new McpError(ErrorCode.InvalidParams, `Unsupported policy type: ${args.policyType}`);
      }
    
      switch (args.action) {
        case 'list':
          apiPath = endpoint;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'get':
          if (!args.policyId) {
            throw new McpError(ErrorCode.InvalidParams, 'policyId is required for get action');
          }
          apiPath = `${endpoint}/${args.policyId}`;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'create':
          if (!args.displayName) {
            throw new McpError(ErrorCode.InvalidParams, 'displayName is required for create action');
          }
          
          const spPolicyPayload: any = {
            displayName: args.displayName,
            description: args.description || '',
            scope: args.scope || {},
            settings: args.settings || {}
          };
    
          apiPath = endpoint;
          result = await graphClient.api(apiPath).post(spPolicyPayload);
          break;
    
        case 'update':
          if (!args.policyId) {
            throw new McpError(ErrorCode.InvalidParams, 'policyId is required for update action');
          }
    
          const updatePayload: any = {};
          if (args.displayName) updatePayload.displayName = args.displayName;
          if (args.description) updatePayload.description = args.description;
          if (args.scope) updatePayload.scope = args.scope;
          if (args.settings) updatePayload.settings = args.settings;
    
          apiPath = `${endpoint}/${args.policyId}`;
          result = await graphClient.api(apiPath).patch(updatePayload);
          break;
    
        case 'delete':
          if (!args.policyId) {
            throw new McpError(ErrorCode.InvalidParams, 'policyId is required for delete action');
          }
          apiPath = `${endpoint}/${args.policyId}`;
          await graphClient.api(apiPath).delete();
          result = { message: `SharePoint ${args.policyType} policy ${args.policyId} deleted successfully` };
          break;
    
        default:
          throw new McpError(ErrorCode.InvalidParams, `Unknown action: ${args.action}`);
      }
    
      return {
        content: [{
          type: 'text',
          text: `SharePoint ${args.policyType} Policy ${args.action} operation completed:\n\n${JSON.stringify(result, null, 2)}`
        }]
      };
  • Zod schema defining input validation for the tool, including action, policyType (sharingPolicy, accessPolicy, etc.), policyId, displayName, scope, and detailed settings.
    export const sharePointGovernancePolicyArgsSchema = z.object({
      action: z.enum(['list', 'get', 'create', 'update', 'delete']).describe('Action to perform on SharePoint governance policy'),
      policyType: z.enum(['sharingPolicy', 'accessPolicy', 'informationBarrier', 'retentionLabel']).describe('Type of SharePoint governance policy'),
      policyId: z.string().optional().describe('SharePoint governance policy ID for specific operations'),
      displayName: z.string().optional().describe('Display name for the policy'),
      description: z.string().optional().describe('Description of the policy'),
      scope: z.object({
        sites: z.array(z.string()).optional().describe('Sites the policy applies to'),
        siteCollections: z.array(z.string()).optional().describe('Site collections the policy applies to'),
        webApplications: z.array(z.string()).optional().describe('Web applications the policy applies to'),
      }).optional().describe('Policy scope'),
      settings: z.object({
        sharingCapability: z.enum(['Disabled', 'ExternalUserSharingOnly', 'ExternalUserAndGuestSharing', 'ExistingExternalUserSharingOnly']).optional().describe('Sharing capability'),
        requireAcceptanceForExternalUsers: z.boolean().optional().describe('Require acceptance for external users'),
        requireAnonymousLinksExpireInDays: z.number().optional().describe('Anonymous links expiration in days'),
        fileAnonymousLinkType: z.enum(['None', 'View', 'Edit']).optional().describe('File anonymous link type'),
        folderAnonymousLinkType: z.enum(['None', 'View', 'Edit']).optional().describe('Folder anonymous link type'),
        defaultSharingLinkType: z.enum(['None', 'Direct', 'Internal', 'AnonymousAccess']).optional().describe('Default sharing link type'),
        preventExternalUsersFromResharing: z.boolean().optional().describe('Prevent external users from resharing'),
        conditionalAccessPolicy: z.enum(['AllowFullAccess', 'AllowLimitedAccess', 'BlockAccess']).optional().describe('Conditional access policy'),
        limitedAccessFileType: z.enum(['OfficeOnlineFilesOnly', 'WebPreviewableFiles', 'OtherFiles']).optional().describe('Limited access file type'),
        allowDownload: z.boolean().optional().describe('Allow download'),
        allowPrint: z.boolean().optional().describe('Allow print'),
        allowCopy: z.boolean().optional().describe('Allow copy'),
        informationBarrierMode: z.enum(['Open', 'Owner', 'Members', 'Explicit']).optional().describe('Information barrier mode'),
        retentionLabels: z.array(z.object({
          labelId: z.string().describe('Retention label ID'),
          isDefault: z.boolean().describe('Is default label'),
          autoApply: z.boolean().optional().describe('Auto-apply label'),
        })).optional().describe('Retention labels'),
      }).optional().describe('Policy settings'),
    });
  • Registers the tool with the MCP server using server.tool(), providing the tool name, description, input schema shape, annotations, and wrapped handler function that calls handleSharePointGovernancePolicies.
    // SharePoint Governance Policy Management - Lazy loading enabled for tool discovery
    this.server.tool(
      "manage_sharepoint_governance_policies",
      "Manage SharePoint governance policies including sharing controls, access restrictions, and site lifecycle management.",
      sharePointGovernancePolicyArgsSchema.shape,
      {"readOnlyHint":false,"destructiveHint":true,"idempotentHint":false},
      wrapToolHandler(async (args: SharePointGovernancePolicyArgs) => {
        this.validateCredentials();
        try {
          return await handleSharePointGovernancePolicies(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'}`
          );
        }
      })
    );
  • TypeScript interface defining the structure of arguments passed to the handler, matching the Zod schema.
    export interface SharePointGovernancePolicyArgs {
      action: 'list' | 'get' | 'create' | 'update' | 'delete';
      policyType: 'sharingPolicy' | 'accessPolicy' | 'informationBarrier' | 'retentionLabel';
      policyId?: string;
      displayName?: string;
      description?: string;
      scope?: {
        sites?: string[];
        siteCollections?: string[];
        webApplications?: string[];
      };
      settings?: {
        // Sharing Policy settings
        sharingCapability?: 'Disabled' | 'ExternalUserSharingOnly' | 'ExternalUserAndGuestSharing' | 'ExistingExternalUserSharingOnly';
        requireAcceptanceForExternalUsers?: boolean;
        requireAnonymousLinksExpireInDays?: number;
        fileAnonymousLinkType?: 'None' | 'View' | 'Edit';
        folderAnonymousLinkType?: 'None' | 'View' | 'Edit';
        defaultSharingLinkType?: 'None' | 'Direct' | 'Internal' | 'AnonymousAccess';
        preventExternalUsersFromResharing?: boolean;
        
        // Access Policy settings
        conditionalAccessPolicy?: 'AllowFullAccess' | 'AllowLimitedAccess' | 'BlockAccess';
        limitedAccessFileType?: 'OfficeOnlineFilesOnly' | 'WebPreviewableFiles' | 'OtherFiles';
        allowDownload?: boolean;
        allowPrint?: boolean;
        allowCopy?: boolean;
        
        // Information Barrier settings
        informationBarrierMode?: 'Open' | 'Owner' | 'Members' | 'Explicit';
        
        // Retention Label settings
        retentionLabels?: {
          labelId: string;
          isDefault: boolean;
          autoApply?: boolean;
        }[];
      };
    }
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, and idempotentHint=false. The description adds some context by mentioning the types of policies managed (sharing controls, access restrictions, site lifecycle management), which helps clarify what 'destructive' might mean in this context. However, it doesn't provide additional behavioral details like authentication requirements, rate limits, or specific destructive consequences beyond what annotations indicate.

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 wastes no words and directly communicates what the tool does. However, for such a complex tool with many parameters and destructive potential, the extreme brevity might be insufficient despite being structurally sound.

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?

For a complex, destructive tool with 7 parameters, nested objects, no output schema, and multiple policy types, the description is inadequate. It doesn't explain the relationship between action and other parameters, doesn't clarify what 'manage' entails across different policy types, and provides no information about return values or error conditions. The annotations help but don't compensate for the description's lack of operational 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?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly. The description mentions policy types (sharing controls, access restrictions) that align with the policyType enum values, but adds no meaningful parameter semantics beyond what the schema provides. The baseline score of 3 reflects adequate coverage through the schema alone.

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 SharePoint governance policies with specific examples (sharing controls, access restrictions, site lifecycle management). It distinguishes itself from siblings like manage_sharepoint_sites or manage_sharepoint_lists by focusing on governance policies rather than site/list operations. However, it doesn't explicitly differentiate from other policy management tools like manage_conditional_access_policies or manage_retention_policies.

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, required permissions, or when to choose this over other policy management tools. The agent must infer usage from the tool name and description alone, which is insufficient for a complex governance tool.

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