Skip to main content
Glama
temurkhan13

silentwatch-mcp

by temurkhan13

find_silent_failures

Detect silent failures in scheduled jobs: exit code 0 but empty output, length anomalies, error keywords, or duration anomalies. Surfaces hidden issues in cron, systemd timers, and OpenClaw schedulers.

Instructions

Jobs that returned exit code 0 but output was flagged by silent-fail rules (empty output, length anomaly, error keywords, duration anomaly).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
window_hoursNoLookback window in hours (default 24)

Implementation Reference

  • Tool handler for 'find_silent_failures' — reads window_hours argument, fetches all jobs and their runs from the backend, then delegates to build_silent_failure_report() for aggregation.
    if name == "find_silent_failures":
        window_hours = int(arguments.get("window_hours", 24))
        jobs = await backend.list_jobs()
        runs_by_job: dict[str, list[Any]] = {}
        for j in jobs:
            runs_by_job[j.id] = await backend.get_job_runs(j.id, limit=200)
        report = build_silent_failure_report(jobs, runs_by_job, window_hours=window_hours)
        return _serialize(report)
  • Tool registration — declares the 'find_silent_failures' tool with its description and input schema (accepts optional window_hours integer).
    Tool(
        name="find_silent_failures",
        description=(
            "Jobs that returned exit code 0 but output was flagged by silent-fail "
            "rules (empty output, length anomaly, error keywords, duration anomaly)."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "window_hours": {
                    "type": "integer",
                    "description": "Lookback window in hours (default 24)",
                    "default": 24,
                }
            },
            "required": [],
        },
    ),
  • Core aggregation logic — build_silent_failure_report() filters runs within the window, identifies silent failures via is_silent_failure(), deduplicates indicators, and produces a SilentFailureReport.
    def build_silent_failure_report(
        jobs: list[CronJob],
        runs_by_job: dict[str, list[CronRun]],
        window_hours: int = 24,
    ) -> SilentFailureReport:
        """Aggregate silent failures across all jobs within a window."""
        cutoff = datetime.now(UTC) - timedelta(hours=window_hours)
        flagged: list[SilentFailureFlag] = []
    
        for job in jobs:
            runs = runs_by_job.get(job.id, [])
            in_window = [r for r in runs if r.started_at >= cutoff]
            silent = [r for r in in_window if is_silent_failure(r)]
            if not silent:
                continue
    
            # Deduplicate indicators across silent runs
            indicators_seen: set[SilentFailIndicator] = set()
            for r in silent:
                indicators_seen.update(r.silent_fail_indicators)
    
            flagged.append(
                SilentFailureFlag(
                    job_id=job.id,
                    job_name=job.name,
                    silent_fail_count=len(silent),
                    total_runs=len(in_window),
                    silent_fail_rate=len(silent) / len(in_window) if in_window else 0.0,
                    indicators=sorted(indicators_seen, key=lambda i: i.value),
                    sample_run_ids=[r.run_id for r in silent[:5]],
                )
            )
    
        return SilentFailureReport(
            window_hours=window_hours,
            jobs_flagged=flagged,
            total_jobs_checked=len(jobs),
        )
  • Helper — detect_silent_fail_indicators() checks a single run (exit_code==0) for empty output, error keywords in stdout, output length anomaly, and duration anomaly against historical runs.
    def detect_silent_fail_indicators(
        run: CronRun,
        historical_runs: list[CronRun] | None = None,
    ) -> list[SilentFailIndicator]:
        """Return all silent-fail indicators that fire for this run.
    
        A run is a silent failure candidate only if exit_code == 0; if exit_code != 0
        it's an explicit failure, not silent.
        """
        if run.exit_code != 0:
            return []
    
        indicators: list[SilentFailIndicator] = []
        output = run.output_snippet or ""
    
        # Rule: output empty
        if not output.strip():
            indicators.append(SilentFailIndicator.OUTPUT_EMPTY)
    
        # Rule: error keywords in stdout despite exit 0
        if DEFAULT_ERROR_KEYWORDS.search(output):
            indicators.append(SilentFailIndicator.ERROR_KEYWORDS_IN_STDOUT)
    
        # Rule: output length anomaly (vs historical median)
        if historical_runs:
            successful_lengths = [
                len(r.output_snippet) for r in historical_runs
                if r.status == RunStatus.SUCCESS and r.output_snippet
            ]
            if len(successful_lengths) >= 5:
                baseline = median(successful_lengths)
                if baseline > 0 and len(output) < baseline * 0.3:
                    indicators.append(SilentFailIndicator.OUTPUT_LENGTH_ANOMALY)
    
        # Rule: duration anomaly (vs historical median)
        if historical_runs and run.duration_ms is not None:
            successful_durations = [
                r.duration_ms for r in historical_runs
                if r.status == RunStatus.SUCCESS and r.duration_ms is not None
            ]
            if len(successful_durations) >= 5:
                baseline_ms = median(successful_durations)
                if run.duration_ms < baseline_ms * 0.1:
                    indicators.append(SilentFailIndicator.DURATION_ANOMALY_SHORT)
    
        return indicators
  • Response schema for 'find_silent_failures' — SilentFailureReport contains window_hours, jobs_flagged list (SilentFailureFlag), and total_jobs_checked.
    class SilentFailureReport(BaseModel):
        """Response for `find_silent_failures`."""
    
        window_hours: int
        jobs_flagged: list[SilentFailureFlag]
        total_jobs_checked: int
Behavior2/5

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

No annotations provided; description only lists detection criteria. It does not disclose behavioral traits like read-only nature, prerequisites, or potential side effects.

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

Conciseness4/5

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

Single sentence efficiently conveys purpose but lists multiple anomaly types in a somewhat dense manner. No wasted words, but readability could improve.

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

Completeness2/5

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

Given one optional parameter and no output schema, the description lacks details on return format, pagination, or usage context. Incomplete for a search/filter tool.

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

Parameters3/5

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

Schema coverage is 100% with clear description for window_hours. The tool description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose4/5

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

The description clearly states it finds jobs with exit code 0 flagged by silent-fail rules, using specific verb and resource. However, it does not differentiate from siblings like find_overdue_jobs.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives. The description implies usage for detecting silent failures but lacks when-not or alternative tool references.

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