Skip to main content
Glama
temurkhan13

silentwatch-mcp

by temurkhan13

find_overdue_jobs

Identify scheduled jobs that missed their run time beyond a configurable grace period to detect silent failures in cron, systemd timers, and OpenClaw schedulers.

Instructions

Returns jobs whose schedule indicates they should have run but haven't, beyond a grace window.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
grace_minutesNoTolerance to avoid flagging jobs about to run (default 5)

Implementation Reference

  • Tool 'find_overdue_jobs' is registered as an MCP Tool with an optional 'grace_minutes' input schema (default 5).
    Tool(
        name="find_overdue_jobs",
        description=(
            "Returns jobs whose schedule indicates they should have run but "
            "haven't, beyond a grace window."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "grace_minutes": {
                    "type": "integer",
                    "description": "Tolerance to avoid flagging jobs about to run (default 5)",
                    "default": 5,
                }
            },
            "required": [],
        },
    ),
  • Handler for 'find_overdue_jobs' — lists all jobs from the backend and filters those with is_overdue=True, returning a JobListResponse.
    if name == "find_overdue_jobs":
        jobs = await backend.list_jobs()
        overdue = [j for j in jobs if j.is_overdue]
        response = JobListResponse(jobs=overdue, total=len(overdue))
        return _serialize(response)
  • CronJob model (used in JobListResponse) includes 'is_overdue' and 'overdue_by_minutes' fields that drive the overdue detection.
    class CronJob(BaseModel):
        """A scheduled cron job with summary state."""
    
        model_config = ConfigDict(frozen=True)
    
        id: str
        name: str
        schedule: str
        """Cron expression or schedule descriptor (e.g., '0 */1 * * *' or 'every 1h')."""
        last_run_at: datetime | None = None
        last_run_status: RunStatus | None = None
        last_success_at: datetime | None = None
        runs_24h: int = 0
        successes_24h: int = 0
        silent_fail_count_24h: int = 0
        is_overdue: bool = False
        overdue_by_minutes: int | None = None
        next_expected_run_at: datetime | None = None
        metadata: dict[str, str] = Field(default_factory=dict)
  • JobListResponse schema — the response type returned by find_overdue_jobs, containing a list of CronJob objects and a total count.
    class JobListResponse(BaseModel):
        """Response for `list_jobs` and `find_overdue_jobs`."""
    
        jobs: list[CronJob]
        total: int
  • compute_overdue_state — core logic that determines if a job is overdue by comparing its computed next run time (via croniter) against the current time with a grace window.
    def compute_overdue_state(
        schedule: str,
        last_run_at: datetime | None,
        grace_minutes: int = 5,
        now: datetime | None = None,
    ) -> tuple[bool, int | None, datetime | None]:
        """Compute overdue state from a cron schedule + last-run timestamp.
    
        Returns ``(is_overdue, overdue_by_minutes, next_expected_run_at)``.
    
        - **is_overdue:** True if `next_expected_run_at` is more than `grace_minutes` in the past.
        - **overdue_by_minutes:** integer minutes past expected run time, or None if not overdue.
        - **next_expected_run_at:** the cron-schedule's next firing time after last_run_at
          (or after `now - 1 day` if last_run_at is None — i.e., we don't know when it last ran).
    
        Returns ``(False, None, None)`` if the schedule string is empty, "unknown", or
        fails to parse — no schedule means we can't reason about overdue state.
        """
        if not schedule or schedule.lower() == "unknown":
            return (False, None, None)
    
        if now is None:
            now = datetime.now(UTC)
    
        # Use last_run_at as the base for next-run computation. If we don't know when it
        # last ran, fall back to "yesterday" — better than computing from now (which would
        # always say next-run is in the future, masking missing-run scenarios).
        base = last_run_at if last_run_at is not None else now - timedelta(days=1)
    
        try:
            iterator = croniter(schedule, base)
            next_run = iterator.get_next(datetime)
        except (CroniterBadCronError, ValueError) as exc:
            logger.warning("Invalid cron schedule %r: %s", schedule, exc)
            return (False, None, None)
    
        # croniter returns naive datetime by default — coerce to UTC for comparison
        if next_run.tzinfo is None:
            next_run = next_run.replace(tzinfo=UTC)
    
        grace = timedelta(minutes=grace_minutes)
        if next_run + grace < now:
            overdue_by = int((now - next_run).total_seconds() / 60)
            return (True, overdue_by, next_run)
    
        return (False, None, next_run)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the core behavior (returns overdue jobs) but does not mention whether the operation is read-only, performance implications, or pagination. Adequate but not thorough.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that is efficient and front-loaded with the core purpose, no redundant words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one optional parameter and no output schema, the description is largely complete. It could clarify what 'schedule indicates' means or the output format, but overall it provides sufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, the description adds value by explaining 'beyond a grace window' which directly connects to the grace_minutes parameter, providing context beyond the schema's technical description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns overdue jobs with a grace window, distinguishing it from siblings like find_silent_failures (different failure mode) and list_jobs (all jobs).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for checking missed jobs but lacks explicit when-to-use or when-not-to-use guidance, nor does it mention alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/temurkhan13/silentwatch-mcp'

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