Skip to main content

claude-chatter

Claude Code peer messaging protocol and client library.

claude-chatter provides a standalone Python implementation of the Claude Code peer-to-peer messaging protocol. It handles peer discovery via local session descriptors (~/.claude/sessions/*.json), background jobs inspection (~/.claude/jobs), UNIX domain socket IPC, NDJSON message framing, and local SQLite mailbox persistence.

This library has no dependencies on FastMCP or Antigravity and can be used directly in any Python application or CLI workflow.

Installation

pip install claude-chatter

Messaging tools

The library implements the peer messaging tools that Claude Code exposes to its own agents (SendMessage and ListAgents), so any Python program can act as a peer:

  • ClaudeClient.send_message(target_session, message_content, priority="next") delivers a message to a live session over its UNIX socket. The target is resolved by name, PID, session id or a partial name match.
  • ClaudeClient.list_sessions() returns the live sessions found in ~/.claude/sessions, with peer tokens redacted unless redact_tokens=False. ClaudeWire.scan_sessions() does the same without a client.

Received messages are stored in the local mailbox and read with get_unread_messages() and get_history(). The CLI equivalents are the send, list, inbox and history commands.

Quick Start

As a Library

import asyncio
from claude_chatter import ClaudeClient, ClaudeWire

async def main():
    # Stateless discovery
    sessions = ClaudeWire.scan_sessions()
    print("Discovered sessions:", sessions)

    # Initialize client node
    client = ClaudeClient(session_name="my-worker")

    # Send message to an active session
    res = await client.send_message(
        target_session="other-session",
        message_content="Hello from claude-chatter"
    )
    print("Send status:", res)

if __name__ == "__main__":
    asyncio.run(main())

Inbound Message Callback

async def on_message(event):
    print(f"Received frame {event['msg_id']} from {event['sender']}: {event['content']}")

client = ClaudeClient(session_name="listener", on_inbound_message=on_message)

An inbound {"type":"auth","token":"..."} line (peerToken is accepted as the key too) is checked against the token this process registered, and the connection is closed on a mismatch. ClaudeClient(require_auth=True) additionally refuses any connection that does not open with a valid auth line.

On send, when the target's key file provides a token, the connection opens with {"type":"auth","token":"..."} before the message frame. A Claude Code session (checked on Linux, 2.1.325) delivers a message whether or not the line is present and whatever token it carries.

await client.notify_when_idle(target, timeout=None) subscribes to a one-shot notice for when a Claude Code session next goes idle (Claude Code v2.1.236 or later, same machine) and returns it as {"success": True, "notice": {...}}. The notice is sent to this client's reply socket, so a listener must be bound (start_bridge_listener); without one the call fails. Control frames other than the idle notice are logged and not stored as messages.

The other side: a bound listener remembers notify_when_idle subscribers (reply address from the frame's from, which must be a uds: path). await client.publish_idle(finished_at_ms=None, detail=None) sends each one a peer_idle_notice (with an auth line when the subscriber's key file provides a token), drops the subscription, and returns {"notified", "failed", "pending"}. client.pending_idle_subscriptions() returns the count, and subscriptions expire after 12 hours.

event["sender"] is the live session that owns the connecting process (or an ancestor of it) when one can be found, with event["sender_verified"] = True. Otherwise it is the name the frame claims and sender_verified is False. claimed_sender, peer_pid and the wrapper's from_mode are always included. Peer lookup needs Linux (SO_PEERCRED) and a sender that is still running when the connection is accepted.

CLI Tool

The package installs both claude-chatter and chatter CLI entry points. Each mode is a command; list, jobs, inbox, history and send print a table, or JSON with --json. --socket, --name, --db and --project-path go before or after the command.

# List all active Claude Code sessions
chatter list

# List Claude Code background jobs
chatter jobs

# Inspect unread messages from local mailbox
chatter inbox

# View full persisted message history
chatter history

# Send message to a target session
chatter send target-session "Hello peer"

# Machine-readable output
chatter list --json

# Run standalone daemon socket listener
chatter standalone --name my-daemon

# Proactively scan and purge dead session files
chatter purge

# Without installing
uvx --from claude-chatter chatter list

The mode flags of earlier releases (--list, --jobs, --inbox, --history, --send, --purge, --standalone) are gone, and their JSON output is now --json.

Provenance

claude-chatter was extracted from non7top/claude-chatter-mcp to provide a reusable, host-independent library for the Claude Code peer messaging protocol with zero MCP dependencies. Full commit history of the protocol core was preserved during the separation.

License

MIT

Metadata

Release files for claude-chatter 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-chatter 0.5.0
File Size Uploaded Provenance Actions
claude_chatter-0.5.0.tar.gz 53.6 kB With provenance Details for claude_chatter-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for claude-chatter 0.5.0
File Interpreter ABI Platform Actions
claude_chatter-0.5.0-py3-none-any.whl Python 3 none any Details for claude_chatter-0.5.0-py3-none-any.whl

Total release size: 86.5 kB

Release files / claude_chatter-0.5.0.tar.gz

Download URL claude_chatter-0.5.0.tar.gz
Size 53.6 kB
Tags Source
SHA-256 checksum
How to use checksums
63111627986fec04a05f413c98423cb08a7f7295fa95d02b226d6df9508308af
BLAKE2b-256 checksum
How to use checksums
f5f2421051c932f07b187d24b5bcac35ed1d9b40eb02400c84cac210bbe611c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / claude_chatter-0.5.0-py3-none-any.whl

Download URL claude_chatter-0.5.0-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c94b7e72b0d3799b7b8e73d6ae9b64651533f904290be0773945ccc2c373027
BLAKE2b-256 checksum
How to use checksums
ee0fef4062590d1d3c16f43fdc9c633e0d5d1f93ae5732ec08f6673d6620df00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for claude-chatter 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for claude_chatter-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page