Skip to main content
Glama

Bridge Anything

A self-hosted bridge for agent communication, task delegation, and shared project memory.

The preview includes a local MCP server, a task Worker, and an Agent coverage matrix with verification results. See the technical design and Magpie coverage.

Planned: export any supported agent

Bridge Anything's product scope also includes exporting data from any supported agent, following the archive workflow in grok-export-tool. Export is a separate adapter capability from messaging and task delegation. This is a planned requirement; the current release does not provide a universal exporter.

  • Export accessible conversation histories, agent/Bot metadata and rosters, attachments, and original source records where the platform exposes them.

  • Produce portable Markdown, JSON/JSONL, an index, and an agent-readable archive map, preserving source identities, timestamps, and attachment references.

  • Support one conversation/agent or all accessible conversations, text-only export, resumable attachment downloads, and local archive listing and search through CLI and MCP.

  • Track export support and verification independently for every platform. Report unavailable fields and unsupported operations explicitly. A platform's messaging or Worker verification does not establish export support.

The Grok reference covers Bot transcripts and attachments plus regular chat history; its existing MCP tools query Bot archives only. Bridge's requirement generalizes export and archive access across supported agents. Adapters must use operator-authorized sources and must not create new chats during export or include credentials in archives. See the export design.

Related MCP server: relaycore

Export local agent history (source checkout)

Configure an operator-owned private archive directory and named history roots. The current source supports Pi v3, Codex, Claude Code, Qoder / Qoder CN, WorkBuddy / WorkBuddy AI / CodeBuddy native JSONL histories, Hermes physical SQLite histories, and OpenCode legacy JSON / V1 / V2 SQLite histories. These readers have native-schema fixture coverage; they do not establish live-account or attachment export support. Other local agents remain in progress. Grok online sources are described below. See export coverage.

mkdir -m 700 ./archive

Add this to the same Bridge configuration. Paths are relative to its file:

{
  "archive": {
    "root": "./archive",
    "sources": {
      "pi-work": {"project": "demo", "kind": "pi", "root": "/absolute/path/to/pi/sessions"},
      "codex-work": {"project": "demo", "kind": "codex", "root": "/absolute/path/to/.codex/sessions"},
      "claude-work": {"project": "demo", "kind": "claude", "root": "/absolute/path/to/.claude/projects"},
      "qoder-work": {"project": "demo", "kind": "qoder", "root": "/absolute/path/to/.qoder/projects"},
      "buddy-work": {"project": "demo", "kind": "workbuddy", "root": "/absolute/path/to/.workbuddy/projects"},
      "hermes-work": {"project": "demo", "kind": "hermes", "root": "/absolute/path/to/hermes-profile"},
      "opencode-work": {"project": "demo", "kind": "opencode", "root": "/absolute/path/to/opencode-data"}
    }
  }
}

Other explicit local kinds are qoder-cn, workbuddy-ai and codebuddy. Configure each platform/profile with its own named source and history root. WorkBuddy-family exports preserve the full user context, tools, usage metadata and user-selected titles. Append-only item updates appear once in normalized text; every original record remains in raw JSON.

Hermes roots contain state.db. Export queries a private DB/WAL snapshot and retains physical rows in messages.id order, including compaction/display flags; this is the ALL view, not the active or deduplicated UI transcript. Configuration metadata is parsed and filtered; attachments remain unimplemented. Bad or oversized sessions appear in errors while healthy sessions continue. SQL size preflight runs before payload extraction and uses a conservative byte budget.

OpenCode reads opencode.db or legacy storage/session, storage/message and storage/part trees under its source root. Set operator-only databaseName for another database basename; an explicitly selected missing database fails rather than switching to legacy history. Automatic mode falls back only when the default database is absent. Existing bad/unsupported databases never trigger legacy fallback. Database migration state selects V1/V2 sessions without mixing stale JSON; message/part order follows each pinned native serializer. Structured metadata credential fields are filtered before text/raw serialization; changed raw cells are marked rather than retaining unfiltered original bytes. Media remains raw references; no referenced file or URL is fetched.

Source and archive directory trees must not overlap. Only configure history you intend to share with every identity granted that project. The same five tools are available to CLI, stdio MCP and authenticated HTTP MCP clients; no additional tools are registered without archive config. Use node src/cli.ts in a source checkout or the built CLI after pnpm build:

node src/cli.ts call ./bridge.json owner export_sources '{"project":"demo"}'
node src/cli.ts call ./bridge.json owner export_run '{"project":"demo","source":"pi-work","limit":5}'
node src/cli.ts call ./bridge.json owner archive_list '{"project":"demo","source":"pi-work"}'
node src/cli.ts call ./bridge.json owner archive_read '{"project":"demo","source":"pi-work","id":"session-id","limit":20}'
node src/cli.ts call ./bridge.json owner archive_search '{"project":"demo","source":"pi-work","query":"release"}'

export_run handles at most ten files or Hermes conversations per call. Pass its nextCursor to continue while history is unchanged. Hermes cursors bind to the database revision. Inspect errors on every page, including the last one; a null cursor only ends the inventory scan. Retry failed files by starting again without a cursor. Stable message IDs prevent duplicate appends. If history changes, restart the scan; a stale cursor is rejected. JSONL archive conversation IDs distinguish source files so revert rollouts and subagent files cannot overwrite one another. WorkBuddy-family archive identities remain stable if a file acquires its native session ID later. Original native IDs remain in raw metadata; missing IDs are marked as derived. Use IDs returned by export/list. Missing message IDs in older Codex rollouts receive a session/file/record-position-derived ID.

Each source/project archive has an authoritative archive.json, an index.md, an AGENTS.md map, and SHA-256-named .md, .jsonl and .json conversation views. Metadata and original parsed records are retained, with credential-named fields redacted. JSONL branches and non-message events are preserved as source records; normalized text is a projection in file order, not active-branch replay. Images, thinking and tool-call blocks remain in raw records; these local readers do not extract or download attachments. Secrets embedded in transcript text are not automatically detected. Treat exported text as private, untrusted data.

Complete local exports keep the latest source's message order. Messages missing from a later source snapshot remain as retained archive history, displayed in a separate Markdown section. Their archive order does not imply native chronology. List/read results include sourceMessageCount and retainedMessageCount when known; read/search messages and portable JSONL include inLatestSource flags. This means presence in the exported physical projection, not an agent's active UI context. Older archives and incremental exports omit these fields until a complete local refresh establishes membership. Remote export merge behavior is unchanged.

Archive list/read/search work offline. Tool text pages are limited to 256 KiB; raw records remain in the local archive. Native files over 32 MiB and per-source archives over 64 MiB fail explicitly. A changed source configuration selects a separate archive. Interrupted writer locks require operator inspection before removal. These are current limits, not completion of universal export.

Export Grok chats and Bots (source checkout)

Grok online sources use the account credentials explicitly supplied by the operator. They read existing history through grok.com's app-chat HTTPS and Bot WebSocket interfaces, following grok-export-tool. They never send new chats or trigger Bot runs. Protocol and attachment fixtures are verified; a live grok.com account has not yet been verified.

Add named sources under the same archive.sources configuration:

{
  "grok-chats": {"project": "demo", "kind": "grok-chat", "account": "personal", "cookieEnv": "GROK_EXPORT_COOKIE"},
  "grok-bots": {"project": "demo", "kind": "grok-bot", "account": "personal", "cookieEnv": "GROK_EXPORT_COOKIE"}
}

Set GROK_EXPORT_COOKIE in the launching process environment to your sso and optional sso-rw cookie header. Only these two cookie names are accepted. The configuration stores the variable name, not the cookie. Use distinct source IDs and account labels for different account/profile logins. No browser cookie store is read or decrypted. The project grants apply to online and archived data.

node src/cli.ts call ./bridge.json owner export_run '{"project":"demo","source":"grok-chats","limit":5}'
node src/cli.ts call ./bridge.json owner export_run '{"project":"demo","source":"grok-bots","limit":1}'
node src/cli.ts call ./bridge.json owner export_run '{"project":"demo","source":"grok-bots","textOnly":true}'

Follow nextCursor and inspect errors on every page. Chat pages contain existing conversations and load their existing response IDs in batches of 50. Bot pages contain roster entries and their paginated transcripts. Original metadata, raw records, timestamps, non-message events and attachment references are retained. The tools archive_list, archive_read and archive_search work on both sources offline, including when the cookie environment variable is no longer present.

Bot exports download recognized local Bot attachment references by default; textOnly: true skips downloads and preserves previously verified links when source records are unchanged. Verified bytes use immutable SHA-256 filenames under the source's attachments/ directory; Markdown and JSONL include local references. Failed refreshes retain previous verified files and links. Each chunk is at most 4 MiB and each attachment is limited to 2 GiB. Private partial files and durable checkpoints survive a cancelled transfer. Retry the same export to resume: saved prefix bytes are revalidated remotely before appending. The protocol supplies no version/hash, so completed files are downloaded again on refresh rather than assumed current solely from size.

Ordinary chat attachment references remain in raw records; downloading those files is not supported by the inspected reference protocol. export_sources and each result state attachment support separately. A completed inventory scan does not establish that every conversation or attachment succeeded.

Each Grok history is limited to 8 MiB of accumulated upstream records and 10,000 message/entry records; Bot history has at most 1,000 transcript pages. Source snapshots still have the archive's 64 MiB limit. Oversized or malformed histories fail explicitly. Each network request/RPC has a 15-second timeout; HTTP/transcript-only operations have a 60-second overall deadline. Attachment- enabled Bot calls use caller cancellation and per-RPC limits so full prefix verification cannot consume the same fixed deadline on every retry. The CLI allows up to 24 hours for export_run; other MCP clients control their request timeout. MCP cancellation closes the remote connection and preserves the attachment checkpoint. Durable background export jobs are still in progress.

Install the release CLI

Download the bridge-anything-<version>.tgz asset from GitHub Releases. With Node.js 22.18 or newer, install it into a local project:

npm install ./bridge-anything-0.15.0.tgz
npx bridge-anything --help

You can point MCP clients directly at the installed bridge-anything binary. Its arguments are mcp <config.json> <principal>. The examples below also work from a source checkout.

Discover and call tools from the local CLI

Use tools <config.json> <principal> to list tool names, input schemas, and annotations as JSON.

Use call <config.json> <principal> <tool> [json|-] with a configured local principal. The command validates the same tool schemas and project grants as stdio MCP. It prints the structured result as JSON and exits nonzero if the call fails. Pass - to read the JSON object from stdin.

bridge-anything tools ./bridge.json claude
bridge-anything call ./bridge.json claude inbox_list '{"project":"demo"}'
printf '%s\n' '{"project":"demo","recipient":"codex","body":"Ready for review","key":"review-1"}' |
  bridge-anything call ./bridge.json claude send_message -

Run the local MCP server

Use Node.js 22.18 or newer. Install runtime dependencies with pnpm install.

Create a local configuration file. The database path is relative to the configuration file.

{
  "database": "./bridge.sqlite",
  "grants": {
    "claude": ["demo"],
    "codex": ["demo"]
  }
}

Configure a local MCP client to start node with these arguments:

/absolute/path/to/bridge-anything/src/cli.ts mcp /absolute/path/to/config.json claude

Use codex as the configured identity for the second client. Both processes must use the same database. The operator controls the client launch arguments and filesystem access. A user who can choose the identity or directly access the SQLite file has access beyond the MCP project grants.

Call send_message with a project, recipient, body, and retry key. The recipient can use inbox_list, reply with reply, and then call acknowledge. Use memory_put with expected version 0 to create a shared memory entry. Read its current version with memory_get before updating.

Test

pnpm test

The integration test starts two local processes with the MCP SDK and exercises message delivery and reply correlation. Platform verification is tracked independently of this fixture.

Run a task worker

Add a commands object to the local configuration. Each key must match a granted target identity. For a local fixture on macOS or Linux:

{
  "commands": {
    "codex": {"command": "/bin/cat", "cwd": ".", "timeoutMs": 2000}
  }
}

Run node src/cli.ts worker ./config.json to process the queue, or add --once to handle up to one queued task. Submit with delegate_task and retrieve the result with task_get. Commands use stdin by default. Configure an explicit inheritEnv array if a target needs environment variables. A configured command runs with the worker account's filesystem access. The fixture uses the target identity only to demonstrate the protocol.

Connect over HTTP

Add an http object to the same configuration:

{
  "http": {
    "port": 8870,
    "tokenEnvByPrincipal": {
      "claude": "BRIDGE_CLAUDE_TOKEN",
      "codex": "BRIDGE_CODEX_TOKEN"
    }
  }
}

Set an independently generated token for each configured identity. The server accepts tokens of at least 32 URL-safe characters. Run node src/cli.ts serve ./config.json and point a Streamable HTTP MCP client at http://127.0.0.1:8870/mcp with an Authorization: Bearer <token> header.

The server listens on IPv4 loopback. For remote access, terminate TLS at a trusted reverse proxy and forward the upstream Host as 127.0.0.1:8870. This entry point targets non-browser clients using configured Bearer tokens. For OAuth clients, configure an external authorization server as described below.

See the platform support matrix for Agent presets and verification status.

Discover targets and configure default routes

Use targets_list with a project ID to see its target identities and which ones accept delegated tasks. You can send to an explicit target or omit the target to use a configured route. A route with the caller's principal takes precedence over a project-wide default. Both the caller and the resolved target must have a grant for the project.

{
  "routes": [
    {"project": "demo", "target": "codex"},
    {"project": "demo", "principal": "codex", "target": "claude"}
  ]
}

Both inbox_list and memory_list accept an optional limit (1–100, default 20) and cursor. Pass the returned nextCursor in the next call with the same project. A null cursor means the page is the last one. For subsequent inbox scans, omit the cursor to include any earlier messages that still need acknowledgement.

Run one worker per database on a local filesystem. The worker holds an exclusive lock while running. On restart it marks previously running tasks as interrupted and continues processing queued tasks. An operator can inspect interrupted work before explicitly submitting a new task.

Receive signed webhooks

Under http.webhooks, configure a route by name with sender, project, optional target, and secretEnv. Grant the configured sender access to the project. Assign a distinct sender and randomly generated secret to each route.

POST a JSON object with a string body to /webhooks/<name>. Send these headers:

  • X-Bridge-Delivery with a stable delivery ID.

  • X-Bridge-Timestamp with the current Unix timestamp in seconds.

  • X-Bridge-Signature with the hex HMAC-SHA256 of the timestamp, a period, the delivery ID, another period, and the exact request body bytes.

The server accepts timestamps within five minutes. To retry later, sign again with a fresh timestamp and the same delivery ID and message. Successful requests return HTTP 202 and the durable message ID.

Use from deepseek-super-agent

Register Bridge as a stdio MCP server in DS_AGENT_MCP_SERVERS:

[{
  "name": "bridge",
  "command": "/absolute/path/to/node",
  "args": [
    "/absolute/path/to/bridge-anything/src/cli.ts",
    "mcp",
    "/absolute/path/to/bridge-config.json",
    "deepseek"
  ]
}]

Grant the deepseek identity access to the intended projects in Bridge. The downstream harness exposes tools such as mcp__bridge__send_message. With both checkouts' dependencies installed, run the offline cross-project contract check:

node --experimental-transform-types scripts/verify-deepseek-mcp.mjs /path/to/deepseek-super-agent

To verify an installed release, append the installed package's dist/cli.js path as the second argument:

node --experimental-transform-types scripts/verify-deepseek-mcp.mjs /path/to/deepseek-super-agent /path/to/node_modules/bridge-anything/dist/cli.js

Telegram channel

Run one polling process per bot, with webhook delivery disabled for that bot. On SIGINT or SIGTERM, the polling process finishes its current poll and reply delivery before closing SQLite. Add a dedicated Bridge identity and grant it access to the intended project. Keep this identity reserved for the Telegram process.

{
  "telegram": {
    "tokenEnv": "TELEGRAM_BOT_TOKEN",
    "chatId": -123456789,
    "userIds": [12345678],
    "identity": "telegram",
    "project": "demo",
    "target": "codex"
  }
}

Run node src/cli.ts telegram ./config.json. Text from the configured chat and allowed user IDs is delivered to the target inbox. When the target uses reply, Bridge replies to the original Telegram message. Incoming updates are deduplicated. Outgoing delivery uses at-least-once semantics, so if Telegram accepts a reply before Bridge can acknowledge it locally, it can be repeated. Telegram replies are limited to 4096 characters.

The Telegram Bot API fixture verifies the round trip without external credentials. Live bot validation requires an authorized bot and test chat.

Inspect the local audit trail

Run bridge-anything audit ./config.json as the operator to read the first 100 audit records. Pass the last sequence as the optional third argument to continue reading. The audit logs persist message mutations, task transitions, and memory writes in the same SQLite transactions as their effects. It records identity, project, object ID, timestamp, and outcome. Message bodies, task prompts and results, and memory values are excluded. Audit access is local and requires the same filesystem privileges as operating the Bridge database.

Use an OAuth authorization server

Bridge can advertise its protected resource and verify access tokens through an existing authorization server's token introspection endpoint. To enable it, add the following under http.oauth:

{
  "issuer": "https://identity.example",
  "resource": "https://bridge.example/mcp",
  "introspectionUrl": "https://identity.example/oauth/introspect",
  "clientId": "bridge-introspector",
  "clientSecretEnv": "BRIDGE_INTROSPECTION_SECRET",
  "principalBySubject": {"identity-provider-subject": "claude"}
}

The introspection client authenticates with form credentials. Configure the authorization server to issue access tokens scoped to bridge:access with the Bridge MCP resource as the audience. Introspection must report the token's active status, issuer, audience, subject, expiry, and scopes. Each mapped identity needs a Bridge project grant. Forward both /mcp and /.well-known/oauth-protected-resource/mcp through the HTTPS reverse proxy. OAuth client registration and user sign-in are handled by the authorization server.

A requester can use task_cancel on a queued or running task. A queued task is cancelled immediately. For a running task, Bridge records cancelRequested: true. The Worker attempts to terminate the managed agent process and reports cancelled once that exit is confirmed. If the process finishes before it sees the request, Bridge records its actual result.

Delegate to an ACP agent

Configure a target with an executable that speaks Agent Client Protocol over stdio. For example, Kimi Code 2.x exposes ACP with the acp subcommand:

{
  "commands": {
    "kimi": {
      "command": "/absolute/path/to/kimi",
      "args": ["acp"],
      "cwd": "./workspace",
      "promptMode": "acp",
      "inheritEnv": ["PATH", "KIMI_CODE_HOME", "KIMI_API_KEY"]
    }
  }
}

The Worker opens a fresh ACP session for each task, submits the prompt, and stores the returned text. Bridge declines ACP permission requests and offers no client filesystem or terminal capabilities. The selected Agent's own workspace access and permissions also apply. Timeouts and cancellation use the Worker process lifecycle. For an adapter that handles SIGTERM, set stopGraceMs to allow cleanup before Bridge sends SIGKILL.

To advertise a stdio MCP server to the Agent in each ACP session, add acpMcpServers to that command target. For example, a target named kimi with its own Bridge project grant can advertise:

{
  "acpMcpServers": [{
    "name": "bridge",
    "command": "/absolute/path/to/node",
    "args": ["/absolute/path/to/bridge-anything/dist/cli.js", "mcp", "/absolute/path/to/bridge.json", "kimi"]
  }]
}

The Agent starts the connector and applies its own MCP policies. The configured executable path must be absolute. The optional env array contains explicit {"name": "...", "value": "..."} entries. These values are transmitted in the ACP session request. Keep secrets out of the configuration.

If the ACP server requires an explicit authentication request, add acpAuthMethod to the target using the method ID advertised at initialization. Bridge rejects an unavailable method and asks the Agent to use its headless authentication flow before starting the session. Configure any required credentials through the Agent's credentials store or the target's environment allowlist. The method ID itself is a non-secret string.

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

    • A
      license
      Not graded
      quality
      B
      maintenance
      A local, stdio-based MCP server that lets multiple coding agents share one project database for tasks, verification evidence, signals, knowledge, and conversation indexes. It enforces workflows with allowlisted verification runners and gate checks on acceptance criteria, evidence, dependencies, and high-risk approval before work can be closed.
      605 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Real-time coordination MCP server for coding agents (Claude Code, Codex, Gemini CLI, Antigravity, Cursor, Windsurf, Copilot, VS Code). Provides shared #channels, @agent DMs, pinned task boards, server-held read watermarks, a live swimlane web UI, and zero-token background watching.
      5
      12
      MIT