Skip to main content

Agent-to-Agent Communication Layer — Real-time message bus for AI agents with pub/sub, WebSocket streaming, and MCP integration.

Project description

Synapse

Agent-to-Agent Communication Layer — Real-time message bus for AI agents.

Synapse is a lightweight pub/sub message bus designed for multi-agent AI systems. It provides real-time communication between AI agents via REST API, WebSocket streaming, and MCP (Model Context Protocol) integration.

Features

  • Pub/Sub Message Bus — Channel-based messaging with priority levels and message types
  • Agent Registry — Auto-discovery, heartbeat monitoring, capability-based routing
  • WebSocket Streaming — Real-time push to connected agents
  • SQLite Persistence — Messages survive restarts, queryable history
  • MCP Server — Native integration with Claude Code and other MCP clients
  • Web Dashboard — Live monitoring at /dashboard
  • Zero Dependencies ClientSynapseClient uses only stdlib (urllib)

Quick Start

pip install synapse-bus

Start the Server

synapse-server
# → Synapse bus running on http://localhost:8200

Connect an Agent

from synapse import SynapseClient, Priority

client = SynapseClient("my-agent")
client.register(capabilities=["analysis"], channels=["#alerts"])

# Publish a message
client.publish("#alerts", {"status": "online"})

# Send a critical alert
client.alert("Something went wrong!")

# Read inbox
messages = client.inbox()

# Get bus health
print(client.health())

Use as MCP Server

Add to your Claude Code config (~/.claude.json):

{
  "mcpServers": {
    "synapse": {
      "command": "synapse-mcp",
      "args": []
    }
  }
}

This gives Claude Code 7 tools: synapse_publish, synapse_inbox, synapse_agents, synapse_channels, synapse_history, synapse_alert, synapse_command.

Architecture

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Agent A    │     │   Agent B    │     │   Agent C    │
│  (Trading)   │     │  (Analysis)  │     │  (Assistant) │
└──────┬───────┘     └──────┬───────┘     └──────┬───────┘
       │ HTTP/WS            │ HTTP/WS            │ MCP
       └────────────┬───────┴────────────────────┘
                    │
            ┌───────▼───────┐
            │  Synapse Bus   │
            │   (FastAPI)    │
            ├────────────────┤
            │  #alerts       │
            │  #market-data  │
            │  #commands     │
            │  #system       │
            │  #heartbeat    │
            │  (custom...)   │
            ├────────────────┤
            │  SQLite Store  │
            └────────────────┘

API

REST Endpoints

Method Endpoint Description
POST /agents/register Register an agent
POST /agents/{name}/heartbeat Send heartbeat
GET /agents List all agents
GET /agents/{name} Get agent details
POST /publish Publish a message
POST /subscribe Subscribe to a channel
GET /inbox/{agent} Get agent inbox
GET /channels List channels
GET /history/{channel} Get message history
GET /health Bus health & stats
GET /dashboard Web dashboard

WebSocket

Connect to /ws/{agent_name} for real-time streaming:

const ws = new WebSocket("ws://localhost:8200/ws/my-agent");
ws.onmessage = (event) => console.log(JSON.parse(event.data));

// Publish via WebSocket
ws.send(JSON.stringify({
  action: "publish",
  channel: "#alerts",
  payload: { message: "Hello from WS" }
}));

Message Model

SynapseMessage(
    channel="#alerts",          # Target channel
    sender="my-agent",         # Sender name
    payload={"key": "value"},  # Arbitrary dict
    type=MessageType.EVENT,    # alert|data|command|query|response|event
    priority=Priority.NORMAL,  # 0=CRITICAL, 1=HIGH, 2=NORMAL, 3=LOW, 4=BACKGROUND
    ttl=0,                     # Seconds until expiry (0=never)
)

Default Channels

Channel Purpose
#alerts Critical notifications
#market-data Trading signals, prices
#learning AI insights, patterns
#commands Direct instructions
#heartbeat Agent health (automatic)
#system Bus internal events

Development

git clone https://github.com/engram-memory/synapse.git
cd synapse
pip install -e ".[dev]"
pytest

Part of the Engram Ecosystem

Synapse is the communication backbone for Engram — the universal memory layer for AI agents. Together they enable persistent, communicating multi-agent systems.

License

MIT

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

synapse_bus-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

synapse_bus-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file synapse_bus-0.1.0.tar.gz.

File metadata

  • Download URL: synapse_bus-0.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for synapse_bus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2c9a2ffe83c66325e993343eb57865c496ecaa34230a1ed3890d058bf3ee1e6
MD5 9d496d440324429a049dac82210463f6
BLAKE2b-256 adb85d0ce3dbbac6b36a76644fd3cded59fe58359496814be24c148c371ef764

See more details on using hashes here.

Provenance

The following attestation bundles were made for synapse_bus-0.1.0.tar.gz:

Publisher: publish.yml on engram-memory/synapse

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

File details

Details for the file synapse_bus-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: synapse_bus-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for synapse_bus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f872866e2af6fa69c3ef45e2aed032553afff7a3dbac5640a0fba5cbf892e5c
MD5 bc6525efd254150a71c91465da16d26d
BLAKE2b-256 e524fb18d91fd29d79df1cd00216d2d17cff7d6e20912ef18c54277f8f3632b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for synapse_bus-0.1.0-py3-none-any.whl:

Publisher: publish.yml on engram-memory/synapse

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