tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > MCP Protocol > MCP Server with Cloud Tasks - Async Job Processing

MCP Server with Cloud Tasks - Async Job Processing

Author: Venkata Sudhakar

Cloud Tasks is a fully managed service for asynchronous task execution. When an AI agent needs to trigger a long-running operation - such as generating a bulk report, sending a batch of emails, or processing an uploaded file - it should not block waiting for completion. Cloud Tasks lets the agent dispatch the job and move on immediately.

ShopMax India uses Cloud Tasks to handle background jobs like bulk invoice generation, stock replenishment notifications, and nightly data exports. The MCP server below gives ADK agents two tools - one to enqueue a job and another to check its status via a tracking record in Firestore.

The below example shows an MCP server that enqueues background jobs via Cloud Tasks and tracks their status, allowing agents to dispatch and monitor async work.


It gives the following output,

# Agent query: "Generate bulk invoices for all Delhi orders in March"
Tool: enqueue_job({job_type: "bulk_invoice", payload: {city: "Delhi", month: "2026-03"}})

Job enqueued. ID: f3a9c2d1-8b44-4e71-a901-cc12f5e8ab90

# Agent query: "Check status of job f3a9c2d1"
Tool: check_job_status({job_id: "f3a9c2d1-8b44-4e71-a901-cc12f5e8ab90"})

{"job_id": "f3a9c2d1-8b44-4e71-a901-cc12f5e8ab90", "job_type": "bulk_invoice",
 "status": "COMPLETED", "created_at": "2026-04-11T04:10:00",
 "completed_at": "2026-04-11T04:12:35", "records_processed": 1842}

For production use, set Cloud Tasks retry configuration with max attempts and backoff to handle transient worker failures. Use Cloud Tasks dispatch rate limits to prevent overwhelming downstream services. Store job results and errors in Firestore so agents can report outcomes to users. For sensitive payloads, use OIDC authentication on the HTTP target so only the Cloud Tasks service account can invoke the worker endpoint.


 
  


  
bl  br