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; error then carries a short reason.
Rows deleted from mcp_tool_calls past the 30-day retention window.
Stale mcp_session_machines presence rows deleted.
Expired per-session project defaults dropped (machine-local).
Abandoned in-flight work entries 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).
Work segments flushed to the database during the sweep.
Short failure reason; present only when ok is false.
Missing or invalid CRON_SECRET