agentbridge 0.2.0

Connect AI brains to local coding agents through MCP
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
# AgentBridge

**Decouple AI reasoning from code execution.**

Use one AI as the **Brain** and another as the **Executor**.

AgentBridge connects web-based AI assistants such as **Gemini, ChatGPT, and Claude** to local coding agents such as **OpenCode** through MCP, allowing them to collaborate on the same local workspace.

> **Let the AI with the best reasoning access think. Let the coding agent you already pay for execute.**

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Rust](https://img.shields.io/badge/Rust-1.88%2B-orange.svg)](https://www.rust-lang.org/)

---

## Why AgentBridge?

Modern AI coding tools often combine two very different jobs:

1. **Reasoning** — understanding the codebase, investigating problems, designing an implementation, reviewing changes.
2. **Execution** — editing files, running commands, running tests, and applying the implementation.

But the AI product that is best for reasoning is not necessarily the AI product you want to spend your coding-agent quota on.

For example, you may have:

* a web AI account with a generous usage allowance and excellent reasoning;
* a coding CLI subscription with more limited agent usage;
* a local coding workspace where the actual implementation needs to happen.

Without a bridge, you have to choose one AI and use its quota for everything.

**AgentBridge separates these responsibilities.**

```text
             REASONING
        ┌─────────────────┐
        │   Web AI        │
        │ Gemini / Claude  │
        │ ChatGPT / ...   │
        └────────┬────────┘
                 │
                 │ MCP
                 ▼
        ┌─────────────────┐
        │  AgentBridge    │
        │                 │
        │  Read workspace │
        │  Create PLAN    │
        │  Review result  │
        └────────┬────────┘
                 │
             C2C PLAN
                 │
                 ▼
        ┌─────────────────┐
        │    Executor     │
        │    OpenCode     │
        │      / ...      │
        └────────┬────────┘
                 │
          edit / test / run
                 │
                 ▼
        ┌─────────────────┐
        │ Local Workspace │
        └─────────────────┘
```

The important idea is simple:

> **Don't make one AI do everything. Let each AI do the job it is best suited for.**

---

## The Core Concept

AgentBridge introduces two explicit roles.

### 🧠 Brain

The Brain is the AI you use for **reasoning**.

It can:

* inspect your project;
* search the codebase;
* understand architecture;
* investigate bugs;
* design implementation strategies;
* create implementation plans;
* review the changes made by the Executor.

The Brain **does not modify your files**.

It only sees the workspace through AgentBridge's read-only MCP interface.

### 🛠️ Executor

The Executor is the coding agent responsible for **execution**.

It can:

* modify files;
* run commands;
* run tests;
* implement the Brain's plan;
* report the execution result.

In the current version, AgentBridge uses **OpenCode** as the Executor.

The architecture is intentionally designed around an Executor interface so additional coding agents can be integrated later.

### 🌉 AgentBridge

AgentBridge is the layer between them.

It provides:

* MCP access to the local workspace;
* read-only project inspection;
* structured task delegation;
* task lifecycle management;
* execution status;
* Git diff inspection;
* test status;
* result reporting.

The Brain never needs to receive your entire repository in its prompt.

Instead, it explores the real workspace through MCP.

---

# The Workflow

A typical AgentBridge workflow looks like this:

```text
1. User gives a coding task
          │
          ▼
2. Brain inspects the workspace
          │
          ▼
3. Brain reasons about the problem
          │
          ▼
4. Brain creates a compact PLAN
          │
          ▼
5. AgentBridge sends the PLAN to Executor
          │
          ▼
6. Executor edits files and runs tests
          │
          ▼
7. AgentBridge records the result
          │
          ▼
8. Brain inspects git diff + test status
          │
          ▼
9. Brain reviews the implementation
          │
       ┌──┴───────────────┐
       │                  │
      DONE             PLAN AGAIN
                          │
                          ▼
                    another iteration
```

This creates a simple feedback loop:

```text
PLAN → EXECUTE → REVIEW → DONE
             ↑            │
             └── PLAN ────┘
```

The Brain can therefore remain focused on high-value reasoning while the Executor handles the mechanical work of changing the codebase.

---

# Why This Can Save AI Coding Quota

AI coding subscriptions are often metered differently from normal chat or web usage.

A coding agent may consume quota while:

* reading files;
* exploring the repository;
* searching for definitions;
* reasoning about architecture;
* generating an implementation;
* editing files;
* running tests;
* retrying failed implementations.

This means a single coding agent can spend a significant amount of its allowance **before it even starts writing useful code**.

AgentBridge allows you to move the exploratory and reasoning-heavy part to another AI interface.

For example:

```text
Gemini Web
    │
    │ reasoning / architecture / planning
    ▼
AgentBridge
    │
    │ compact implementation plan
    ▼
OpenCode CLI
    │
    │ implementation / tests
    ▼
Your repository
```

Instead of spending your coding-agent quota on the entire conversation, you can reserve it primarily for the part that actually requires local execution.

### The goal is not to bypass quotas.

AgentBridge does not provide additional model credits, circumvent provider limits, or access paid models without authorization.

It simply lets you **route work between the AI services and coding agents you already use**.

---

# A Different Way to Think About AI Coding

Most AI coding workflows look like this:

```text
User
  │
  ▼
One AI
  │
  ├── understand project
  ├── reason
  ├── plan
  ├── edit files
  ├── run tests
  └── review
```

AgentBridge turns it into:

```text
User
  │
  ▼
Brain
  │
  ├── understand
  ├── reason
  ├── plan
  └── review
       │
       ▼
   AgentBridge
       │
       ▼
   Executor
       │
       ├── edit
       ├── run
       └── test
```

This is the fundamental design principle behind AgentBridge:

> **Reasoning and execution are separate resources.**

You can choose the best AI for each one.

---

# MCP as the Bridge

AgentBridge uses the **Model Context Protocol (MCP)** to connect the Brain to your local workspace.

The Brain gets structured tools for inspecting the project:

| Tool                | Purpose                              |
| ------------------- | ------------------------------------ |
| `workspace_info`    | Project information and Git status   |
| `list_directory`    | Explore the workspace                |
| `read_file`         | Read a file                          |
| `search_workspace`  | Search source code                   |
| `git_status`        | Inspect repository state             |
| `git_diff`          | Review Executor changes              |
| `test_status`       | Read the latest recorded test result |
| `execution_summary` | Read the Executor result             |

The Brain does **not** receive a generic shell interface.

It also cannot directly write files.

This separation is intentional.

---

# C2C: Brain-to-Executor Protocol

AgentBridge uses a small structured protocol called **C2C (Context-to-Context)** to communicate between the Brain and Executor.

Instead of sending source code or a huge conversation to the coding agent, the Brain produces a compact implementation plan:

```text
[C2C]
STATE: PLAN
TASK_ID: c2c_12345
ITERATION: 1

GOAL:
Add URL inspection to the GSC client.

ACTIONS:
1. Inspect the current GSC client.
2. Add URL inspection support.
3. Add tests for indexed and non-indexed URLs.

TESTS:
cargo test

SUCCESS_CRITERIA:
Tests pass and the API correctly reports indexed / not-indexed.
```

The source code stays in the local workspace.

Only the intent and implementation contract cross the Brain → Executor boundary.

This has two important benefits:

1. **Lower context overhead**
2. **Clear separation of responsibility**

The Brain does not need to paste your repository into the Executor's prompt.

The Executor works directly against the same local workspace.

---

# Read-Only Brain, Write-Capable Executor

One of the most important design decisions in AgentBridge is the trust boundary.

The Brain can inspect:

```text
workspace
├── source files
├── project structure
├── Git status
├── Git diff
└── test results
```

But it cannot:

```text
✗ write files
✗ delete files
✗ execute shell commands
✗ commit
✗ push
```

The Executor is the component that performs those actions.

This gives the architecture a clear separation:

```text
                 Read-only
                    │
                    ▼
              ┌───────────┐
              │   Brain   │
              └─────┬─────┘
                    │
                 PLAN
                    │
                    ▼
              ┌───────────┐
              │ Executor  │
              └─────┬─────┘
                    │
              Write / Execute
                    │
                    ▼
              Local Project
```

The Brain decides **what should happen**.

The Executor decides **how to execute the supplied plan inside the coding environment**.

---

# Quick Start

## 1. Install

Requirements:

* Rust 1.88+
* Git
* OpenCode
* An MCP-capable AI client

Clone and install AgentBridge:

```bash
git clone https://github.com/IndexFlowing/AgentBridge.git
cd AgentBridge

cargo install --path .
```

---

## 2. Initialize a Workspace

Point AgentBridge at the project you want the Brain to inspect:

```bash
agentbridge init ~/projects/my-project
```

This creates the AgentBridge configuration and associates the MCP server with that workspace.

---

## 3. Start the MCP Server

```bash
agentbridge serve
```

By default, AgentBridge listens on:

```text
http://127.0.0.1:8787/mcp
```

The default configuration is intentionally localhost-only.

---

## 4. Connect Your Brain

Connect a compatible MCP client such as Gemini, Claude, ChatGPT, or another MCP-capable AI client to AgentBridge.

Then provide the Brain instructions from:

```text
skill/SKILL.md
```

The skill teaches the AI how to:

1. inspect the workspace;
2. create a C2C PLAN;
3. delegate the task;
4. monitor execution;
5. inspect the result;
6. review the changes;
7. finish or create another iteration.

---

## 5. Give the Brain a Task

For example:

```text
Add Google Search Console URL inspection support to this project.

First understand the existing architecture.
Then create an implementation plan and delegate it to the Executor.
After implementation, review the diff and test results.
```

The Brain can inspect the actual repository rather than relying on files pasted into the conversation.

---

# Exposing AgentBridge to a Web AI

If your Brain runs in a web environment and cannot access localhost directly, you can expose AgentBridge through a tunnel.

For example, with Cloudflare Tunnel:

```bash
agentbridge serve --allow-any-host
```

Then:

```bash
cloudflared tunnel --url http://127.0.0.1:8787
```

Your MCP endpoint will be available at:

```text
https://<your-tunnel-id>.trycloudflare.com/mcp
```

Cloudflare Tunnel is **optional**.

AgentBridge itself works entirely locally.

> **Security:** If you expose AgentBridge outside localhost, use authentication and understand that the remote Brain can read the workspace exposed by the server. Never point AgentBridge at your entire home directory.

See [Security](docs/security.md) for details.

---

# CLI

```bash
agentbridge init <workspace>
agentbridge serve
agentbridge status
agentbridge doctor

agentbridge task start --goal "..."
agentbridge task executed \
  --status success \
  --tests "cargo test" \
  --exit-code 0
```

Use:

```bash
agentbridge doctor
```

to check:

* workspace configuration;
* Git availability;
* MCP configuration;
* server port;
* optional Cloudflare Tunnel configuration;
* Executor availability.

---

# Configuration

AgentBridge stores global configuration in:

```text
~/.agentbridge/config.toml
```

and workspace-specific configuration in:

```text
<workspace>/.agentbridge.toml
```

Example:

```toml
workspace = "/absolute/path/to/project"
host = "127.0.0.1"
port = 8787

[security]
max_file_size = 1048576
deny_sensitive_files = true
```

---

# Security

AgentBridge is designed around a simple security model:

**The remote Brain receives a read-only view of the configured workspace.**

Path traversal and sensitive files are explicitly restricted.

Examples of blocked paths include:

```text
../
/etc/passwd
C:\Users\...
~/.ssh
.env
*.pem
*.key
id_rsa
```

Important recommendations:

* Point AgentBridge at a single project.
* Do not expose your home directory.
* Keep the default localhost binding whenever possible.
* If you expose the server remotely, configure authentication.
* Treat the Brain as an external service with access to the workspace you explicitly expose.

AgentBridge is a local developer tool, not a multi-tenant security boundary.

See [`docs/security.md`](docs/security.md).

---

# Architecture

The project is intentionally small and has clear boundaries:

```text
AgentBridge
│
├── MCP Server
│   └── Exposes workspace inspection tools
│
├── Workspace
│   └── Filesystem access with security restrictions
│
├── Task Runtime
│   └── PLAN → EXECUTE → RESULT lifecycle
│
├── C2C Protocol
│   └── Compact Brain → Executor communication
│
├── Executor
│   └── Runs the local coding agent
│
└── Git / State
    └── Tracks changes and execution results
```

The important boundary is:

```text
             Remote Brain
                  │
               MCP API
                  │
          ┌───────▼───────┐
          │  AgentBridge   │
          └───────┬───────┘
                  │
              C2C PLAN
                  │
          ┌───────▼───────┐
          │    Executor    │
          └───────┬───────┘
                  │
             Local process
                  │
          ┌───────▼───────┐
          │    Workspace   │
          └────────────────┘
```

---

# What AgentBridge Is Not

AgentBridge is **not** another AI coding agent.

It does not attempt to replace:

* Gemini
* ChatGPT
* Claude
* OpenCode
* Codex
* your editor
* your existing development workflow

Instead, it connects them.

AgentBridge also does not:

* provide AI models;
* provide additional model credits;
* bypass subscription limits;
* proxy model APIs;
* upload your repository to a hosted service.

It is a **local bridge between AI reasoning and local code execution**.

---

# Current Status

AgentBridge is currently focused on the Brain / Executor workflow.

Current implementation:

* Rust-based local MCP server
* workspace inspection
* secure path handling
* Git status and diff inspection
* structured C2C task protocol
* task lifecycle management
* OpenCode Executor integration
* execution status and result reporting
* Brain skill instructions
* local-first architecture

The Executor abstraction is designed to support additional coding agents as the project evolves.

---

# Roadmap

Potential future directions include:

* More Executor backends
* Better task orchestration
* Executor selection and routing
* Parallel task execution
* Improved context optimization
* Persistent task history
* More Brain integrations
* Better IDE integration
* Richer review workflows

The goal is not to build another monolithic AI coding product.

The goal is to make the AI coding stack **composable**.

---

# Development

```bash
cargo fmt --check

cargo clippy --all-targets --all-features -- -D warnings

cargo test

cargo build --release
```

Requires:

```text
Rust 1.88+
Git
```

---

# Philosophy

AI coding does not have to be a single-agent problem.

Different AI products have different strengths, interfaces, context windows, pricing models, and usage limits.

Instead of forcing one agent to handle everything, AgentBridge treats AI coding as a distributed workflow:

```text
        THINK
          │
          ▼
       PLAN
          │
          ▼
      EXECUTE
          │
          ▼
       REVIEW
          │
          ▼
        DONE
```

Use the AI that is best at **thinking**.

Use the coding agent that is best at **doing**.

Use AgentBridge to connect them.

---

# License

MIT