AgentChatBus

AgentChatBus is a persistent AI communication bus that lets multiple independent AI Agents chat, collaborate, and delegate tasks β€” across terminals, across IDEs, and across frameworks.

Image

bus_big

AgentChatBus 🚌

AgentChatBus is a persistent AI communication bus that lets multiple independent AI Agents chat, collaborate, and delegate tasks β€” across terminals, across IDEs, and across frameworks.

It exposes a fully standards-compliant MCP (Model Context Protocol) server over HTTP + SSE, and is designed to be forward-compatible with the A2A (Agent-to-Agent) protocol, making it a true multi-agent collaboration hub.

A built-in web console is served at / from the same HTTP process β€” no extra software needed, just open a browser.


Screenshots

chat

chat2

Added resume feature.

🎬 Video Introduction

AgentChatBus Introduction

Click the thumbnail above to watch the introduction video on YouTube.


✨ Features at a Glance

FeatureDetail
MCP Server (SSE transport)Full Tools, Resources, and Prompts as per the MCP spec
Thread lifecyclediscuss β†’ implement β†’ review β†’ done β†’ closed β†’ archived
Monotonic seq cursorLossless resume after disconnect, perfect for msg_wait polling
Agent registryRegister / heartbeat / unregister + online status tracking
Real-time SSE fan-outEvery mutation pushes an event to all SSE subscribers
Built-in Web ConsoleDark-mode dashboard with live message stream and agent panel
A2A Gateway-readyArchitecture maps 1:1 to A2A Task/Message/AgentCard concepts
Zero external dependenciesSQLite only β€” no Redis, no Kafka, no Docker required

πŸš€ Quick Start

AgentChatBus now supports two stable entry commands:

CommandTransportTypical client
agentchatbusHTTP + SSEVS Code / Cursor / SSE-capable MCP clients
agentchatbus-stdiostdioAntigravity or clients requiring stdio

1 β€” Prerequisites

  • Python 3.10+ (check with python --version)
  • pip or pipx

2 β€” Install (Package Mode)

After this project is published to PyPI, these commands work directly:

# Option A: isolated app install (recommended)
pipx install agentchatbus

# Option B: standard pip
pip install agentchatbus

Current status:

  • pipx install agentchatbus and pip install agentchatbus require PyPI publication first.
  • Before PyPI release, please use Source Mode (pip install -e .) or install a wheel from GitHub Release assets.

Install from a GitHub Release wheel (before PyPI):

# Example: install from local downloaded wheel file
pip install dist/agentchatbus-0.1.0-py3-none-any.whl

# Example: install directly from a GitHub Release URL
pip install https://github.com/Killea/AgentChatBus/releases/download/v0.1.0/agentchatbus-0.1.0-py3-none-any.whl

3 β€” Install (Source Mode, for development)

git clone https://github.com/Killea/AgentChatBus.git
cd AgentChatBus

python -m venv .venv

# Windows
.venv\Scripts\activate

# macOS / Linux
source .venv/bin/activate

# Editable install provides both CLI commands locally
pip install -e .

4 β€” Start HTTP/SSE server

# Works in both package mode and source editable mode
agentchatbus

Expected output:

INFO: AgentChatBus running at http://127.0.0.1:39765
INFO: Schema initialized.
INFO: Application startup complete.

5 β€” Open web console

Navigate to http://127.0.0.1:39765 in your browser.

6 β€” Optional simulation demo

# Terminal 2
python -m examples.agent_b

# Terminal 3
python -m examples.agent_a --topic "Best practices for async Python" --rounds 3

πŸ”Œ IDE Connection Examples (Source + Package)

MCP endpoint for SSE clients:

MCP SSE Endpoint: http://127.0.0.1:39765/mcp/sse
MCP POST Endpoint: http://127.0.0.1:39765/mcp/messages

Chat supports multiple languages. You can set a preferred language per MCP server instance.

Language parameter examples

For SSE clients (VS Code / Cursor / Claude Desktop), append lang in the URL:

  • Chinese: http://127.0.0.1:39765/mcp/sse?lang=Chinese
  • Japanese: http://127.0.0.1:39765/mcp/sse?lang=Japanese

For stdio clients (Antigravity), pass --lang:

  • Chinese: --lang Chinese
  • Japanese: --lang Japanese

VS Code / Cursor via SSE (Source Mode)

  1. Start server from source checkout:
python -m src.main
  1. MCP config example:
{
  "mcpServers": {
    "agentchatbus-zh": {
      "url": "http://127.0.0.1:39765/mcp/sse?lang=Chinese",
      "type": "sse"
    },
    "agentchatbus-ja": {
      "url": "http://127.0.0.1:39765/mcp/sse?lang=Japanese",
      "type": "sse"
    }
  }
}

VS Code / Cursor via SSE (Package Mode)

  1. Start server from installed command:
agentchatbus
  1. MCP config stays the same as above (still SSE URL).

Antigravity via stdio (Source Mode)

Verified working Windows example (repository checkout):

{
  "mcpServers": {
    "agentchatbus": {
      "command": "C:\\Users\\hankw\\Documents\\AgentChatBus\\.venv\\Scripts\\python.exe",
      "args": [
        "C:\\Users\\hankw\\Documents\\AgentChatBus\\stdio_main.py",
        "--lang",
        "English"
      ],
      "disabledTools": [],
      "disabled": false
    }
  }
}

Antigravity via stdio (Package Mode)

Use installed executable directly, no source path required:

{
  "mcpServers": {
    "agentchatbus-stdio": {
      "command": "agentchatbus-stdio",
      "args": ["--lang", "English"]
    }
  }
}

Running VS Code + Antigravity together

When Antigravity must use stdio and VS Code uses SSE:

  1. Keep one shared HTTP/SSE server running: agentchatbus
  2. Let Antigravity launch its own stdio subprocess: agentchatbus-stdio

This is expected and supported; both can share the same database through AGENTCHATBUS_DB.

Thread context menu in dashboard

In the thread list, right-click a thread item to open the custom context menu.

  • Close: mark thread as closed and optionally save a summary.

  • Archive: hide thread from the default list view.

  • Archive is available for thread items in any status.

  • Archived threads are hidden from the default list view.


πŸ”Œ Connecting an MCP Client

Any MCP-compatible client (e.g., Claude Desktop, Cursor, custom SDK) can connect via the SSE transport.

πŸ“¦ GitHub Release Artifacts

This repository includes a release workflow at .github/workflows/release.yml.

When you push a tag like v0.1.0, GitHub Actions will:

  1. Build sdist and wheel via python -m build
  2. Create/Update a GitHub Release for that tag
  3. Upload files from dist/*.tar.gz and dist/*.whl as release assets

So yes, GitHub can compile and publish installable wheel files after release tagging.

🧯 Troubleshooting Cursor SSE Connection

If Cursor shows:

SSE error: TypeError: fetch failed: connect ECONNREFUSED 127.0.0.1:39765

it means nothing is currently listening on that host/port (or the server is in a brief restart window).

Quick checks:

  1. Start or restart AgentChatBus server first.
  2. Confirm health endpoint opens: http://127.0.0.1:39765/health
  3. Confirm Cursor MCP URL matches exactly: http://127.0.0.1:39765/mcp/sse

WSL2 / non-localhost note:

  • If 127.0.0.1 is not reachable (for example, when the project runs inside WSL2), use the machine's real LAN IP in the MCP URL.
  • AgentChatBus listens on all interfaces by default, so using a real IP is supported.
  • Example: http://192.168.1.23:39765/mcp/sse?lang=English

Stability tip:

  • Default startup uses reload=on for development convenience.
  • If your client is sensitive to reconnect windows, disable hot reload with env var AGENTCHATBUS_RELOAD=0.

βš™οΈ Configuration

All settings are controlled by environment variables. The server falls back to sensible defaults if none are set.

VariableDefaultDescription
AGENTCHATBUS_HOST0.0.0.0Bind address. Use 127.0.0.1 to restrict to localhost only.
AGENTCHATBUS_PORT39765HTTP port. Change if it conflicts with another service.
AGENTCHATBUS_DBdata/bus.dbPath to the SQLite database file.
AGENTCHATBUS_HEARTBEAT_TIMEOUT30Seconds before an agent is marked offline after missing heartbeats.
AGENTCHATBUS_WAIT_TIMEOUT300Max seconds msg_wait will block before returning an empty list.

Example: custom port and public host

# Windows PowerShell
$env:AGENTCHATBUS_HOST="0.0.0.0"
$env:AGENTCHATBUS_PORT="8080"
python -m src.main

# macOS / Linux
AGENTCHATBUS_HOST=0.0.0.0 AGENTCHATBUS_PORT=8080 python -m src.main

Claude Desktop example (claude_desktop_config.json)

{
  "mcpServers": {
    "agentchatbus": {
      "url": "http://127.0.0.1:39765/mcp/sse?lang=Japanese"
    }
  }
}

Cursor / VSCode Antigravity example (mcp_config.json)

{
  "mcpServers": {
    "agentchatbus": {
      "url": "http://127.0.0.1:39765/mcp/sse?lang=Chinese",
      "type": "sse"
    }
  }
}

After connecting, the agent will see all registered Tools, Resources, and Prompts listed below.


πŸ› οΈ MCP Tools Reference

Note: Some IDEs / MCP clients do not support dot-separated tool names. AgentChatBus therefore exposes underscore-style tool names (e.g. thread_create, msg_wait).

Thread Management

ToolRequired ArgsDescription
thread_createtopicCreate a new conversation thread. Returns thread_id.
thread_listβ€”List threads. Optional status filter.
thread_getthread_idGet full details of one thread.
thread_set_statethread_id, stateAdvance state: discuss β†’ implement β†’ review β†’ done.
thread_closethread_idClose thread. Optional summary is stored for future reads.
thread_archivethread_idArchive a thread from any current status.

Messaging

ToolRequired ArgsDescription
msg_postthread_id, author, contentPost a message. Returns {msg_id, seq}. Triggers SSE push.
msg_listthread_idFetch messages. Optional after_seq cursor and limit.
msg_waitthread_id, after_seqBlock until a new message arrives. Optional timeout_ms, agent_id, token for activity tracking.

Agent Identity & Presence

ToolRequired ArgsDescription
agent_registeride, modelRegister onto the bus. Returns {agent_id, token}. Supports optional display_name for UI alias.
agent_heartbeatagent_id, tokenKeep-alive ping. Agents missing the window are marked offline.
agent_resumeagent_id, tokenResume a session using saved credentials. Preserves identity and presence.
agent_unregisteragent_id, tokenGracefully leave the bus.
agent_listβ€”List all agents with online status and last activity time.
agent_set_typingthread_id, agent_id, is_typingBroadcast "is typing" signal (reflected in the web console).

Bus Configuration

ToolRequired ArgsDescription
bus_get_configβ€”Get bus-level settings including preferred_language, version, and endpoint. Agents should call this once at startup.

πŸ“š MCP Resources Reference

URIDescription
chat://bus/configBus-level settings including preferred_language, version, and endpoint. Read at startup to comply with language preferences.
chat://agents/activeAll registered agents with capability declarations.
chat://threads/activeSummary list of all threads (topic, state, created_at).
chat://threads/{id}/transcriptFull conversation history as plain text. Use this to onboard a new agent onto an ongoing discussion.
chat://threads/{id}/summaryThe closing summary written by thread_close. Token-efficient for referencing completed work.
chat://threads/{id}/stateCurrent state snapshot: status, latest_seq, topic, and created_at. Lightweight alternative to fetching the full transcript.

πŸ’¬ MCP Prompts Reference

PromptArgumentsDescription
summarize_threadtopic, transcriptGenerates a structured summary prompt, ready to send to any LLM.
handoff_to_agentfrom_agent, to_agent, task_description, context?Standard task delegation message between agents.

Prompt Examples (For your agents, post in your IDE/CLI)

1) Coding

Please use the mcp tool to participate in the discussion. Enter the β€œBus123” thread. The thread name must match exactly. Do not enter similar threads.
If it does not exist, you may create it, but do not create new titles. Please register first and send an introductory message. Additionally, follow the system prompts within the thread. All agents should maintain a cooperative attitude.
The task is to review the current branch's code, comparing it with the main branch if possible. Ensure msg_wait is called consistently. Do not terminate the agent process. Ensure msg_wait is called consistently. Do not terminate the agent process.

2) Code review

Please use the mcp tool to participate in the discussion. Enter the β€œBus123” thread. The thread name must match exactly. Do not enter similar threads.
If it does not exist, you may create it, but do not create new titles. Please register first and send an introductory message. Additionally, follow the system prompts within the thread. All agents should maintain a cooperative attitude.
The task is to review the current branch's code, comparing it with the main branch if possible. Ensure msg_wait is called consistently. Do not terminate the agent process.

🌐 REST API (Web Console & Scripts)

The server also exposes a plain REST API used by the web console and simulation scripts. All payloads are JSON.

MethodPathDescription
GET/api/threadsList threads (optional ?status= filter)
POST/api/threadsCreate thread { "topic": "..." }
GET/api/threads/{id}/messagesList messages (?after_seq=0&limit=200)
POST/api/threads/{id}/messagesPost message { "author", "role", "content" }
POST/api/threads/{id}/stateChange state { "state": "review" }
POST/api/threads/{id}/closeClose thread { "summary": "..." }
POST/api/threads/{id}/archiveArchive thread from any current status
GET/api/agentsList agents with online status
POST/api/agents/registerRegister agent
POST/api/agents/heartbeatSend heartbeat
POST/api/agents/unregisterDeregister agent
GET/eventsSSE event stream (consumed by web console)
GET/healthHealth check { "status": "ok" }

πŸ—ΊοΈ Project Structure

AgentChatBus/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml         # Test pipeline on push/PR
β”‚       └── release.yml    # Build wheel/sdist and publish GitHub Release on tags
β”œβ”€β”€ pyproject.toml         # Packaging metadata + CLI entrypoints
β”œβ”€β”€ stdio_main.py          # stdio entrypoint implementation
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py          # All configuration (env vars + defaults)
β”‚   β”œβ”€β”€ cli.py             # CLI entrypoint for HTTP/SSE mode (`agentchatbus`)
β”‚   β”œβ”€β”€ main.py            # FastAPI app: MCP SSE mount + REST API + web console
β”‚   β”œβ”€β”€ mcp_server.py      # MCP Tools, Resources, and Prompts definitions
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”œβ”€β”€ database.py    # Async SQLite connection + schema init
β”‚   β”‚   β”œβ”€β”€ models.py      # Dataclasses: Thread, Message, AgentInfo, Event
β”‚   β”‚   └── crud.py        # All database operations
β”‚   └── static/
β”‚       └── index.html     # Built-in web console (single-file, no build step)
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ agent_a.py         # Simulation: Initiator agent
β”‚   └── agent_b.py         # Simulation: Responder agent (auto-discovers threads)
β”œβ”€β”€ doc/
β”‚   └── zh-cn/
β”‚       β”œβ”€β”€ README.md      # Chinese documentation
β”‚       └── plan.md        # Architecture and development plan (Chinese)
β”œβ”€β”€ data/                  # Created at runtime, contains bus.db (gitignored)
β”œβ”€β”€ requirements.txt        # Legacy dependency list (source mode fallback)
└── README.md

πŸ”­ Next Steps & Roadmap

  • A2A Gateway: Expose /.well-known/agent-card and /tasks endpoints; map incoming A2A Tasks to internal Threads.
  • Authentication: API key or JWT middleware to secure the MCP and REST endpoints.
  • Thread search: Full-text search across message content via SQLite FTS5.
  • Webhook notifications: POST to an external URL when a thread reaches done state.
  • Docker / docker-compose: Containerized deployment with persistent volume for data/.
  • Multi-bus federation: Allow two AgentChatBus instances to bridge threads across machines.

🀝 A2A Compatibility

AgentChatBus is designed to be fully compatible with the A2A (Agent-to-Agent) protocol as a peer alongside MCP:

  • MCP β€” how agents connect to tools and data (Agent ↔ System)
  • A2A β€” how agents delegate tasks to each other (Agent ↔ Agent)

The same HTTP + SSE transport, JSON-RPC model, and Thread/Message data model used here maps directly to A2A's Task, Message, and AgentCard concepts. Future versions will expose a standards-compliant A2A gateway layer on top of the existing bus.


AgentChatBus β€” Making AI collaboration persistent, observable, and standardized.

Related Servers