Skip to main content
Glama
DynamicEndpoints

Microsoft 365 Core MCP Server

execute_delta_query

Read-onlyIdempotent

Track incremental changes to Microsoft Graph resources for efficient synchronization using delta queries.

Instructions

Track incremental changes to Microsoft Graph resources using delta queries for efficient synchronization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourceYesGraph resource path (e.g., /users, /groups)
deltaTokenNoDelta token from previous query

Implementation Reference

  • Core handler function executeDeltaQuery that performs Microsoft Graph delta queries, handles delta tokens, extracts response metadata, and returns formatted DeltaQueryResponse.
    async executeDeltaQuery(resource: string, deltaToken?: string): Promise<DeltaQueryResponse> {
      let apiPath = resource;
      
      // Add delta function to the path
      if (!apiPath.includes('/delta')) {
        apiPath = apiPath.endsWith('/') ? `${apiPath}delta` : `${apiPath}/delta`;
      }
    
      try {
        let request = this.graphClient.api(apiPath);
    
        // If we have a delta token, use it to get only changes since last query
        if (deltaToken) {
          request = request.query({ $deltatoken: deltaToken });
        }
    
        const response = await request.get();
    
        // Extract delta link and delta token from response
        const deltaLink = response['@odata.deltaLink'];
        const nextLink = response['@odata.nextLink'];
        
        let extractedDeltaToken = '';
        if (deltaLink) {
          const tokenMatch = deltaLink.match(/\$deltatoken=([^&]+)/);
          extractedDeltaToken = tokenMatch ? decodeURIComponent(tokenMatch[1]) : '';
        }
    
        return {
          value: response.value || [],
          deltaToken: extractedDeltaToken,
          deltaLink: deltaLink,
          nextLink: nextLink,
          hasMoreChanges: !!nextLink,
          changeCount: response.value ? response.value.length : 0,
          queriedAt: new Date().toISOString()
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Delta query failed: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
  • Registers the execute_delta_query tool on the MCP server, using deltaQuerySchema for input validation, instantiates GraphAdvancedFeatures class, and calls executeDeltaQuery method with parsed arguments.
    this.server.tool(
      "execute_delta_query",
      "Track incremental changes to Microsoft Graph resources using delta queries for efficient synchronization.",
      deltaQuerySchema.shape,
      {"readOnlyHint":true,"destructiveHint":false,"idempotentHint":true},
      wrapToolHandler(async (args: any) => {
        this.validateCredentials();
        try {
          const advancedFeatures = new GraphAdvancedFeatures(this.getGraphClient(), this.getAccessToken.bind(this));
          const result = await advancedFeatures.executeDeltaQuery(args.resource, args.deltaToken);
          return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
        } catch (error) {
          if (error instanceof McpError) {
            throw error;
          }
          throw new McpError(
            ErrorCode.InternalError,
            `Error executing delta query: ${error instanceof Error ? error.message : 'Unknown error'}`
          );
        }
      })
    );
  • Zod input schema defining 'resource' (required string: Graph endpoint) and 'deltaToken' (optional string from previous query). Used for tool parameter validation.
    export const deltaQuerySchema = z.object({
      resource: z.string().describe('Graph resource path (e.g., /users, /groups)'),
      deltaToken: z.string().optional().describe('Delta token from previous query')
    });
  • Tool metadata providing description, title, and annotations (readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true) for the execute_delta_query tool.
    execute_delta_query: {
      description: "Track incremental changes to Microsoft Graph resources using delta queries for efficient synchronization.",
      title: "Graph Delta Query",
      annotations: { title: "Graph Delta Query", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
    },
Behavior3/5

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

Annotations already provide readOnlyHint=true, idempotentHint=true, and destructiveHint=false, indicating a safe, repeatable operation. The description adds value by specifying the tool's purpose for 'tracking incremental changes' and 'efficient synchronization,' which gives context beyond annotations, but does not detail behavioral aspects like rate limits, authentication needs, or 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.

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 tool's purpose, method, and benefit without any redundant or unnecessary information. It is front-loaded with key information and uses precise language.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity, rich annotations, and full schema coverage, the description is largely complete for its purpose. However, the absence of an output schema means the description could benefit from mentioning return values or pagination behavior, leaving a minor gap in contextual information.

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 clear descriptions for both parameters ('resource' and 'deltaToken'). The description mentions 'delta queries' which aligns with the deltaToken parameter, adding some semantic context, but does not provide additional details beyond what the schema already covers, such as examples or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('track incremental changes'), the resource ('Microsoft Graph resources'), and the method ('using delta queries'), with explicit mention of the benefit ('for efficient synchronization'). It distinguishes this tool from siblings by focusing on delta query functionality rather than batch operations, searches, or management tasks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context for 'efficient synchronization' scenarios, suggesting when to use this tool for tracking changes over time. However, it does not explicitly state when not to use it or name specific alternatives among the sibling tools, such as 'execute_graph_search' for non-incremental queries.

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