🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

ark-self-recon

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ark-self-recon

Runtime self-diagnostic scanner for ark-* MCP servers — auto-detects cacache vs JSON/JSONL state, scores health, surfaces actionable warnings

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

ark-self-recon — runtime self-diagnostic for MCP servers

Self-recon: a health-check function that tells you whether your MCP server's state is healthy, degraded, or critical — cacache or JSONL, single call.

Why

The problem. MCP servers store state in cacache caches, JSONL files, and WAL journals. Over hours or days, caches go stale, WAL files accumulate uncheckpointed writes, and orphan files drift in without being flagged. There is no built-in health check for any of it — operators discover degraded state only when something breaks.

Why now. As the ark-* MCP fleet grows and state stores multiply, manual inspection doesn't scale. A single selfRecon() call replaces ad-hoc checks with a scored, actionable report — making per-server health as routine as a heartbeat.

What it does. Zero-config scan that detects state type (cacache vs JSONL), measures freshness against configurable TTL, and returns a scored report with warnings. Drop it into any MCP server for an instant diagnostic endpoint.

Who it's for

  • MCP server maintainers — add a self-recon tool to any server with one import
  • Platform operators — fleet health checks across multiple MCP servers
  • AI agent evaluators — verify tool state health before or after invocation

Standalone use case: point it at any cacache directory or JSONL state folder — no ark-* server required.

Quick Start

npm install ark-self-recon
import { selfRecon } from "ark-self-recon";

const report = await selfRecon("/path/to/state");
console.log(report.health.score);     // 0-100
console.log(report.health.status);    // "good" | "degraded" | "critical"
console.log(report.health.warnings);  // string[]

Use case — JSONL state-store with WAL detection (operator role):

const report = await selfRecon("/path/to/jsonl-dir", { kind: "state-store" });
console.log(report.snapshot.walPending);  // uncheckpointed journal count

Developer persona — raw scan (no scoring) for custom health logic, easy adoption into existing tooling:

import { scan, scanCache, scanStateDir } from "ark-self-recon/core";
const snapshot = await scanCache("/path/to/cacache");
console.log(snapshot.staleRatio, snapshot.avgFreshnessS);

Architecture

Two-phase pipeline — call selfRecon(dir) or compose the stages yourself:

  selfRecon(dir)
    ├── detectTarget(dir) → { type, path }
    ├── scan[Cache|StateDir](path) → snapshot
    └── score[Health|StateDir](snapshot) → health
  • scan: reads cacache entries via stream (no full load into memory), or walks JSON/JSONL files detecting .journal WAL signals
  • score: weighs entries against staleness TTL (default 7d), flags orphan files, returns 0-100 score with typed warnings

Configuration

ParamTypeDefaultDescription
kind"cache" | "state-store""cache"Forces state-store mode for JSONL/WAL directories
stalenessMsnumber604800000 (7d)TTL for cacache staleness detection
walThresholdnumber5Pending WAL files before warning
expectedstring[][]Expected state files (orphan detection)

Export surface

Import pathContents
ark-self-reconCurated top-level: selfRecon, scanCache, scoreHealth
ark-self-recon/coreFull API: scan, scanCache, scanStateDir, detectTarget, scoreHealth, scoreStateDir, selfRecon
ark-self-recon/scannerInternal: scanCache, scanStateDir, detectTarget
ark-self-recon/scorerInternal: scoreHealth, scoreStateDir
ark-self-recon/benchmarkBenchmark: runBenchmark, runChainBench, selfReconBench, predictFailures

Benchmark integration

Consumer projects use the benchmark module for predictions and performance measurement.

Prediction engine — ark-delegator wraps predict with server-specific rules:

import { predict, storePredictions } from "ark-self-recon/benchmark";
import type { PredictionRule, FailurePrediction } from "ark-self-recon/benchmark";

Standalone benchmark — ark-gist runs a self-recon benchmark direct from the package:

import { selfReconBench } from "ark-self-recon/benchmark";

const report = await selfReconBench();
console.log(report.perSize.map(p => `${p.entryCount} entries: scan ${p.scan.avg}ms`).join("\n"));

Explicitly Not

  • A monitoring agent or cron daemon — single-shot scan, no watch mode
  • A metrics dashboard — returns a report object, no visualization or charting
  • A runtime supervisor — no restart, recovery, or alerting logic
  • A replacement for fs.stat — health scoring uses data semantics, not filesystem timestamps alone

Documentation

DocWhat it covers
docs/API.mdFull API reference with type signatures
docs/ARCHITECTURE.mdSystem design, components, data flow
docs/DESIGN.mdDesign decisions, constraints, tradeoffs
CE.mdAI entry point with config, pipeline overview

License

Apache-2.0

Keywords

mcp

FAQs

Package last updated on 14 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts