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.1.1.tar.gz (38.6 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.1.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: meshai_claude_code-0.1.1.tar.gz
  • Upload date:
  • Size: 38.6 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.1.1.tar.gz
Algorithm Hash digest
SHA256 2fe6c8d5e737ca2b48ba9322dacd668aa7770422172b97e05e1f804a5c09e4b6
MD5 57b5a2d5dc567a094f088838f4f946fa
BLAKE2b-256 7837868deaa46fc0506fd57847c80edd55f54c42fc4fa57efd84903d0884a12c

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshai_claude_code-0.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for meshai_claude_code-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 110cf182c78e0857d849461c89b97df67ad16c06e9df09b944ea9cc86e7aa9f7
MD5 5428edb1788aa916e09b014ca3cff0a2
BLAKE2b-256 5d1eef5610753abca9c59c8a506bd10fb8449fa4bdf71fe63ae00f6f97c1c50c

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshai_claude_code-0.1.1-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