Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

manage_graph_subscriptions

Destructive

Create, update, delete, or list webhook subscriptions to receive real-time notifications for changes in Microsoft Graph resources.

Instructions

Manage webhook subscriptions for real-time change notifications from Microsoft Graph resources.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesSubscription management action
subscriptionIdNoSubscription ID for update/delete operations
subscriptionNoSubscription details for create/update
updatesNoUpdates for existing subscription

Implementation Reference

  • Registers the manage_graph_subscriptions tool with inline handler logic that uses GraphAdvancedFeatures class methods based on the 'action' parameter (create, update, delete, list). Includes inline input schema.
    const graphSubscriptionsMeta = getToolMetadata("manage_graph_subscriptions")!;
    this.server.tool(
      "manage_graph_subscriptions",
      graphSubscriptionsMeta.description,
      z.object({
        action: z.enum(['create', 'update', 'delete', 'list']).describe('Subscription management action'),
        subscriptionId: z.string().optional().describe('Subscription ID for update/delete operations'),
        subscription: webhookSubscriptionSchema.optional().describe('Subscription details for create/update'),
        updates: webhookSubscriptionSchema.partial().optional().describe('Updates for existing subscription')
      }).shape,
      graphSubscriptionsMeta.annotations || {},
      wrapToolHandler(async (args: any) => {
        this.validateCredentials();
        try {
          const advancedFeatures = new GraphAdvancedFeatures(this.getGraphClient(), this.getAccessToken.bind(this));
          let result: any;
    
          switch (args.action) {
            case 'create':
              if (!args.subscription) {
                throw new McpError(ErrorCode.InvalidParams, 'Subscription details required for create action');
              }
              result = await advancedFeatures.createSubscription(args.subscription);
              break;
            case 'update':
              if (!args.subscriptionId || !args.updates) {
                throw new McpError(ErrorCode.InvalidParams, 'Subscription ID and updates required for update action');
              }
              result = await advancedFeatures.updateSubscription(args.subscriptionId, args.updates);
              break;
            case 'delete':
              if (!args.subscriptionId) {
                throw new McpError(ErrorCode.InvalidParams, 'Subscription ID required for delete action');
              }
              result = await advancedFeatures.deleteSubscription(args.subscriptionId);
              break;
            case 'list':
              result = await advancedFeatures.listSubscriptions();
              break;
            default:
              throw new McpError(ErrorCode.InvalidParams, `Invalid action: ${args.action}`);
          }
    
          return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
        } catch (error) {
          if (error instanceof McpError) {
            throw error;
          }
          throw new McpError(
            ErrorCode.InternalError,
            `Error managing subscriptions: ${error instanceof Error ? error.message : 'Unknown error'}`
          );
        }
      })
    );
  • Core handler methods in GraphAdvancedFeatures class for managing Microsoft Graph webhook subscriptions: createSubscription, updateSubscription, deleteSubscription, listSubscriptions. Called by the tool handler in server.ts.
    async createSubscription(subscription: WebhookSubscription): Promise<SubscriptionResponse> {
      const subscriptionPayload: any = {
        changeType: subscription.changeTypes.join(','),
        notificationUrl: subscription.notificationUrl,
        resource: subscription.resource,
        expirationDateTime: subscription.expirationDateTime || this.getDefaultExpiration(),
        clientState: subscription.clientState,
        latestSupportedTlsVersion: subscription.tlsVersion || 'v1_2'
      };
    
      // Add lifecycle notification URL if provided
      if (subscription.lifecycleNotificationUrl) {
        subscriptionPayload.lifecycleNotificationUrl = subscription.lifecycleNotificationUrl;
      }
    
      try {
        const response = await this.graphClient
          .api('/subscriptions')
          .post(subscriptionPayload);
    
        return {
          id: response.id,
          resource: response.resource,
          changeType: response.changeType,
          notificationUrl: response.notificationUrl,
          expirationDateTime: response.expirationDateTime,
          clientState: response.clientState,
          createdAt: new Date().toISOString()
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create subscription: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
    
    // Update existing subscription
    async updateSubscription(subscriptionId: string, updates: Partial<WebhookSubscription>): Promise<SubscriptionResponse> {
      const updatePayload: any = {};
    
      if (updates.expirationDateTime) {
        updatePayload.expirationDateTime = updates.expirationDateTime;
      }
    
      if (updates.notificationUrl) {
        updatePayload.notificationUrl = updates.notificationUrl;
      }
    
      try {
        const response = await this.graphClient
          .api(`/subscriptions/${subscriptionId}`)
          .patch(updatePayload);
    
        return {
          id: response.id,
          resource: response.resource,
          changeType: response.changeType,
          notificationUrl: response.notificationUrl,
          expirationDateTime: response.expirationDateTime,
          clientState: response.clientState,
          updatedAt: new Date().toISOString()
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to update subscription: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
    
    // Delete subscription
    async deleteSubscription(subscriptionId: string): Promise<{ deleted: boolean; deletedAt: string }> {
      try {
        await this.graphClient
          .api(`/subscriptions/${subscriptionId}`)
          .delete();
    
        return {
          deleted: true,
          deletedAt: new Date().toISOString()
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to delete subscription: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
    
    // List all subscriptions
    async listSubscriptions(): Promise<SubscriptionResponse[]> {
      try {
        const response = await this.graphClient
          .api('/subscriptions')
          .get();
    
        return response.value.map((sub: any) => ({
          id: sub.id,
          resource: sub.resource,
          changeType: sub.changeType,
          notificationUrl: sub.notificationUrl,
          expirationDateTime: sub.expirationDateTime,
          clientState: sub.clientState
        }));
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to list subscriptions: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • Zod schema for WebhookSubscription input parameters, used directly in the tool's inline schema (as subscription and updates).
    export const webhookSubscriptionSchema = z.object({
      resource: z.string().describe('Graph resource to monitor'),
      changeTypes: z.array(z.enum(['created', 'updated', 'deleted'])).describe('Types of changes to monitor'),
      notificationUrl: z.string().url().describe('Webhook endpoint URL'),
      expirationDateTime: z.string().optional().describe('Subscription expiration (ISO 8601)'),
      clientState: z.string().optional().describe('Client state for validation'),
      lifecycleNotificationUrl: z.string().url().optional().describe('Lifecycle notification URL'),
      tlsVersion: z.enum(['v1_0', 'v1_1', 'v1_2', 'v1_3']).optional().describe('Minimum TLS version')
    });
  • TypeScript interfaces for WebhookSubscription input and SubscriptionResponse output used by the subscription management methods.
    export interface WebhookSubscription {
      resource: string;
      changeTypes: ('created' | 'updated' | 'deleted')[];
      notificationUrl: string;
      expirationDateTime?: string;
      clientState?: string;
      lifecycleNotificationUrl?: string;
      tlsVersion?: 'v1_0' | 'v1_1' | 'v1_2' | 'v1_3';
    }
    
    export interface SubscriptionResponse {
      id: string;
      resource: string;
      changeType: string;
      notificationUrl: string;
      expirationDateTime: string;
      clientState?: string;
      createdAt?: string;
      updatedAt?: string;
    }
  • Tool metadata registration providing description, title, and annotations (readOnlyHint, destructiveHint, etc.) for the manage_graph_subscriptions tool, used during tool registration in server.ts.
    manage_graph_subscriptions: {
      description: "Manage webhook subscriptions for real-time change notifications from Microsoft Graph resources.",
      title: "Graph Subscription Manager",
      annotations: { title: "Graph Subscription 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 provide key behavioral hints: readOnlyHint=false, destructiveHint=true, openWorldHint=true, and idempotentHint=false. The description adds value by specifying 'real-time change notifications' and 'webhook subscriptions,' which clarifies the tool's focus on event-driven updates. However, it doesn't disclose additional traits like rate limits, error handling, or the impact of destructive operations (e.g., what happens when deleting a subscription). With annotations covering the safety profile, the description offers moderate context but lacks depth on operational behavior.

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 a single, well-structured sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the main action ('Manage webhook subscriptions') and includes key details ('real-time change notifications,' 'Microsoft Graph resources') that earn their place. There is no redundancy or fluff, making it highly concise and effective for quick understanding.

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 (4 parameters, nested objects, no output schema) and rich annotations, the description is adequate but incomplete. It covers the basic purpose but lacks details on return values, error conditions, or integration with sibling tools. The annotations provide behavioral context, but the description doesn't fully address the tool's role in the broader ecosystem or operational considerations, leaving gaps for an agent to infer usage in real-world 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%, with detailed descriptions for all parameters, including enums and required fields. The description adds no parameter-specific information beyond the schema, such as examples or usage notes. According to the rules, when schema coverage is high (>80%), the baseline score is 3 even without param details in the description. The description's general statement doesn't compensate or detract from the schema's thorough documentation.

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 webhook subscriptions for real-time change notifications from Microsoft Graph resources.' It specifies the verb ('manage'), resource ('webhook subscriptions'), and domain ('Microsoft Graph resources'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'manage_alerts' or 'search_audit_log' that might also involve notifications or monitoring, so it doesn't reach the highest score.

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, such as authentication requirements or permissions needed for Microsoft Graph, nor does it specify scenarios where this tool is preferred over other notification or management tools in the sibling list. Without any usage context or exclusions, the agent must infer when to invoke it based solely on the purpose statement.

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