Skip to main content
Glama

Harness Bridge

CI M8ven Score Discussions License: MIT

Harness Bridge is a lightweight, harness-agnostic inter-agent proxy and Model Context Protocol (MCP) server for AI coding agents. It enables CLI-based harnesses (such as Claude Code and Antigravity CLI) to interoperate seamlessly, dispatching tasks, executing code in isolated sandboxes, and collaborating across distinct machines and subscription accounts.


Harness Bridge — Proposed Final Architecture

One central broker. Local MCP adapters for agents. Lightweight native workers for execution.

Recommended Architecture • Distributed-Ready

flowchart TD
    subgraph MachineA["Machine A — Orchestrator"]
        ClaudeA["Claude Code CLI"]
        MCPAdapterA["Local MCP Adapter\n(harness-bridge adapter)"]
        ClaudeA -->|"MCP over stdio"| MCPAdapterA
    end

    subgraph CentralBroker["Central Infrastructure — Docker (Zero Host Mounts)"]
        MCPServer["MCP Server\n(/sse · /mcp)"]
        RelayBus["Relay Bus\n(SQLite WAL · Task Queue)"]
        WorkerGW["Worker HTTP/SSE Gateway\n(/api/v1/workers/*)"]
        Health["Health Probe\n(/health)"]

        MCPServer <--> RelayBus
        RelayBus <--> WorkerGW
    end

    subgraph MachineB["Machine B — Execution"]
        WorkerB["Native Worker Runtime\n(harness-bridge worker run / service)"]
        HarnessB["Antigravity CLI (agy)"]
        StorageB["Local Filesystem & Auth\n(/srv/sources · /srv/data · ~/.gemini)"]

        WorkerB -->|"Native subprocess"| HarnessB
        HarnessB -->|"Direct access"| StorageB
    end

    subgraph MachineC["Machine C — Execution (Optional)"]
        WorkerC["Native Worker Runtime\n(harness-bridge worker run / service)"]
        HarnessC["Claude Code CLI / Other"]
        WorkerC -->|"Native subprocess"| HarnessC
    end

    MCPAdapterA -->|"MCP over HTTP/SSE"| MCPServer
    WorkerGW -->|"Server-Sent Events (Task Push)"| WorkerB
    WorkerB -->|"HTTP POST (Acks / Results / Heartbeats)"| WorkerGW
    WorkerGW -.->|"Server-Sent Events"| WorkerC
    WorkerC -.->|"HTTP POST"| WorkerGW

1. Component Responsibilities

Component

Runs Where

Responsibility

MCP Adapter

Agent machine

Exposes broker tools to local AI agents over stdio

MCP Server

Central Docker Broker

Exposes standard MCP tools over SSE and streamable HTTP (/sse, /mcp)

Relay Bus

Central Docker Broker

Manages task queue, leases, sessions, and state machines

Worker Gateway

Central Docker Broker

Real-time SSE task delivery (/api/v1/workers/events) and HTTP result ingestion

Native Worker

Execution machine

Connects outward via SSE; executes tasks with local tools

Harness CLI

Execution machine

Runs agy, claude, etc. natively on the host

2. Communication Protocols

Connection

Protocol

Characteristics

Claude / Agent → MCP Adapter

MCP over stdio

Standard MCP JSON-RPC protocol; agent sees zero network complexity

MCP Adapter → Broker

MCP over HTTP/SSE

Remote tool routing over network

Broker → Worker

Server-Sent Events (SSE)

Event-driven push; worker holds open connection at 0% idle CPU

Worker → Broker

HTTP POST

Task acknowledgements, progress heartbeats, and result payloads

Worker → Harness CLI

Native subprocess execution

Direct host execution with access to local files, tools, and auth

Note: The worker never needs to speak MCP. Agents communicate through MCP; machines communicate through the relay protocol; execution happens locally.

3. Installation Experience

Central Broker

Run the decoupled broker with zero host volume mounts:

./install.sh --docker
# or manually via Docker:
docker run -d \
  --name harness-bridge \
  --restart unless-stopped \
  -p 8000:8000 \
  -v harness-bridge-data:/home/bridge/.harness-bridge \
  sukumar1210/harness-bridge:latest

Orchestrator Machine (Local Agent MCP Setup)

harness-bridge setup --force

Execution Machine — Foreground

harness-bridge worker run --server http://<broker-ip>:8000

Execution Machine — Persistent OS Service (Optional)

Install and manage as a native user service (systemd --user on Linux, launchd on macOS):

# Install and auto-start user service
harness-bridge worker service install --server http://<broker-ip>:8000

# Service lifecycle commands
harness-bridge worker service status
harness-bridge worker service stop
harness-bridge worker service start
harness-bridge worker service restart
harness-bridge worker service uninstall

4. Architectural Invariants

  • 01: No Docker host mounts: The broker never accesses execution-machine filesystems. It remains 100% portable and decoupled from host directories, disk structures, and UIDs.

  • 02: No mandatory OS services: Workers can run interactively in the foreground (harness-bridge worker run) or as managed user services (harness-bridge worker service install).

  • 03: No agent polling: SSE event-driven task push eliminates polling latency, CPU waste, and agent context exhaustion.

  • 04: No unnecessary MCP servers: Only agent-facing machines require MCP adapters. Execution machines only run the lightweight native worker daemon.

  • 05: Native execution: Workers have direct access to local host tools, CLIs, local repositories (/srv/sources), datasets (/srv/data), and user credentials (~/.gemini).

  • 06: Independent scaling: Scale execution machines horizontally without modifying the broker.

5. Implementation Details

  • Worker Authentication & Identity: Automatic hardware- and PID-derived machine identity (worker_id) with optional bearer tokens (HARNESS_BRIDGE_TOKEN).

  • Sliding Leases & Heartbeats: 45-second sliding task leases with automatic heartbeats, reconnection recovery, and graceful re-queuing on worker disconnection.

  • Task Acknowledgement & Idempotence: Explicit task state machine transitions (pending → leased → acknowledged → running → completed / failed).

  • Durable State: SQLite WAL-backed relay bus retains task status and lease records across network interruptions and container restarts.

  • Zero Exposed Host Credentials: Host credentials and OAuth tokens remain strictly local on the execution machine.

Final Design Decision: 1 Broker + N Adapters + N Native Workers

  • 1 Central Broker: Handles state, queueing, and MCP routing with zero host mounts.

  • N MCP Adapters: Provides stdio MCP interfaces to local AI agents.

  • N Native Workers: Executes tasks natively with local tools and credentials.



Related MCP server: native-agent-router

Features

  • Standard Model Context Protocol (MCP) Server: Exposes standard tools (bridge_list_harnesses, bridge_dispatch_task, bridge_apply_diff, bridge_get_session, bridge_close_session) that any MCP-compliant agent can invoke directly.

  • Dedicated Native Drivers: Built-in, headless drivers for Claude Code (claude) and Antigravity CLI (agy) with conversational continuity across turns via native session resumption flags (--resume / --conversation).

  • Workspace Sandboxing via Git Worktrees: Ephemeral git worktrees (.worktrees/<session_id>) prevent concurrent file clobbering. Review generated diffs safely before applying them with bridge_apply_diff.

  • Kernel Buffer & Protocol Deadlock Prevention: Asynchronous execution via proc.communicate() wrapped with timeouts eliminates 64KB Linux pipe buffer deadlocks. All server logs route strictly to stderr to preserve clean JSON-RPC framing.

  • Distributed Loop Protection: Injects HARNESS_BRIDGE_TRACE_ID and HARNESS_BRIDGE_HOP_COUNT into child processes to prevent recursive agent fork bombs.

  • Self-Updating: Built-in harness-bridge update command syncs with GitHub Releases and updates in-place via pre-compiled .whl distribution assets.


Quick Start & Installation

Bootstrap Harness Bridge in a single command. The installer automatically detects your environment, offers a choice between Docker and Local CLI, and registers the MCP server in your installed coding harnesses (Claude Code, Antigravity):

Linux & macOS:

curl -fsSL https://raw.githubusercontent.com/sukumar1210/harness-bridge/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/sukumar1210/harness-bridge/main/install.ps1 | iex

In interactive terminals, the installer prompts between Docker (Recommended) and Local installation. In automated or CI/CD environments, it auto-detects the runtime (or accepts --docker / --local / -y flags).


Manual Installation Options

If you prefer installing manually without running scripts:

Option 1: Docker (Central Broker — Zero Host Volume Mounts)

Pull and run the pre-built multi-architecture broker container from Docker Hub with zero host mounts:

docker run -d \
  --name harness-bridge \
  --restart unless-stopped \
  -p 8000:8000 \
  -v harness-bridge-data:/home/bridge/.harness-bridge \
  sukumar1210/harness-bridge:latest

# Connect your agent harnesses to the broker
claude mcp add --transport sse -s user harness-bridge http://localhost:8000/sse
agy mcp add harness-bridge http://localhost:8000/sse

# Start the native worker on your execution machine to run tasks
harness-bridge worker run --server http://localhost:8000

The central broker manages task leases, state, and queues without mounting host filesystems. Native workers connect outward via SSE and execute tasks with local tools.

See the Docker Guide for custom port mappings, Docker Compose, and production deployment options.

Option 2: Local Host CLI (pip / venv)

Install the CLI into your user environment:

# Install via pip
pip install harness-bridge

# Register into Claude Code and Antigravity (uses on-demand stdio)
harness-bridge setup

Option 3: From Source (uv)

Clone the repository for local development:

git clone https://github.com/sukumar1210/harness-bridge.git
cd harness-bridge
uv sync

# Register local editable build
uv run harness-bridge setup

Re-running Setup

If you reinstall Claude Code, update your Antigravity configuration, or switch between Docker and local runtimes, re-run setup at any time to repair harness registrations:

./setup.sh
# or on Windows:
.\setup.ps1
# or via CLI:
harness-bridge setup

Multi-Device & Network Access

By default, local CLI installations run on-demand via standard MCP stdio (zero open ports, zero idle RAM). If you want other devices across your local network (LAN) to connect to Harness Bridge:

  • Via Docker: Run the container with -p 8000:8000 (exposed by default in Docker mode). Other devices on the LAN can connect to http://<HOST-IP>:8000/sse.

  • Via Local Host CLI: Launch the server explicitly in network mode:

    harness-bridge serve --transport unified --host 0.0.0.0 --port 8000

Manual Registration by Harness

Harness Bridge exposes a standard Model Context Protocol (MCP) server over standard I/O (stdio). You can also register it manually in any MCP-compliant harness or IDE:

1. Claude Code

Register Harness Bridge directly using the claude CLI:

claude mcp add harness-bridge -- harness-bridge serve

Alternatively, add it directly to your project or user configuration (~/.claude.json):

{
  "mcpServers": {
    "harness-bridge": {
      "command": "harness-bridge",
      "args": ["serve"]
    }
  }
}

2. Antigravity CLI (agy)

Register Harness Bridge using the agy CLI:

agy mcp add harness-bridge harness-bridge serve

Or configure it in your Antigravity MCP settings (~/.gemini/antigravity-cli/mcp_config.json):

{
  "mcpServers": {
    "harness-bridge": {
      "command": "harness-bridge",
      "args": ["serve"]
    }
  }
}

3. Cursor

In Cursor:

  1. Navigate to Cursor Settings > Features > MCP Servers.

  2. Click + Add New MCP Server.

  3. Fill in:

    • Name: harness-bridge

    • Type: command

    • Command: harness-bridge serve (or ~/.local/bin/harness-bridge serve if not in global PATH)

4. Windsurf (Codeium Cascade)

Add the server configuration to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "harness-bridge": {
      "command": "harness-bridge",
      "args": ["serve"]
    }
  }
}

5. Claude Desktop

Add to your claude_desktop_config.json (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):

{
  "mcpServers": {
    "harness-bridge": {
      "command": "harness-bridge",
      "args": ["serve"]
    }
  }
}

6. Generic MCP Clients / Zed / Goose

Any client supporting JSON-RPC stdio transport can connect to Harness Bridge:

  • Executable: harness-bridge (or $HOME/.local/bin/harness-bridge)

  • Arguments: ["serve"]

  • Transport: stdio


CLI Usage

# List available harnesses on system PATH
harness-bridge list

# Check current version
harness-bridge version

# Check for updates from GitHub Releases
harness-bridge update --check

# Self-update to the latest release
harness-bridge update

# Run a one-shot task directly
harness-bridge run --target agy "Inspect README.md and explain the architecture"

# Start the MCP server manually
harness-bridge serve

# Start native worker daemon in foreground
harness-bridge worker run --server http://localhost:8000

# Install and manage persistent background worker service (systemd/launchd)
harness-bridge worker service install --server http://localhost:8000
harness-bridge worker service status
harness-bridge worker service stop
harness-bridge worker service start

# Run local MCP adapter proxying stdio to remote broker over SSE
harness-bridge adapter --server http://localhost:8000

Architecture & System Internals (For Developers)

Subdirectories & System Boundaries

Architectural Invariants

  • Stdio Transport Protocol Purity: During harness-bridge serve, standard output (stdout) is strictly reserved for JSON-RPC 2.0 frames. All diagnostics, progress spinners, and log messages route strictly to stderr.

  • Subprocess Pipe Deadlock Immunity: Cross-platform process execution in run_command_safe binds stdin to DEVNULL and reads output via proc.communicate(), eliminating 64KB OS pipe deadlocks.

  • Process Group Termination: Child subprocesses are spawned in detached process groups (process_group=0 on POSIX) and terminated recursively with SIGTERM/SIGKILL escalation on timeout.

  • Workspace Sandboxing Integrity: Tasks executed under worktree isolation operate strictly within ephemeral .worktrees/{session_id} directories and dedicated bridge/session-{session_id} branches, never modifying the primary working tree until explicitly merged via bridge_apply_diff.

  • Distributed Delegation Recursion Ceiling: Inter-agent delegation propagates HARNESS_BRIDGE_TRACE_ID and increments HARNESS_BRIDGE_HOP_COUNT, raising MaxHopsExceededError if recursion depth reaches max_hops (default: 10).

System Side Effects

  • Child Subprocess Execution: Spawns headless external AI coding harness CLIs (claude, agy) and git processes.

  • Repository Worktree & Branch Mutation: Creates and removes .worktrees/{session_id} directories and mutates local git branches (bridge/session-*).

  • Harness MCP Configuration Writes: Reads and updates configuration files across user directories (~/.claude.json, ~/.gemini/antigravity-cli/mcp_config.json, ~/.gemini/config/mcp_config.json).

  • Network Egress: Issues HTTPS requests to api.github.com for release checks and updates, downloading .whl assets when upgrading.

Development Verification

  • Run tests: uv run pytest -v tests/

  • Run lint & formatting: uv run ruff check . and uv run ruff format .


Contributing

Contributions, issues, and feature requests are welcome!


License

MIT © Sukumar Rastogi

Available Tools

6 tools
bridge_apply_diffA

Apply the code changes generated by a worker in an isolated git worktree branch into the main repository. After applying, call bridge_close_session(session_id, cleanup_worktree=True) to clean up the temporary worktree.

Args: session_id: Session ID whose worktree branch should be applied. repo_root: Path to the target git repository (defaults to current directory).

Inputs: session_id (required), repo_root. Returns: object

bridge_cancel_sessionB
DestructiveIdempotent

Cancel an active or running task session and terminate its subprocess group.

Args: session_id: Session ID to cancel.

Inputs: session_id (required). Returns: object

bridge_close_sessionB
DestructiveIdempotent

Close a session and clean up temporary worktrees.

Args: session_id: Session ID to terminate. repo_root: Path to target repository. cleanup_worktree: Whether to remove the worktree folder on disk (default: True).

Inputs: session_id (required), repo_root, cleanup_worktree. Returns: object

bridge_dispatch_taskA

Dispatch a coding task or conversational turn to a target AI agent harness (e.g. 'claude' or 'agy'). Use this tool to delegate dev work (feature implementation, bug fixes, refactoring), code and security reviews, or technical exploration and architectural prototyping to another agent.

Args: harness: Target harness name ('claude', 'agy', or 'antigravity'). prompt: Task instructions or follow-up prompt. session_id: Optional existing session ID for conversational resumption. workspace_mode: Workspace isolation mode. Defaults to 'inherit' (executes directly in the same repository and directory). Set to 'worktree' when delegating risky refactors, speculative implementations, parallel experiments, or tasks requiring an isolated branch diff review before applying. When using 'worktree', always review the resulting diff, apply it via bridge_apply_diff if approved, and clean up the temporary worktree when done using bridge_close_session(session_id, cleanup_worktree=True). timeout_seconds: Execution timeout in seconds (default: 300). repo_root: Path to target git repository (defaults to current directory). detach: If True, dispatches the task asynchronously in the background and returns the session_id immediately to prevent client timeouts on long turns. Poll or retrieve output via bridge_get_session.

Inputs: prompt (required), harness (required), detach, repo_root, +3 more. Returns: object

bridge_get_sessionB
Read-onlyIdempotent

Retrieve tracking details, output, diff, and token usage for an active or past session.

Args: session_id: Session ID to inspect.

Inputs: session_id (required). Returns: object

bridge_list_harnessesA
Read-onlyIdempotent

List all registered agent harnesses, their binary names, and installation status on system PATH.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation4/5

    Most tools target clearly distinct operations (list harnesses vs. dispatch task vs. apply diff). The main ambiguity is between bridge_cancel_session and bridge_close_session, which both terminate sessions; descriptions differentiate them (subprocess termination vs. worktree cleanup) but an agent could still misselect. The dispatch description's embedded workflow references to apply_diff and close_session help tie the set together.

    Naming Consistency5/5

    All six tools use a uniform bridge_ prefix followed by a verb_noun pattern (list_harnesses, dispatch_task, cancel_session, apply_diff, get_session, close_session). No mixed conventions or stylistic deviations.

    Tool Count5/5

    Six tools is tightly scoped to the dispatch-and-manage-session domain, with each tool covering a distinct lifecycle step. Nothing feels redundant or missing at this size.

    Completeness4/5

    The surface covers the full dispatch lifecycle: discover harnesses, dispatch (sync or detached), inspect output/diff, apply results, cancel, and clean up. The one notable gap is the lack of a list/inspect-active-sessions tool, so an agent that loses a session_id from a detached dispatch has no recovery path.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Delegate coding tasks to external AI coding agents in isolated git worktrees with independent verification, enabling any MCP client to orchestrate multi-agent workflows.
      5
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to spawn, parallelize, and synchronize multi-agent programming swarms through a stdio MCP interface. Provides tools for DAG-scheduled task dispatch, isolated Git worktree execution, atomic file locking, shared blackboard memory, and clean merging of completed agent work back to the main repository.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an orchestrating agent to delegate tasks to Codex, Claude, or Gemini worker CLIs running in isolated git worktrees, then wait on jobs, inspect per-file diffs, and merge or discard the resulting changes before anything touches the working tree.
      1
      MIT