MCP housekeeping sweep (GET)
const url = 'https://example.com/api/cron/mcp-retention-sweep';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://example.com/api/cron/mcp-retention-sweepRuns the MCP layer’s retention sweeps: the 30-day mcp_tool_calls delete, stale
presence rows, expired session defaults, and the process-local in-flight / agent /
worker session maps. Replaces the process-local 60-second timer that lived in the
deleted mcp-transport.ts session layer.
Safe to run repeatedly and safe to miss — every sweep is a bounded delete against an
age cutoff, never a state transition. Protected by CRON_SECRET via the x-cron-secret
header only.
Responses
Section titled “ Responses ”Per-sweep deleted / swept counters
object
False when the sweep threw OR any DB clause errored (see failed_clauses); error carries a short reason only on the throw path.
Rows deleted from mcp_tool_calls past the 30-day retention window.
Rows deleted from oauth_token_events past the 30-day retention window.
Stale mcp_session_machines presence rows deleted.
Presence rows transitioned ‘connected’ -> ‘disconnected’ after 60 minutes of silence (HO-9101). These are marked, not deleted; the 24h clause deletes them later.
Expired per-session project defaults dropped (machine-local).
Stale agent sessions dropped from the in-process map (machine-local).
Stale agent-worker sessions pruned (machine-local).
Expired presence write-throttle entries dropped (machine-local).
Dangling work intervals finalized and written to project_agent_work_segments (fleet-wide since HO-9075).
Expired mcp_idempotency_cache rows deleted.
Names of DB sweep clauses that errored this pass (HO-9102). Empty is the only clean value - every count above is legitimately 0 on a healthy run. A non-empty list is returned with ok: false and HTTP 500.
Short failure reason; present only when ok is false.
Missing or invalid CRON_SECRET