execute_delta_query
Track incremental changes to Microsoft Graph resources for efficient synchronization by using delta queries with tokens.
Instructions
Track incremental changes to Microsoft Graph resources using delta queries for efficient synchronization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource | Yes | Graph resource path (e.g., /users, /groups) | |
| deltaToken | No | Delta token from previous query |
Implementation Reference
- Core handler function that executes delta queries against Microsoft Graph resources, appending /delta to paths, handling deltaTokens, and parsing responses for tokens, links, and changes.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'}` ); } }
- Zod input schema for validating parameters to the execute_delta_query tool.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') });
- src/tool-metadata.ts:213-217 (registration)Tool metadata registration defining the execute_delta_query tool's description, title, and behavioral annotations.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 } },
- TypeScript interface defining the structure of the response returned by delta queries.export interface DeltaQueryResponse { value: any[]; deltaToken: string; deltaLink?: string; nextLink?: string; hasMoreChanges: boolean; changeCount: number; queriedAt: string; }