cancel_sync
Stop a running data synchronization job in the Better Google Search Console MCP server to halt ongoing data downloads into the local SQLite database.
Instructions
Cancel a running sync job. The job will stop gracefully after completing the current API call.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobId | Yes | Job ID to cancel. |
Implementation Reference
- src/server.ts:445-463 (registration)Tool registration for 'cancel_sync' with the MCP server, including the handler function that calls syncManager.cancelJob() and returns the job status or error
server.tool( 'cancel_sync', 'Cancel a running sync job. The job will stop gracefully after completing the current API call.', { jobId: z.string().describe('Job ID to cancel.'), }, async (args) => { try { const cancelled = syncManager.cancelJob(args.jobId); if (cancelled) { const status = syncManager.getStatus(args.jobId); return { content: [{ type: 'text', text: JSON.stringify(status, null, 2) }] }; } return { content: [{ type: 'text', text: JSON.stringify({ error: `Job ${args.jobId} not found or already finished.` }) }], isError: true }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ error: (error as Error).message }) }], isError: true }; } } ); - src/core/SyncManager.ts:131-140 (handler)Core implementation of cancelJob() method that marks a job as cancelled by setting the cancelled flag and status, returns false if job doesn't exist or already finished
cancelJob(jobId: string): boolean { const job = this.jobs.get(jobId); if (!job) return false; if (job.status === 'completed' || job.status === 'failed' || job.status === 'cancelled') { return false; } job.cancelled = true; job.status = 'cancelled'; return true; } - src/server.ts:448-450 (schema)Input schema definition using Zod - expects jobId as a string parameter to identify which job to cancel
{ jobId: z.string().describe('Job ID to cancel.'), }, - src/core/SyncManager.ts:15-44 (schema)Type definitions for SyncJobStatus and SyncStatus interfaces that define the structure of job status data returned by cancel_sync
export type SyncJobStatus = 'queued' | 'syncing' | 'completed' | 'failed' | 'cancelled'; export interface SyncJobResult { siteUrl: string; status: 'completed' | 'failed' | 'skipped' | 'cancelled'; rowsFetched: number; rowsInserted: number; durationMs: number; error?: string; pruned?: { rowsDeleted: number; rowsAfter: number; spaceSavedMB: number; }; } export interface SyncStatus { jobId: string; status: SyncJobStatus; totalProperties: number; completedProperties: number; currentProperty: string | null; rowsFetched: number; estimatedTotalRows: number | null; apiCallsMade: number; startedAt: string; elapsedMs: number; results: SyncJobResult[]; error?: string; } - src/core/SyncManager.ts:46-65 (schema)SyncJob interface definition that includes the cancelled boolean flag and status field modified by the cancelJob method
interface SyncJob { id: string; status: SyncJobStatus; cancelled: boolean; properties: Array<{ siteUrl: string; startDate?: string; endDate?: string; dimensions?: string[]; searchType?: 'web' | 'discover' | 'googleNews' | 'image' | 'video'; }>; totalProperties: number; completedProperties: number; currentProperty: string | null; rowsFetched: number; estimatedTotalRows: number | null; apiCallsMade: number; startedAt: number; results: SyncJobResult[]; error?: string;