agentbridge 0.2.1

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
# AgentBridge

**Use one AI to think and another AI to code.**

AgentBridge connects AI reasoning environments to local coding agents through **MCP**, allowing a web-based AI to understand and plan changes while a local coding agent executes them in your workspace.

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

[πŸ‡¨πŸ‡³ δΈ­ζ–‡](README_zh.md) Β· [πŸ“¦ crates.io](https://crates.io/crates/agentbridge) Β· [πŸ™ GitHub](https://github.com/IndexFlowing/AgentBridge)

[![Crates.io](https://img.shields.io/crates/v/agentbridge.svg)](https://crates.io/crates/agentbridge)
[![License](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?

AI coding tools increasingly combine two different jobs:

* **Reasoning** β€” understanding a codebase, investigating problems, designing solutions, and reviewing changes.
* **Execution** β€” editing files, running commands, running tests, and applying changes.

These two jobs do not necessarily need to be performed by the same AI.

You may have a web AI with generous usage and strong reasoning capabilities, while your coding CLI has a more limited subscription quota.

Without a bridge, the coding agent has to spend its quota on everything:

```text
Understand β†’ Explore β†’ Reason β†’ Plan β†’ Code β†’ Test β†’ Review
```

AgentBridge separates the workflow:

```text
                 BRAIN
          Web-based AI
       Gemini / Claude / ...
                 β”‚
          Reason / Plan
                 β”‚
                MCP
                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚   AgentBridge   β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
             C2C PLAN
                 β”‚
                 β–Ό
             EXECUTOR
          Local coding agent
             OpenCode
                 β”‚
        Edit / Run / Test
                 β”‚
                 β–Ό
          Local Workspace
```

The result is simple:

> **Use the AI that is best at thinking, and the coding agent that is best at doing.**

---

## The Core Idea

AgentBridge introduces two explicit roles.

### 🧠 Brain

The **Brain** is the AI responsible for reasoning.

It can:

* inspect the project;
* search the codebase;
* understand architecture;
* investigate bugs;
* design implementation strategies;
* create implementation plans;
* inspect Git diffs;
* review the Executor's work.

The Brain interacts with the workspace through AgentBridge's **read-only MCP interface**.

It does not directly modify files or execute shell commands.

### πŸ› οΈ Executor

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

It can:

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

AgentBridge currently uses **OpenCode** as its Executor.

The architecture is designed so additional coding agents can be supported in the future.

### πŸŒ‰ AgentBridge

AgentBridge connects the two.

It provides:

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

---

## How It Works

A typical workflow looks like this:

```text
User
 β”‚
 β–Ό
Brain
 β”‚
 β”œβ”€β”€ Inspect workspace
 β”œβ”€β”€ Understand architecture
 β”œβ”€β”€ Investigate problem
 └── Create PLAN
          β”‚
          β–Ό
     AgentBridge
          β”‚
       C2C PLAN
          β”‚
          β–Ό
      Executor
          β”‚
   β”œβ”€β”€ Edit files
   β”œβ”€β”€ Run commands
   └── Run tests
          β”‚
          β–Ό
    Git Diff / Result
          β”‚
          β–Ό
        Brain
          β”‚
       Review
          β”‚
     β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
     β”‚         β”‚
    DONE    PLAN AGAIN
```

This creates a feedback loop:

```text
PLAN β†’ EXECUTE β†’ REVIEW β†’ DONE
             ↑            β”‚
             └── PLAN β”€β”€β”€β”€β”˜
```

The Brain can therefore focus on high-value reasoning while the Executor focuses on actually changing the codebase.

---

## Why This Can Save Coding-Agent Quota

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

A coding agent may consume its allowance while:

* exploring the repository;
* reading files;
* searching for definitions;
* understanding architecture;
* reasoning about an implementation;
* generating a plan;
* implementing changes;
* running tests;
* retrying failed implementations.

That means a significant amount of coding-agent usage can happen **before the first useful code change**.

AgentBridge lets you move much of the exploratory and reasoning-heavy work to another AI interface.

For example:

```text
Gemini Web
    β”‚
    β”‚ understand / reason / plan
    β–Ό
AgentBridge
    β”‚
    β”‚ compact implementation plan
    β–Ό
OpenCode CLI
    β”‚
    β”‚ implement / test
    β–Ό
Your repository
```

The goal is not to bypass quotas.

AgentBridge:

* does not provide additional model credits;
* does not bypass provider limits;
* does not access paid models without authorization;
* does not proxy model APIs.

It simply allows you to **use the AI services and coding agents you already have more efficiently**.

---

## MCP: Giving the Brain Access to Your Workspace

AgentBridge uses the **Model Context Protocol (MCP)** to expose your local project to the Brain.

The Brain can use tools such as:

| Tool                | Purpose                                     |
| ------------------- | ------------------------------------------- |
| `workspace_info`    | Inspect workspace information and Git state |
| `list_directory`    | Explore the project structure               |
| `read_file`         | Read files                                  |
| `search_workspace`  | Search source code                          |
| `git_status`        | Inspect repository status                   |
| `git_diff`          | Review changes                              |
| `test_status`       | Read the latest test result                 |
| `execution_summary` | Read the latest 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 Communication

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

Instead of passing an entire repository or a huge conversation to the coding agent, the Brain creates a compact implementation plan:

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

GOAL:
Add URL inspection support to the GSC client.

ACTIONS:
1. Inspect the existing 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 / non-indexed.
```

The source code remains in the local workspace.

Only the task intent and implementation contract cross the Brain β†’ Executor boundary.

This keeps the communication focused and avoids unnecessarily duplicating the entire project context.

---

## 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.

```text
                 Read-only
                    β”‚
                    β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   Brain   β”‚
              β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                    β”‚
                  PLAN
                    β”‚
                    β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Executor  β”‚
              β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                    β”‚
             Write / Execute
                    β”‚
                    β–Ό
              Local Project
```

The Brain decides **what should happen**.

The Executor performs **the implementation inside the local coding environment**.

---

## Quick Start

### 1. Install

The easiest way to install AgentBridge is through Cargo:

```bash
cargo install agentbridge
```

Verify the installation:

```bash
agentbridge --version
```

You can also download pre-built binaries from [GitHub Releases](https://github.com/IndexFlowing/AgentBridge/releases).

### Build from source

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

cargo install --path .
```

### 2. Start AgentBridge

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.

You can check your environment with:

```bash
agentbridge doctor
```

![Start AgentBridge](images/start_server.jpg)

### 3. Connect Your Brain

Connect an MCP-capable AI client to AgentBridge.

Your Brain can then inspect the local workspace through the MCP tools.

![Connect MCP](images/connect_mcp.jpg)

The Brain instructions are provided in:

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

The skill teaches the Brain how to:

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

### 4. 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 instead of relying on files pasted into the conversation.

---

## Using a Web-Based Brain

If your Brain runs in a web environment and cannot directly access localhost, 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
```

AgentBridge itself remains a local application.

> **Security:** If you expose AgentBridge outside localhost, use authentication and carefully choose which workspace is exposed. Do not point AgentBridge at your entire home directory.

---

## 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
```

Run:

```bash
agentbridge doctor
```

to check your local AgentBridge environment.

---

## Configuration

Global configuration:

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

Workspace-specific configuration:

```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 Brain receives a read-only view of the workspace you explicitly expose.**

Path traversal and sensitive files are restricted.

Examples of protected paths and patterns include:

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

Recommended practices:

* 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 a remote Brain as an external service with access to the workspace you expose.

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

---

## Architecture

AgentBridge is intentionally built around clear boundaries:

```text
AgentBridge
β”‚
β”œβ”€β”€ MCP Server
β”‚   └── Exposes workspace inspection tools
β”‚
β”œβ”€β”€ Workspace
β”‚   └── Secure filesystem access
β”‚
β”œβ”€β”€ Task Runtime
β”‚   └── PLAN β†’ EXECUTE β†’ RESULT lifecycle
β”‚
β”œβ”€β”€ C2C Protocol
β”‚   └── Brain β†’ Executor communication
β”‚
β”œβ”€β”€ Executor
β”‚   └── Runs the local coding agent
β”‚
└── Git / State
    └── Tracks changes and execution results
```

The key 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 try to replace:

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

Instead, it connects them.

AgentBridge does not:

* provide AI models;
* provide 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 capabilities include:

* 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:

* Additional Executor backends
* Executor selection and routing
* Better task orchestration
* Parallel task execution
* Context optimization
* Persistent task history
* More Brain integrations
* 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

Requirements:

```text
Rust 1.88+
Git
```

Run:

```bash
cargo fmt --check

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

cargo test

cargo build --release
```

---

## 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.**

---

## Contributing

Contributions are welcome.

If you want to add a new Executor, improve the MCP interface, or enhance the Brain / Executor workflow, feel free to open an issue or pull request.

---

## License

MIT License.