Skip to main content
Glama

Agent Flight Recorder

Tamper-evident flight recorder, Lamport causal replay engine, MCP tool-poisoning scanner, and zero-leak operational security (OPSEC) scrubber for Python 3.12 and Model Context Protocol (MCP 2025-11-25) workflows.

Live interactive avionics workbench: nahianakhtar.github.io/demos/flight-recorder/

Why Production Agent Teams Need a Flight Recorder

Long-running AI agents fail compliance reviews when nobody can reproduce Tuesday afternoon's tool calls offline. Models sample stochastically. Upstream APIs mutate state between retries, while raw debug logs routinely leak developer home directories, internal CGNAT addresses, or API tokens into bug trackers.

agent-flight-recorder wraps every tool call in a zero-dependency signed cassette (.afr.jsonl) built on four mathematical guarantees:

  1. Monotonic Lamport Logical Clocks: Every invocation advances L_k = max(L_{k-1}, L_in) + 1 and seals (seq, lamport_clock, tool_name, schema_sha256, args_sha256, output_sha256, duration_us, prev_hash) into a SHA-256 hash chain.

  2. Domain-Separated Binary Merkle Root: Leaf digests (0x00 || leaf) and interior nodes (0x01 || left || right) produce compact O(log2 N) inclusion proofs. Flipping one bit in any historical argument invalidates the cassette root immediately.

  3. Wagner-Fischer Trace Alignment: Offline replay computes exact dynamic-programming edit distance D(m, n) between recorded production cassettes and candidate builds. It isolates ARG_DRIFT, SCHEMA_DRIFT, MISSING_CALL, or UNEXPECTED_CALL in under two milliseconds with zero network calls.

  4. Shannon Entropy and Zero-Leak OPSEC Gate: Scrubs OS user paths, private LAN and RFC 6598 CGNAT carrier-grade ranges, 0.0.0.0 wildcard port binds, tracking query parameters, hidden Unicode bidirectional overrides (U+202E), and unlabelled high-entropy secrets (H(X) >= 4.35 bits/char).

Related MCP server: MCP Security scanner

Architecture Overview

Tool Call -> [OPSEC & Entropy Scrubber] -> [Lamport Clock + Canonical RFC 8785 JSON]
                                                       |
                                                       v
Candidate Run -> [Wagner-Fischer DP Aligner] <-- [.afr.jsonl + SHA-256 Merkle Root]

Quick Start

pip install -e .

# Run self-contained recording, scrubbing, and Merkle verification demo
afr demo

# Verify an existing flight cassette
afr verify session.afr.jsonl

# Align a candidate test run against a recorded production cassette
afr replay session.afr.jsonl candidate_calls.json

# Start the zero-dependency MCP 2025-11-25 stdio server
afr-mcp

MCP 2025-11-25 Server Tools

Tool Name

Read-Only

Purpose

afr_verify_cassette

true

Verify Lamport clock order, SHA-256 frame hashes, and Merkle root integrity

afr_replay_diff

true

Align recorded cassette frames against candidate calls via Wagner-Fischer DP

afr_scrub_opsec

true

Redact host paths, private/CGNAT IPs, wildcard binds, and high-entropy secrets

afr_audit_mcp_tools

true

Detect Trojan-Source Bidi overrides and indirect prompt injection in tools/list

Verification Gate

ruff check src tests
ruff format --check src tests
mypy --strict src
pytest -q

License

MIT License. Copyright (c) 2026 Nahian Akhtar.

Available Tools

4 tools
afr_audit_mcp_toolsB
Read-onlyIdempotent

Detect hidden Unicode smuggling and indirect prompt-injection inside MCP tool metadata.

Inputs: tools (required).

afr_replay_diffC
Read-onlyIdempotent

Deterministically align a recorded cassette against candidate tool invocations via Wagner-Fischer DP.

Inputs: cassette_jsonl (required), candidate_calls (required).

afr_scrub_opsecB
Read-onlyIdempotent

Scan and redact OS user paths, LAN/CGNAT IPs, wildcard binds, and high-entropy secrets.

Inputs: payload (required).

afr_verify_cassetteB
Read-onlyIdempotent

Verify Lamport logical clocks, SHA-256 hash chain, and Merkle root of a JSONL flight cassette.

Inputs: cassette_jsonl (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a clearly distinct operation: cassette integrity verification, deterministic replay comparison, OPSEC redaction, and MCP metadata injection auditing. The boundaries are easy to distinguish from names and descriptions, with no apparent overlap.

    Naming Consistency5/5

    All tools use the same predictable afr_verb_noun pattern: afr_verify_cassette, afr_replay_diff, afr_scrub_opsec, afr_audit_mcp_tools. The shared prefix and consistent verb-based structure make the set highly readable.

    Tool Count5/5

    Four tools is well-scoped for a focused cassette security and audit server. Each tool covers a distinct audit operation, and there are no redundant or trivial entries.

    Completeness4/5

    The surface covers verification, replay diffing, scrubbing, and MCP metadata auditing, which are core for this forensic/audit domain. Minor gaps could include cassette listing/summarization or report export, but agents can likely work around them.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables users to deterministically audit MCP servers for security issues across manifests, source, runtime responses, multi-call state, identity, and install scripts, and to run an inline gateway that gates tool calls and scans responses before returning them.
      3
      21 PyPI
      1
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents to run scope-checked probes of MCP endpoints, analyze tool definitions for poisoning and dangerous capabilities, detect definition drift, and generate reproducible evidence bundles and bounty-ready reports.
      1
      MIT