Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_sharepoint_sites

Destructive

Create, configure, and manage SharePoint sites with permissions, settings, and user administration for team collaboration and document storage.

Instructions

Manage SharePoint sites including creation, configuration, permissions, and site collection administration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on SharePoint site
siteIdNoSharePoint site ID for existing site operations
urlNoURL for the SharePoint site
titleNoTitle for the SharePoint site
descriptionNoDescription of the SharePoint site
templateNoWeb template ID for site creation (e.g., STS#3 for Modern Team Site)
ownersNoList of owner email addresses
membersNoList of member email addresses
settingsNoSite configuration settings

Implementation Reference

  • Core handler function implementing SharePoint site management logic: get, list, search sites; retrieve permissions, drives, subsites; limited update support.
    export async function handleSharePointSite(
      graphClient: Client,
      args: SharePointSiteArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      switch (args.action) {
        case 'get': {
          let apiPath = '';
          
          if (args.siteId) {
            // Get specific site by ID
            apiPath = `/sites/${args.siteId}`;
          } else if (args.url) {
            // Get site by URL (hostname:path format)
            const urlParts = args.url.replace('https://', '').split('/');
            const hostname = urlParts[0];
            const sitePath = urlParts.slice(1).join('/') || 'sites/root';
            apiPath = `/sites/${hostname}:/${sitePath}`;
          } else {
            throw new McpError(ErrorCode.InvalidParams, 'Either siteId or url is required for get action');
          }
          
          const site = await graphClient.api(apiPath).get();
          return { content: [{ type: 'text', text: JSON.stringify(site, null, 2) }] };
        }
        
        case 'list': {
          // List all sites in the organization
          const sites = await graphClient
            .api('/sites?search=*')
            .get();
          return { content: [{ type: 'text', text: JSON.stringify(sites, null, 2) }] };
        }
        
        case 'search': {
          if (!args.title) {
            throw new McpError(ErrorCode.InvalidParams, 'title (search query) is required for search action');
          }
          
          const sites = await graphClient
            .api(`/sites?search=${encodeURIComponent(args.title)}`)
            .get();
          return { content: [{ type: 'text', text: JSON.stringify(sites, null, 2) }] };
        }
        
        case 'create': {
          // Note: Direct site creation via Graph API is limited
          // This creates a communication site via SharePoint REST API
          throw new McpError(
            ErrorCode.InvalidParams, 
            'Direct site creation is not supported via Graph API. Use SharePoint admin center or PowerShell for site creation. You can use the "get" action to retrieve existing sites.'
          );
        }
        
        case 'update': {
          if (!args.siteId) {
            throw new McpError(ErrorCode.InvalidParams, 'siteId is required for update action');
          }
          
          const updatePayload: any = {};
          if (args.title) updatePayload.displayName = args.title;
          if (args.description) updatePayload.description = args.description;
          
          // Update site properties (limited to displayName and description)
          const result = await graphClient
            .api(`/sites/${args.siteId}`)
            .patch(updatePayload);
          
          return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
        }
        
        case 'delete': {
          throw new McpError(
            ErrorCode.InvalidParams, 
            'Site deletion is not supported via Graph API. Use SharePoint admin center or PowerShell for site deletion.'
          );
        }
        
        case 'get_permissions': {
          if (!args.siteId) {
            throw new McpError(ErrorCode.InvalidParams, 'siteId is required for get_permissions action');
          }
          
          const permissions = await graphClient
            .api(`/sites/${args.siteId}/permissions`)
            .get();
          return { content: [{ type: 'text', text: JSON.stringify(permissions, null, 2) }] };
        }
        
        case 'get_drives': {
          if (!args.siteId) {
            throw new McpError(ErrorCode.InvalidParams, 'siteId is required for get_drives action');
          }
          
          const drives = await graphClient
            .api(`/sites/${args.siteId}/drives`)
            .get();
          return { content: [{ type: 'text', text: JSON.stringify(drives, null, 2) }] };
        }
        
        case 'get_subsites': {
          if (!args.siteId) {
            throw new McpError(ErrorCode.InvalidParams, 'siteId is required for get_subsites action');
          }
          
          const subsites = await graphClient
            .api(`/sites/${args.siteId}/sites`)
            .get();
          return { content: [{ type: 'text', text: JSON.stringify(subsites, null, 2) }] };
        }
        
        default:
          throw new McpError(ErrorCode.InvalidParams, `Invalid action: ${args.action}`);
      }
    }
  • src/server.ts:478-498 (registration)
    MCP tool registration for 'manage_sharepoint_sites', linking schema to handleSharePointSite handler with annotations.
    this.server.tool(
      "manage_sharepoint_sites",
      "Manage SharePoint sites including creation, configuration, permissions, and site collection administration.",
      sharePointSiteSchema.shape,
      {"readOnlyHint":false,"destructiveHint":true,"idempotentHint":false},
      wrapToolHandler(async (args: SharePointSiteArgs) => {
        // Validate credentials only when tool is executed (lazy loading)
        this.validateCredentials();
        try {
          return await handleSharePointSite(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'}`
          );
        }
      })
    );    // SharePoint Lists - Lazy loading enabled for tool discovery
  • Zod input schema defining parameters for manage_sharepoint_sites tool (action, siteId/url, title, etc.).
    export const sharePointSiteSchema = z.object({
      action: z.enum(['get', 'create', 'update', 'delete', 'add_users', 'remove_users']).describe('Action to perform on SharePoint site'),
      siteId: z.string().optional().describe('SharePoint site ID for existing site operations'),
      url: z.string().optional().describe('URL for the SharePoint site'),
      title: z.string().optional().describe('Title for the SharePoint site'),
      description: z.string().optional().describe('Description of the SharePoint site'),
      template: z.string().optional().describe('Web template ID for site creation (e.g., STS#3 for Modern Team Site)'),
      owners: z.array(z.string()).optional().describe('List of owner email addresses'),
      members: z.array(z.string()).optional().describe('List of member email addresses'),
      settings: z.object({
        isPublic: z.boolean().optional().describe('Whether the site is public'),
        allowSharing: z.boolean().optional().describe('Allow external sharing'),
        storageQuota: z.number().optional().describe('Storage quota in MB'),
      }).optional().describe('Site configuration settings'),
    });
  • TypeScript interface defining the argument shape for SharePoint site operations, used by handler.
    export interface SharePointSiteArgs {
      action: 'get' | 'list' | 'search' | 'create' | 'update' | 'delete' | 'add_users' | 'remove_users' | 'get_permissions' | 'get_drives' | 'get_subsites';
      siteId?: string;
      url?: string;
      title?: string;
      description?: string;
      template?: string;
      owners?: string[];
      members?: string[];
      settings?: {
        isPublic?: boolean;
        allowSharing?: boolean;
        storageQuota?: number;
      };
    }
  • Tool metadata providing description, title, and annotations for 'manage_sharepoint_sites' used in MCP discovery.
    manage_sharepoint_sites: {
      description: "Manage SharePoint sites including creation, configuration, permissions, and site collection administration.",
      title: "SharePoint Site Manager",
      annotations: { title: "SharePoint Site 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 about the scope of management (creation, configuration, permissions, administration), which helps clarify what 'manage' entails beyond the annotations, but doesn't detail rate limits, authentication needs, or specific behavioral traits like error handling.

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 key information ('Manage SharePoint sites') and lists core functionalities. It avoids redundancy and waste, though it could be slightly more structured by separating actions for clarity.

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?

For a tool with 9 parameters, destructive annotations, and no output schema, the description is adequate but minimal. It covers the high-level purpose and scope, but lacks details on return values, error cases, or operational constraints that would help an agent use it effectively in complex scenarios.

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 fully documents all 9 parameters. The description mentions general aspects like 'creation, configuration, permissions' which loosely map to parameters like action, settings, and owners/members, but adds no specific syntax, format, or usage details beyond what the schema provides, meeting the baseline for high 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: 'Manage SharePoint sites including creation, configuration, permissions, and site collection administration.' It specifies the resource (SharePoint sites) and key actions (creation, configuration, permissions, administration), though it doesn't explicitly differentiate from sibling tools like 'manage_sharepoint_lists' or 'manage_sharepoint_governance_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, appropriate contexts, or exclusions, leaving the agent to infer usage from the action parameter alone without sibling tool differentiation.

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