Skip to main content

OTel-native MeshAI connector for Claude Code: durable, evidence-grade telemetry for AI coding agent activity

Project description

meshai-claude-code

MeshAI  ·  Why durable telemetry  ·  PyPI

OTel-native MeshAI connector for Claude Code: durable, evidence-grade telemetry for AI coding agent activity, aimed at EU AI Act Article 12 record-keeping. Every hook event is fsynced to a local write-ahead log before anything else happens; a daemon publishes the WAL to MeshAI over OTLP. Daemon crash, OOM, or network outage cannot lose events. Only disk failure can.

Platforms (v1): macOS, Linux, and WSL. On WSL the state directory must live in the Linux filesystem (it does by default: ~/.local/state/meshai-cc); the daemon refuses to run against /mnt/c (DrvFS/9p), where fsync and file locks do not hold. Native Windows support (TCP loopback) is v2.

Install

Install with pipx. It puts the connector in its own isolated environment and exposes the meshai-claude-code, meshai-cc-hook, and meshai-cc-daemon commands on your PATH, which is what Claude Code needs to run the hooks.

pipx install meshai-claude-code
meshai-claude-code login --api-key msh_...
meshai-claude-code install     # registers hooks in ~/.claude/settings.json

If you do not have pipx: sudo apt install pipx (or brew install pipx), then pipx ensurepath and restart your shell.

The daemon starts automatically on the next Claude Code session (auto_start_daemon: true), or run meshai-cc-daemon yourself. Check health with meshai-claude-code status.

Plain pip install meshai-claude-code also works inside a virtual environment. On a system Python it fails with error: externally-managed-environment (PEP 668) on modern Debian, Ubuntu, and Homebrew. Use pipx, a venv, or pip install --break-system-packages if you understand the tradeoff.

Architecture

                fsync                    tail              OTLP POST
  ┌──────┐  event ┌──────┐    nudge   ┌────────┐         ┌────────────┐
  │ hook │───────▶│ WAL  │◀───────────│ daemon │────────▶│ MeshAI API │
  └──────┘        └──────┘            └────┬───┘         └────────────┘
                                      1s poll backstop
  • Hooks (meshai-cc-hook <Event>) are registered for SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, and Stop. Each one appends a CRC-framed record to the WAL with a real fsync (F_FULLFSYNC on macOS) and exits, with a p99 under 50ms that CI enforces.
  • The WAL lives at ~/.local/state/meshai-cc/wal/ (owner-only). Hooks own writes and rotation; the daemon is a pure reader.
  • The daemon (one per user, PID-file flock) converts events to OpenTelemetry spans and exports OTLP/HTTP protobuf to MeshAI. Offsets advance only after a successful export: delivery is at-least-once, and span ids are minted once at hook time, so MeshAI's ingest dedup makes accounting exactly-once.
  • Usage & cost: on session Stop, the transcript is parsed for per-turn token usage, emitted with gen_ai.* attributes MeshAI turns into cost rows. Pricing comes from GET /api/v1/pricing/anthropic at daemon startup, with a bundled offline fallback.

What leaves your machine (default: metadata only)

Tool content (tool_input/tool_output) is dropped by default. Structural metadata (event type, tool name, timing, token counts) always flows. Opt in per tool in ~/.config/meshai/filters.yaml:

tools:
  Bash:
    allow: [tool_input]

Allowlisted content passes through the MeshAI SDK's secret-redaction pipeline (API keys, JWTs, private-key blocks, homoglyph and base64-wrapped variants) and fails closed on any doubt. Filtering happens at emission in the daemon; the WAL itself is owner-only local state.

Compliance mode

# ~/.config/meshai/policy.yaml
fail_closed: true    # WAL append failure blocks Claude Code (exit 2)
agent_name: my-cc    # registry identity; default claude-code-<hostname>
base_url: https://api.meshai.dev

With fail_closed: true, no evidence means no action: a tool call that cannot be durably recorded does not run.

Development

pip install -e ".[dev]"
pytest -q            # includes Hypothesis WAL property tests + latency gate
ruff check src/ tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshai_claude_code-0.2.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshai_claude_code-0.2.0-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file meshai_claude_code-0.2.0.tar.gz.

File metadata

  • Download URL: meshai_claude_code-0.2.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for meshai_claude_code-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fa92a64af5e6182340960d30e93987d38736ac56df43da33339f843a8956d7b4
MD5 6943789307b66c400ff6ef715583c519
BLAKE2b-256 7cace5d2061e1fc820128a91671a507b12da4e9621cf3d73c08a6179991d869c

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshai_claude_code-0.2.0.tar.gz:

Publisher: publish.yml on meshailabs-org/meshai-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file meshai_claude_code-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for meshai_claude_code-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f3000379411e7dae7e5e7527d04f97896547cb4c55b5f1f8e0c7dff9afaccb6
MD5 6a6d93ba9dea7b26a0cbfc3a654274ca
BLAKE2b-256 0ae4c3a036e6d2dadcbb54bc9c71bc6722b3c4dbde00dacb011174cd0df7209b

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshai_claude_code-0.2.0-py3-none-any.whl:

Publisher: publish.yml on meshailabs-org/meshai-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page