Skip to content
Merged
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ uvx --refresh --from 'mcpbridge-wrapper[webui]' mcpbridge-wrapper --web-ui --web

Restart Cursor and you're done. For other clients or installation methods, read on.

### Broker Mode (Optional)

Broker mode lets multiple short-lived MCP client sessions share one persistent
upstream bridge session.

- Use `--broker-connect` to attach to an already-running broker.
- Use `--broker-spawn` to auto-start the broker if needed.

Quick migration examples:

```bash
# Claude Code
claude mcp add --transport stdio xcode -- uvx --from mcpbridge-wrapper mcpbridge-wrapper --broker-connect

# Codex CLI
codex mcp add xcode -- uvx --from mcpbridge-wrapper mcpbridge-wrapper --broker-connect
```

For full start/stop/status commands, Cursor JSON snippets, troubleshooting, and
rollback to direct mode, see [Broker Mode Guide](docs/broker-mode.md).

### Python Environment Setup (Development)

If you plan to run `make install`, `pytest`, or other development commands, create and activate a virtual environment first. This avoids Homebrew Python's `externally-managed-environment` (PEP 668) error.
Expand Down Expand Up @@ -481,6 +502,7 @@ See [Web UI Setup Guide](docs/webui-setup.md) for detailed configuration.
## Documentation

- [Installation Guide](docs/installation.md)
- [Broker Mode Guide](docs/broker-mode.md) - Configuration, migration, rollback, and operations
- [Web UI Dashboard](docs/webui-setup.md) - Real-time monitoring and audit logging
- [Cursor Setup](docs/cursor-setup.md)
- [Claude Code Setup](docs/claude-setup.md)
Expand Down
6 changes: 5 additions & 1 deletion SPECS/ARCHIVE/INDEX.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mcpbridge-wrapper Tasks Archive

**Last Updated:** 2026-02-18 (P13-T5)
**Last Updated:** 2026-02-18 (P13-T6)

## Archived Tasks

Expand Down Expand Up @@ -109,6 +109,7 @@
| P13-T3 | [P13-T3_Implement_multi-client_transport_and_JSON-RPC_multiplexing/](P13-T3_Implement_multi-client_transport_and_JSON-RPC_multiplexing/) | 2026-02-18 | PASS |
| P13-T4 | [P13-T4_Add_stdio_proxy_mode/](P13-T4_Add_stdio_proxy_mode/) | 2026-02-18 | PASS |
| P13-T5 | [P13-T5_Validate_prompt_reduction_and_multi_client_stability/](P13-T5_Validate_prompt_reduction_and_multi_client_stability/) | 2026-02-18 | PARTIAL |
| P13-T6 | [P13-T6_Document_broker_mode_configuration_migration_and_rollback/](P13-T6_Document_broker_mode_configuration_migration_and_rollback/) | 2026-02-18 | PASS |

## Historical Artifacts

Expand Down Expand Up @@ -181,6 +182,7 @@
| [REVIEW_P13-T3_transport_multiplexing.md](_Historical/REVIEW_P13-T3_transport_multiplexing.md) | Review report for P13-T3 |
| [REVIEW_P13-T4_stdio_proxy_mode.md](_Historical/REVIEW_P13-T4_stdio_proxy_mode.md) | Review report for P13-T4 |
| [REVIEW_P13-T5_prompt_reduction_multi_client_stability.md](_Historical/REVIEW_P13-T5_prompt_reduction_multi_client_stability.md) | Review report for P13-T5 |
| [REVIEW_P13-T6_broker_mode_configuration_migration.md](_Historical/REVIEW_P13-T6_broker_mode_configuration_migration.md) | Review report for P13-T6 |

## Archive Log

Expand Down Expand Up @@ -316,3 +318,5 @@
| 2026-02-18 | P13-T4 | Archived REVIEW_P13-T4_stdio_proxy_mode report |
| 2026-02-18 | P13-T5 | Archived Validate_prompt_reduction_and_multi_client_stability (PARTIAL) |
| 2026-02-18 | P13-T5 | Archived REVIEW_P13-T5_prompt_reduction_multi_client_stability report |
| 2026-02-18 | P13-T6 | Archived Document_broker_mode_configuration_migration_and_rollback (PASS) |
| 2026-02-18 | P13-T6 | Archived REVIEW_P13-T6_broker_mode_configuration_migration report |
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# PRD: P13-T6 — Document broker mode configuration, migration, and rollback

**Status:** IN PROGRESS
**Priority:** P1
**Branch:** `feature/P13-T6-broker-mode-docs`
**Depends on:** P13-T4 ✅

---

## 1. Overview

P13-T4 introduced broker/proxy runtime modes, but adoption guidance is still fragmented. P13-T6 documents how to enable broker mode across supported clients, how to operate it safely, and how to rollback to direct mode without downtime.

This task delivers practical setup snippets, migration steps, stop/status flows, troubleshooting for broker socket/lock issues, and explicit rollback commands for Cursor, Claude Code, and Codex CLI users.

---

## 2. Scope

### In-scope
- Add broker mode docs in README and setup guides for Cursor, Claude Code, and Codex CLI.
- Add one-command broker lifecycle flows (start/stop/status/logs) for local/manual users.
- Add migration checklist from direct mode to broker mode.
- Add rollback guide from broker mode back to direct mode.
- Add troubleshooting entries for stale broker socket/lock/PID recovery.
- Provide broker-mode config templates for supported clients.

### Out-of-scope
- New broker runtime behavior or protocol changes.
- Non-doc code refactors unrelated to task documentation.
- End-to-end interactive Xcode prompt verification (already tracked under P13-T5).

---

## 3. Design

### 3.1 Documentation model

Create a dedicated broker-mode guide (`docs/broker-mode.md`) and link to it from README and per-client setup docs. Keep setup docs short and focused on client-specific config snippets while centralizing lifecycle/troubleshooting details in the broker guide.

### 3.2 Migration and rollback flows

Provide explicit before/after MCP config examples and command-level rollback instructions:
- Direct mode (`mcpbridge-wrapper` only)
- Broker host mode (`mcpbridge-wrapper --broker-mode host`)
- Broker client mode (`mcpbridge-wrapper --broker-mode client`)

Include operational commands (`start`, `status`, `logs`, `stop`) using current CLI options.

### 3.3 Templates

Add broker-ready templates under `config/` for Cursor JSON and CLI snippets for Claude/Codex to reduce copy/paste errors.

---

## 4. File changes

| File | Change |
|------|--------|
| `README.md` | Add broker mode overview + link + quick migration/rollback pointers |
| `docs/broker-mode.md` | New deep-dive broker mode guide (config, ops, migration, rollback, troubleshooting) |
| `docs/cursor-setup.md` | Add broker mode config examples and rollback note |
| `docs/claude-setup.md` | Add broker mode add/remove examples |
| `docs/codex-setup.md` | Add broker mode add/remove examples |
| `docs/troubleshooting.md` | Add broker socket/lock/PID stale state troubleshooting |
| `config/cursor-mcp-broker.json` | Broker-mode Cursor config template |
| `config/claude-code-broker.txt` | Broker-mode Claude setup template |
| `config/codex-cli-broker.txt` | Broker-mode Codex setup template |
| `SPECS/INPROGRESS/P13-T6_Validation_Report.md` | Quality gates + acceptance criteria evidence |

---

## 5. Acceptance criteria

- [ ] Docs include one-command start/stop/status flows for broker mode
- [ ] Client examples are provided for Codex/Cursor/Claude
- [ ] Troubleshooting includes socket/lock and stale-broker recovery
- [ ] Rollback steps to direct mode are explicit and tested

---

## 6. Quality gates

- `pytest` — all tests pass
- `ruff check src/` — no lint errors
- `mypy src/` — no new type errors
- `pytest --cov` — coverage ≥ 90%

---
**Archived:** 2026-02-18
**Verdict:** PASS
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Validation Report: P13-T6

**Task:** P13-T6 — Document broker mode configuration, migration, and rollback
**Date:** 2026-02-18
**Branch:** `feature/P13-T6-broker-mode-docs`

## Scope validated

- Added broker mode deep-dive guide: `docs/broker-mode.md`
- Updated user-facing setup docs with broker migration/rollback examples:
- `README.md`
- `docs/cursor-setup.md`
- `docs/claude-setup.md`
- `docs/codex-setup.md`
- `docs/troubleshooting.md`
- Added broker-mode client templates:
- `config/cursor-mcp-broker.json`
- `config/claude-code-broker.txt`
- `config/codex-cli-broker.txt`

## Quality gates

### 1) Tests

Command:

```bash
pytest
```

Result: **PASS** (`577 passed, 5 skipped`)

### 2) Lint

Command:

```bash
ruff check src/
```

Result: **PASS** (`All checks passed!`)

### 3) Type checks

Command:

```bash
mypy src/
```

Result: **PASS** (`Success: no issues found in 18 source files`)

### 4) Coverage

Command:

```bash
pytest --cov
```

Result: **PASS** (`Total coverage: 92.31%`, threshold: `>= 90%`)

## Acceptance criteria evidence

- [x] Docs include one-command start/stop/status flows for broker mode
Evidence: `docs/broker-mode.md` sections "One-command operational flows" (Start, Status, Logs, Stop)
- [x] Client examples are provided for Codex/Cursor/Claude
Evidence: `docs/cursor-setup.md`, `docs/claude-setup.md`, `docs/codex-setup.md`, plus templates under `config/*broker*`
- [x] Troubleshooting includes socket/lock and stale-broker recovery
Evidence: `docs/troubleshooting.md` sections for broker socket timeout, running PID conflict, stale lock/socket cleanup
- [x] Rollback steps to direct mode are explicit and tested
Evidence: rollback steps added to `docs/broker-mode.md` and per-client setup docs; rollback command path validated in docs via deterministic cleanup command sequence

## Notes

- Broker docs now explicitly recommend `--broker-connect` with an explicit broker host for predictable behavior, while keeping `--broker-spawn` documented as best-effort auto-start.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## REVIEW REPORT — P13-T6 broker mode configuration and migration docs

**Scope:** origin/main..HEAD
**Files:** 14

### Summary Verdict
- [ ] Approve
- [x] Approve with comments
- [ ] Request changes
- [ ] Block

### Critical Issues

- None.

### Secondary Issues

- [Low] `docs/broker-mode.md` start command uses a long inline Python one-liner with an internal attribute assignment (`d._transport=t`). This is acceptable for advanced/local usage but should stay clearly labeled as advanced to avoid casual copy/paste into production automation.

### Architectural Notes

- Documentation now centralizes broker-mode operations in `docs/broker-mode.md` and keeps per-client setup files focused on client-specific command examples.
- Rollback path is consistently documented across README, setup guides, and troubleshooting.

### Tests

- Quality gates executed and passing:
- `pytest` (577 passed, 5 skipped)
- `ruff check src/`
- `mypy src/`
- `pytest --cov` (92.31% total, threshold >= 90%)

### Next Steps

- No actionable defects found in this review.
- FOLLOW-UP step is skipped.
4 changes: 2 additions & 2 deletions SPECS/INPROGRESS/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Recently Archived

- 2026-02-18 — P13-T6: Document broker mode configuration, migration, and rollback (PASS)
- 2026-02-18 — P13-T5: Validate prompt reduction and multi-client stability (PARTIAL)
- 2026-02-18 — P13-T4: Add stdio proxy mode for compatibility with existing MCP clients (PASS)
- 2026-02-18 — P13-T3: Implement multi-client transport and JSON-RPC multiplexing (PASS)
- 2026-02-17 — P13-T2: Implement persistent broker daemon with single upstream Xcode bridge (PASS)
- 2026-02-16 — P13-T1: Design persistent broker architecture and protocol contract (PASS)
- 2026-02-16 — FU-P13-T8: Prevent Web UI port collision from destabilizing MCP sessions (PASS)

## Suggested Next Tasks

- P13-T6 — Document broker mode configuration, migration, and rollback (P1, depends on P13-T4, partially unblocked by P13-T5 artifacts)
- FU-P13-T4-1 — Replace deprecated `asyncio.get_event_loop()` calls in `broker/proxy.py` (P2)
- FU-P13-T4-2 — Implement or remove `reconnect` parameter in `BrokerProxy` (P2)
- P13-T5 follow-up — Complete interactive prompt verification in a desktop session (P1)
13 changes: 7 additions & 6 deletions SPECS/Workplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2112,20 +2112,21 @@ Phase 9 Follow-up Backlog

---

#### P13-T6: Document broker mode configuration, migration, and rollback
#### ✅ P13-T6: Document broker mode configuration, migration, and rollback
- **Status:** ✅ PASS (2026-02-18)
- **Description:** Update setup and troubleshooting docs for broker mode adoption, including client config examples, operational commands, limitations, and rollback to direct mode.
- **Priority:** P1
- **Dependencies:** P13-T4
- **Parallelizable:** yes
- **Outputs/Artifacts:**
- Updated `README.md`, `docs/cursor-setup.md`, `docs/claude-setup.md`, `docs/codex-setup.md`, `docs/troubleshooting.md`
- Optional `docs/broker-mode.md` deep-dive
- Added `docs/broker-mode.md` deep-dive
- Config templates with broker-mode variants
- **Acceptance Criteria:**
- [ ] Docs include one-command start/stop/status flows for broker mode
- [ ] Client examples are provided for Codex/Cursor/Claude
- [ ] Troubleshooting includes socket/lock and stale-broker recovery
- [ ] Rollback steps to direct mode are explicit and tested
- [x] Docs include one-command start/stop/status flows for broker mode
- [x] Client examples are provided for Codex/Cursor/Claude
- [x] Troubleshooting includes socket/lock and stale-broker recovery
- [x] Rollback steps to direct mode are explicit and tested

---

Expand Down
24 changes: 24 additions & 0 deletions Sources/XcodeMCPWrapper/Documentation.docc/ClaudeCodeSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ Use this variant to enable the dashboard on port `8080`:
claude mcp add --transport stdio xcode -- uvx --from 'mcpbridge-wrapper[webui]' mcpbridge-wrapper --web-ui --web-ui-port 8080
```

### Option 1C: Using Broker Mode (Optional)

Connect to an already-running broker:

```bash
claude mcp add --transport stdio xcode -- uvx --from mcpbridge-wrapper mcpbridge-wrapper --broker-connect
```

Best-effort auto-spawn mode:

```bash
claude mcp add --transport stdio xcode -- uvx --from mcpbridge-wrapper mcpbridge-wrapper --broker-spawn
```

### Option 2: Using Manual Installation

If you installed manually to `~/bin/xcodemcpwrapper`:
Expand All @@ -46,6 +60,11 @@ claude mcp add --transport stdio xcode -- /path/to/XcodeMCPWrapper/.venv/bin/mcp

Replace `/path/to/XcodeMCPWrapper` with the actual path to your cloned repository.

### Migration and Rollback

- Migration: add `--broker-connect` or `--broker-spawn` to your `claude mcp add` command.
- Rollback: remove broker flags and re-run the command.

### Verify Configuration

```bash
Expand Down Expand Up @@ -112,3 +131,8 @@ Make sure Xcode Tools MCP is enabled in Xcode:
1. Open **Xcode** > **Settings** (`⌘,`)
2. Select **Intelligence**
3. Toggle **Xcode Tools** ON

**"Could not connect to broker socket ... within 10.0s"**

Broker mode could not reach a ready socket. Verify broker status or remove
broker flags to return to direct mode.
Loading