Skip to main content
Glama
houtini-ai

Better Google Search Console

by houtini-ai

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
NameRequiredDescriptionDefault
jobIdYesJob 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 };
        }
      }
    );
  • 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;
    }
  • 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.'),
    },
  • 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;
    }
  • 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;

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/houtini-ai/better-google-search-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server