Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_distribution_lists

Destructive

Create, update, and manage Exchange distribution lists including members, settings, and email addresses for Microsoft 365 groups.

Instructions

Manage Exchange distribution lists including creation, updates, member management, and settings configuration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on distribution list
listIdNoDistribution list ID for existing list operations
displayNameNoDisplay name for the distribution list
emailAddressNoEmail address for the distribution list
membersNoList of member email addresses
settingsNoDistribution list settings

Implementation Reference

  • Core handler function implementing manage_distribution_lists tool logic using Microsoft Graph API for CRUD operations on distribution lists (mail-enabled non-security groups) and membership management.
    export async function handleDistributionLists(
      graphClient: Client,
      args: DistributionListArgs
    ): Promise<{ content: { type: string; text: string }[] }> {
      let apiPath = '';
      let result: any;
    
      switch (args.action) {
        case 'get':
          if (!args.listId) {
            throw new McpError(ErrorCode.InvalidParams, 'listId is required for get action');
          }
          apiPath = `/groups/${args.listId}`;
          result = await graphClient.api(apiPath).get();
          break;
    
        case 'create':
          if (!args.displayName || !args.emailAddress) {
            throw new McpError(ErrorCode.InvalidParams, 'displayName and emailAddress are required for create action');
          }
          apiPath = '/groups';
          const createPayload = {
            displayName: args.displayName,
            mailNickname: args.emailAddress.split('@')[0],
            mailEnabled: true,
            securityEnabled: false,
            groupTypes: [], // Empty for distribution lists
            mail: args.emailAddress
          };
          result = await graphClient.api(apiPath).post(createPayload);
          break;
    
        case 'update':
          if (!args.listId) {
            throw new McpError(ErrorCode.InvalidParams, 'listId is required for update action');
          }
          apiPath = `/groups/${args.listId}`;
          const updatePayload: any = {};
          if (args.displayName) updatePayload.displayName = args.displayName;
          result = await graphClient.api(apiPath).patch(updatePayload);
          break;
    
        case 'delete':
          if (!args.listId) {
            throw new McpError(ErrorCode.InvalidParams, 'listId is required for delete action');
          }
          apiPath = `/groups/${args.listId}`;
          await graphClient.api(apiPath).delete();
          result = { message: 'Distribution list deleted successfully' };
          break;
    
        case 'add_members':
          if (!args.listId || !args.members?.length) {
            throw new McpError(ErrorCode.InvalidParams, 'listId and members are required for add_members action');
          }
          
          for (const member of args.members) {
            await graphClient
              .api(`/groups/${args.listId}/members/$ref`)
              .post({
                '@odata.id': `https://graph.microsoft.com/v1.0/users/${member}`
              });
          }
          result = { message: `Added ${args.members.length} members to distribution list` };
          break;
    
        case 'remove_members':
          if (!args.listId || !args.members?.length) {
            throw new McpError(ErrorCode.InvalidParams, 'listId and members are required for remove_members action');
          }
          
          for (const member of args.members) {
            await graphClient
              .api(`/groups/${args.listId}/members/${member}/$ref`)
              .delete();
          }
          result = { message: `Removed ${args.members.length} members from distribution list` };
          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 for the manage_distribution_lists tool, used for validation and MCP tool discovery.
    export const distributionListSchema = z.object({
      action: z.enum(['get', 'create', 'update', 'delete', 'add_members', 'remove_members']).describe('Action to perform on distribution list'),
      listId: z.string().optional().describe('Distribution list ID for existing list operations'),
      displayName: z.string().optional().describe('Display name for the distribution list'),
      emailAddress: z.string().optional().describe('Email address for the distribution list'),
      members: z.array(z.string()).optional().describe('List of member email addresses'),
      settings: z.object({
        hideFromGAL: z.boolean().optional().describe('Hide from Global Address List'),
        requireSenderAuthentication: z.boolean().optional().describe('Require sender authentication'),
        moderatedBy: z.array(z.string()).optional().describe('List of moderator email addresses'),
      }).optional().describe('Distribution list settings'),
    });
  • src/server.ts:354-373 (registration)
    MCP server tool registration for manage_distribution_lists, linking schema, metadata, and handler function with error handling and lazy credential validation.
    const distributionListsMeta = getToolMetadata("manage_distribution_lists")!;
    this.server.tool(
      "manage_distribution_lists",
      distributionListsMeta.description,
      distributionListSchema.shape,
      distributionListsMeta.annotations || {},
      wrapToolHandler(async (args: DistributionListArgs) => {
        // Validate credentials only when tool is executed (lazy loading)
        this.validateCredentials();        try {
          return await handleDistributionLists(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 for the distribution lists handler.
    export interface DistributionListArgs {
      action: 'get' | 'create' | 'update' | 'delete' | 'add_members' | 'remove_members';
      listId?: string;
      displayName?: string;
      emailAddress?: string;
      members?: string[];
      settings?: {
        hideFromGAL?: boolean;
        requireSenderAuthentication?: boolean;
        moderatedBy?: string[];
      };
    }
  • Tool metadata providing description, title, and annotations (hints for UI/behavior) for the manage_distribution_lists tool.
    manage_distribution_lists: {
      description: "Manage Exchange distribution lists including creation, updates, member management, and settings configuration.",
      title: "Distribution List Manager",
      annotations: { title: "Distribution List 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 minimal behavioral context beyond annotations. Annotations already indicate destructiveHint=true (implying potential data loss), readOnlyHint=false (mutation allowed), openWorldHint=true (supports flexible operations), and idempotentHint=false (non-idempotent actions). The description mentions 'management' operations but doesn't elaborate on risks (e.g., deletion consequences), authentication needs, rate limits, or error handling. It doesn't contradict annotations, but with rich annotations, it could provide more practical insights like typical use cases or limitations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured: a single sentence that front-loads the core purpose ('Manage Exchange distribution lists') followed by a comma-separated list of key operations. Every word earns its place, with no redundancy or fluff, making it easy for an AI agent to parse quickly and understand the tool's scope efficiently.

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 (6 parameters, destructive operations, no output schema) and rich annotations, the description is minimally adequate but lacks depth. It covers the 'what' (operations) but not the 'how' or 'why'—missing details on output format, error cases, or integration with sibling tools. With annotations handling safety profiles, it avoids being incomplete, but for a multi-action tool with potential data impact, more context on usage patterns or examples would enhance completeness.

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?

The description doesn't add meaningful parameter semantics beyond the input schema. Schema description coverage is 100%, with clear descriptions for all 6 parameters (e.g., action enum values, listId for existing operations). The description generically mentions 'creation, updates, member management, and settings configuration,' which loosely maps to parameters like action, members, and settings, but doesn't clarify dependencies (e.g., listId required for updates but not creation) or usage nuances. Baseline 3 is appropriate given high 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: 'Manage Exchange distribution lists including creation, updates, member management, and settings configuration.' It specifies the resource (Exchange distribution lists) and enumerates key operations (creation, updates, member management, settings configuration), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'manage_m365_groups' or 'manage_security_groups', which might handle similar group management tasks in different contexts.

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 lists operations but doesn't specify prerequisites (e.g., requiring Exchange permissions), appropriate contexts (e.g., for email distribution vs. security groups), or exclusions (e.g., not for managing Microsoft 365 groups). Without such guidance, an AI agent might struggle to choose between this and sibling tools like 'manage_m365_groups' or 'manage_security_groups' in overlapping scenarios.

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