Skip to main content
Glama

agent-bridge

A local SQLite-backed peer-to-peer MCP bridge and plugin bundle enabling official Antigravity, Claude Code, and Codex sessions to collaborate directly in the same workspace—via shared rooms, lifecycle auto-trigger hooks, a zero-token background wait listener, and visible interactive session launching.

Overview (English)

agent-bridge lets official AI coding agent clients collaborate as peers without wrapping or scraping third-party CLIs behind the scenes:

  • Official clients talk to each other: Each agent runs in its own official client (Antigravity, Claude Code, Codex) and talks through standard stdio MCP tools and lifecycle hooks backed by a local SQLite WAL database (~/.agent-bridge/hub.db)—no daemon required.

  • Automatic workspace room matching: Omitting room derives a deterministic room ID (<repo-name>-<8-char-hash>) from the git repository root (or workspace path), so agents opened in the same repository automatically meet in the same room. Supports N agents (antigravity, claude-code, codex, or custom handles).

  • Lifecycle auto-trigger hooks & stall detection: Bundled plugins wire SessionStart / PreInvocation / Stop (Antigravity) and SessionStart / UserPromptSubmit / Stop (Claude Code) to inject unread messages, maintain passive presence, warn the sender when a reply-expected message goes unanswered (seen_no_reply vs unseen), and prevent infinite ping-pong loops (max_turns + Stop-hook continuation caps).

  • Zero-token background wait listener (agent-bridge wait): Long-running CLI listener (default 1800s, or 0 for indefinite) that blocks on SQLite with zero token usage while idle and exits immediately when a peer message arrives—waking an idle Antigravity conversation automatically via Reactive Wakeup. Includes a PID-verified singleton guard to prevent duplicate listeners.

  • Visible interactive launching: When a target peer is offline, bridge_launch / bridge_send(..., auto_launch=True) / agent-bridge up opens a visible terminal window for the official CLI instead of hidden background processes.

Quickstart (English)

git clone https://github.com/holmesfems/agent-bridge.git agent-bridge
cd agent-bridge
python -m venv .venv

# Windows (PowerShell)
.venv\Scripts\python -m pip install -e ".[dev]"
.venv\Scripts\agent-bridge install --target all

# macOS / Linux
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/agent-bridge install --target all
  • Antigravity: Installed automatically to ~/.gemini/config/plugins/agent-bridge/ (auto-discovered on the next turn).

  • Claude Code: Installed to ~/.agent-bridge/plugins/claude-code/. Launch with:

    claude --plugin-dir ~/.agent-bridge/plugins/claude-code

Related MCP server: agent-bridge

概要(日本語)

Antigravity・Claude Code・Codex などの公式クライアント同士が、ローカルの共有 SQLite ハブと公式プラグイン/フックを通じて対等に協調作業するための MCP ブリッジです。

  • 公式クライアント同士で通信:他社 CLI のサブスク認証を裏でヘッドレスにラップするのではなく、ユーザーが起動した公式の Antigravity / Claude Code / Codex 同士が、ローカルの共有ボード(~/.agent-bridge/hub.db)を標準 MCP とフックで読み書きします。

  • N エージェント対応:最初から 2 者専用ではなく、同じワークスペースのルームに何人でも参加できます(antigravity / claude-code / codex / カスタム名)。

  • 自動トリガー(Hooks + スマート待機リスナー):

    • Antigravity(SessionStart / PreInvocation / Stop)と Claude Code(SessionStart / UserPromptSubmit / Stop)の公式フックをプラグインに同梱。新着メッセージがあれば自動でコンテキスト注入・ターン続行します。

    • Antigravity 向けには、待機中トークン消費ゼロで自動起床できるバックグラウンド待機コマンド agent-bridge wait と、オンラインピア検知時のスマート自動待機ルールを同梱しています。

    • 無限ピンポン防止のため、スレッドごとの max_turns 上限と Stop フック連続発火上限を内蔵しています。

  • 新規セッションの可視起動:相手がオフラインのときは bridge_launch(または bridge_send(..., auto_launch=True) / agent-bridge up)で、ユーザーの目の前に公式 CLI の対話ウィンドウを開きます。


アーキテクチャ

┌──────────────────────────┐        ┌──────────────────────────┐
│  Antigravity (公式)       │        │  Claude Code (公式)       │
│  + plugins/antigravity   │        │  + plugins/claude-code   │
│  (MCP + Skill + Hooks)   │        │  (MCP + Skill + Hooks)   │
└────────────┬─────────────┘        └─────────────┬────────────┘
             │ stdio MCP / Hook CLI / wait        │ stdio MCP / Hook CLI
             └──────────────┐      ┌──────────────┘
                            ▼      ▼
               ┌────────────────────────────────┐
               │ ~/.agent-bridge/hub.db (SQLite)│  ← 常駐デーモン不要(WAL モード)
               └────────────────────────────────┘
                            ▲
                            │ (任意)
               ┌────────────┴─────────────┐
               │  Codex (plugins/codex)   │
               └──────────────────────────┘
  • ルームの自動一致:room を省略すると、カレントの git リポジトリルート(またはワークスペースパス)から決定論的なルーム ID(<repo-name>-<8桁ハッシュ>)を生成するため、同じプロジェクトを開いた各エージェントが自動的に同じ部屋に入ります。

  • ファイル受け渡し:バイナリや巨大な本文は送らず、files にワークスペース内のファイルパスだけを渡します。


セットアップ

1. インストール

# リポジトリを取得して仮想環境を作成(Windows / PowerShell の例)
git clone https://github.com/holmesfems/agent-bridge.git agent-bridge
cd agent-bridge
python -m venv .venv
.venv\Scripts\python -m pip install -e ".[dev]"

macOS / Linux の場合は .venv/bin/python -m pip install -e ".[dev]" を使用してください。

2. Antigravity & Claude Code プラグインの配置

agent-bridge install を実行すると、現在の .venv 内の実行ファイル絶対パスを mcp_config.json・hooks.json・rules/AGENTS.md・skills/agent-bridge/SKILL.md に埋め込んだ状態でプラグインを配置します(グローバル PATH 未登録でも別リポジトリから動作します。起動中の再インストールでも上書き更新されます)。

# Windows (PowerShell)
.venv\Scripts\agent-bridge install --target all

# macOS / Linux
.venv/bin/agent-bridge install --target all
  • Antigravity:~/.gemini/config/plugins/agent-bridge/ に自動配置されます(~/.gemini/config/config.json は編集せず、Antigravity の自動検出に任せます)。次のターンから有効になり、Customizations 画面で ON/OFF 管理できます。

  • Claude Code:~/.agent-bridge/plugins/claude-code/ に配置されます。以下のように読み込んで起動します:

# Windows (PowerShell)
claude --plugin-dir "$env:USERPROFILE\.agent-bridge\plugins\claude-code"

# macOS / Linux
claude --plugin-dir "$HOME/.agent-bridge/plugins/claude-code"

3. Antigravity の権限設定(毎回確認を省くおすすめ設定)

Antigravity の MCP ツールは既定で確認ダイアログ(Ask)が出ます。以下の 2 つを許可しておくと、自動待機〜返信まで完全ノンストップで動きます。

Settings → General → Permissions → Advanced から以下を Allow に追加:

  1. MCP Tools:

    agent-bridge_agent-bridge/*

    (bridge_launch だけ毎回確認したい場合は、あわせて Ask に agent-bridge_agent-bridge/bridge_launch を追加)

  2. Commands(バックグラウンド待機リスナーを無確認で張る場合):

    <path-to-agent-bridge>\.venv\Scripts\agent-bridge.exe wait

    (macOS / Linux は <path-to-agent-bridge>/.venv/bin/agent-bridge wait)


MCP ツール一覧

ツール

役割

bridge_join(room?, name?, workspace?, status?)

ルームに参加・オンライン登録し、参加者一覧と未読メッセージを返す

bridge_who(room?, workspace?, include_offline?)

ルーム内のオンライン/待機中エージェントを確認する

bridge_send(to, message, room?, kind?, files?, thread_id?, expect_reply?, max_turns?, wait_seconds?, auto_launch?)

相手(または all)へ送信。wait_seconds で返信待ち、auto_launch=True でオフライン相手の対話ウィンドウ起動も可能

bridge_inbox(room?, unread_only?, limit?, mark_read?)

自分宛て・部屋宛ての未読メッセージを読む

bridge_wait(room?, thread_id?, timeout_seconds?)

相手からの新着メッセージをロングポーリング待機する(MCP タイムアウト回避のため最大 110 秒)

bridge_history(room?, thread_id?, limit?)

ルームまたはスレッドの履歴を参照する

bridge_launch(target, room?, workspace?, prompt?, launcher?)

対象エージェント(claude-code / antigravity / codex)の新しい対話セッションを可視ウィンドウで開く

bridge_rooms(limit?)

アクティブ・最近のルーム一覧を表示する


自動トリガー・待機リスナーの仕組みと安全ガード

  1. ターン開始・プロンプト送信時:

    • Antigravity:SessionStart / PreInvocation フックが未読メッセージを injectSteps(systemMessage)で自動注入します。

    • Claude Code:SessionStart / UserPromptSubmit フックが未読メッセージを additionalContext で自動注入します。

    • 同時にオンライン状態(presence)も受動的に更新されるため、bridge_join を明示的に呼ばなくても相手から「オンライン」に見えます。

  2. アイドル中の自動起床(スマート待機リスナー agent-bridge wait):

    • MCP の bridge_wait(上限 110 秒)とは別に、CLI の agent-bridge wait --client antigravity --timeout 1800(0 で無期限)を用意しています。

    • Antigravity のバックグラウンドコマンドとして起動してターンを終了すると、待機中のトークン消費ゼロのまま SQLite を監視し、ピアからメッセージが届いた瞬間に終了 → Antigravity の Reactive Wakeup で会話が自動起床します。

    • スマート起動 & 安全ガード:

      • 同じルームにオンラインのピア(Claude Code 等)がいて待機リスナーが未起動のときだけ、SessionStart / PreInvocation フックがセッションにつき 1 回自動起動を促します。

      • 重複起動ガード:同一 (room, client) で生きている wait プロセス(PID 生存確認+ハートビート)がある場合は already_running: true を返して即終了し、多重起動を防ぎます(--force で強制起動可)。

      • 自然終了:返信後は自動で張り直しますが、無通信タイムアウト(既定 30 分、timed_out: true)・max_turns 到達・ユーザーからの停止指示時は張り直さずに静かに終了します。

      • 待機中は status: "waiting" として公開され、終了時に自動で offline へクリーンアップされます。

  3. ターン終了時(Stop フック):

    • 返信要求付き(expect_reply=True)の未処理メッセージがあり、かつ turn < max_turns の場合のみ自動続行します(Antigravity は decision: "continue"、Claude Code は decision: "block")。

    • 暴走防止:

      • 同一メッセージは 1 セッションにつき 1 回しかフック配信しません(hook_deliveries テーブル)。

      • ユーザーキャンセル・エラー終了時(Antigravity terminationReason != "NO_TOOL_CALL")や Claude Code stop_hook_active=true では絶対に止めません。

      • 1 ターンあたりの自動続行回数上限(AGENT_BRIDGE_STOP_MAX_CONTINUES、既定 2)とスレッドの max_turns(既定 6)の二重ガードを持ちます。

  4. 返信停滞(「返事が来ない」)検知:

    • expect_reply=True のメッセージに、同じスレッドで他クライアントからの後続投稿が無いまま AGENT_BRIDGE_STALL_SECONDS(既定 180 秒、0 で無効、6 時間より古い投稿は対象外)を経過すると、送り手へ自動通知します。

    • 相手が既にメッセージを読んだ(message_reads)またはフック注入済み(hook_deliveries)なのに返信がない場合は state: "seen_no_reply"(権限確認プロンプトやユーザー入力待ちで止まっている可能性)、未読の場合は state: "unseen"(オフラインや待機リスナー未起動など)として区別します。

    • 送り手の SessionStart / PreInvocation / UserPromptSubmit フックで 1 メッセージにつき 1 セッション・1 状態ごとに 1 回だけ(unseen → seen_no_reply に変わったときは改めて)「Peer reply overdue」通知を注入するほか、bridge_who および agent-bridge status --sender <client> の awaiting_replies 欄でも確認できます。

  5. 新規セッション起動クールダウン:

    • 同一 (room, target) への連続起動は既定 30 秒間ブロックし、ウィンドウの多重起動を防ぎます。


CLI ユーティリティ

# ルームの参加者と最新メッセージを確認
agent-bridge status

# 同じルームで Antigravity と Claude Code の対話ウィンドウをまとめて起動
agent-bridge up --agents antigravity,claude-code

# ターミナルからエージェントへ直接メッセージ送信
agent-bridge send claude-code "tests/test_hub.py の設計をレビューして" --files tests/test_hub.py

# ピアからの未読メッセージが届くまで長時間待機(既定 1800 秒、0 で無期限)
# 重複起動ガード内蔵(--force で強制上書き、--no-mark-read で既読化せず確認)
agent-bridge wait --client antigravity --timeout 1800

環境変数

変数

既定

意味

AGENT_BRIDGE_HOME

~/.agent-bridge

DB・設定の保存先

AGENT_BRIDGE_DB

~/.agent-bridge/hub.db

SQLite DB ファイルパス

AGENT_BRIDGE_CLIENT

unknown

クライアント識別子(antigravity / claude-code / codex)

AGENT_BRIDGE_NAME

クライアント名

ルーム内での表示ハンドル

AGENT_BRIDGE_ROOM

ワークスペース由来

ルーム ID の明示指定

AGENT_BRIDGE_STOP_MAX_CONTINUES

2

Stop フックによる連続続行の上限(0 で Stop 自動続行を無効化)

AGENT_BRIDGE_STALL_SECONDS

180

expect_reply メッセージの返信停滞を検知するまでの秒数(0 で停滞検知を無効化)

AGENT_BRIDGE_LAUNCH_COOLDOWN

30

同一ターゲットの連続起動クールダウン秒数


注意事項 / Disclaimer

  • 各クライアント(Antigravity / Claude Code / Codex など)の利用規約に沿った使い方かどうかは、利用者ご自身で確認してください。本プロジェクトは各社の公式ツールではなく、規約への適合を保証するものではありません。

  • bridge_launch(..., launcher="antigravity-ui") は、Antigravity の公開されていない内部 API(ローカルの ConversationService/CreateConversation)を呼びます。仕様変更で動かなくなる可能性があるうえ、規約上の扱いも明確ではありません。明示的に指定したときだけ使われるので、気になる場合は既定の launcher="auto"(可視ターミナルで起動)のままにしてください。

  • 待機リスナーや Stop フックによる自動続行は、人が見ていない間にもエージェントのターンを進めます。max_turns や AGENT_BRIDGE_STOP_MAX_CONTINUES で回数を抑え、無人で長時間動かし続けないようにしてください。

English: This is an unofficial, community project. Check each client's terms of service yourself; no compliance is guaranteed. The antigravity-ui launcher calls an undocumented internal Antigravity API and may break or be disallowed. Auto-continuation (wait listener, Stop hooks) advances agent turns without a human present, so keep the turn caps low and avoid long unattended runs.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      B
      maintenance
      Enables Claude and Codex sessions on the same host to communicate across different session systems via shared SQLite rooms, with named participants, durable ordered messages, offline delivery, and wait-based message handling.
      4
      2
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude Code, Codex and opencode sessions on the same machine to message each other live over a local pipe, with threaded replies and offline queuing, and to delegate or spawn one another as background subagents. Messages persist in SQLite and any running server can take over as broker, so peers stay reachable without a daemon.
      5
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables Claude Code, Codex, and other coding-agent sessions on the same machine to message each other, exchange tracked tasks with owners and states, and coordinate through channels, broadcasts, and multi-session asks without typing into terminals. Messages are routed by what the receiver is doing — next tool call, end of turn, or a held-back digest — so a flood of traffic doesn't interrupt active work.
      254
      14
      70 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coordinating local coding agents across Antigravity, DeepSeek Harness, Claude Code, and OpenCode with persistent tasks, live public events, file-change artifacts, session follow-ups, process-tree cancellation, and configurable execution permissions.
      MIT