Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# PRD: FU-P12-T1-2 — Add code comment clarifying stdin-only client capture in `on_request`

**Created:** 2026-02-18
**Priority:** P3
**Branch:** `codex/feature/FU-P12-T1-2-stdin-only-capture-comment`
**Status:** PLAN

---

## 1. Problem Statement

`on_request()` in `src/mcpbridge_wrapper/__main__.py` captures client metadata
from `initialize` requests that arrive from stdin. This is intentional, but the
scope is not obvious without reading stream-direction assumptions.

---

## 2. Scope

### In Scope
- Add a concise code comment near initialize client-capture logic.
- Clarify that capture is intentionally stdin-only (client -> wrapper path).
- Keep behavior and data flow unchanged.

### Out of Scope
- Any functional changes to request/response handling.
- Additional telemetry or dashboard behavior changes.

---

## 3. Deliverables

1. `src/mcpbridge_wrapper/__main__.py`
- Add a comment by the client info capture block in `on_request()`.

2. Validation evidence
- Confirm no runtime behavior changes.
- Run required quality gates and document results.

3. `SPECS/INPROGRESS/FU-P12-T1-2_Validation_Report.md`
- Record command outcomes and verdict.

---

## 4. Acceptance Criteria

- [ ] Comment clearly states stdin-only capture direction.
- [ ] No functional changes are introduced.
- [ ] `pytest` passes.
- [ ] `ruff check src/` passes.
- [ ] `mypy src/` passes.
- [ ] `pytest --cov` reports coverage >= 90%.

---

## 5. Dependencies

- P12-T1 ✅

---

## 6. Risks and Mitigations

- **Risk:** Comment wording may be ambiguous and still invite misinterpretation.
- **Mitigation:** Use explicit direction language (`stdin`, `client -> wrapper`) and keep it adjacent to the relevant block.

---

## 7. Validation Plan

1. Insert the clarifying comment in `on_request()`.
2. Run full quality gates.
3. Capture results and verdict in validation report.

---

---
**Archived:** 2026-02-18
**Verdict:** PASS
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Validation Report — FU-P12-T1-2

**Task:** FU-P12-T1-2 — Add code comment clarifying stdin-only client capture in `on_request`
**Date:** 2026-02-18
**Verdict:** PASS

## Scope

- Added a clarifying comment in `src/mcpbridge_wrapper/__main__.py` near the
initialize client identity capture block in `on_request()`.
- No functional behavior changes were introduced.

## Evidence

- Code diff scope:
- `src/mcpbridge_wrapper/__main__.py`
- Change type: comment-only clarification.

## Required Quality Gates

- `pytest`
- Result: **PASS** (`582 passed, 5 skipped, 2 warnings`)
- `ruff check src/`
- Result: **PASS** (`All checks passed!`)
- `mypy src/`
- Result: **PASS** (`Success: no issues found in 18 source files`)
- `pytest --cov`
- Result: **PASS** (`582 passed, 5 skipped, 2 warnings`; total coverage **92.18%**, threshold 90%)

## Acceptance Criteria Status

- [x] Comment clearly states stdin-only capture direction.
- [x] No functional changes are introduced.

## Notes

- Existing third-party deprecation warnings from `websockets`/`uvicorn` were
observed during tests and are unrelated to this task.
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 (REVIEW_fu_p12_t1_1_mcpinitializeparams_archived)
**Last Updated:** 2026-02-18 (REVIEW_fu_p12_t1_2_stdin_capture_comment_archived)

## Archived Tasks

Expand Down Expand Up @@ -116,6 +116,7 @@
| FU-P13-T2-2 | [FU-P13-T2-2_Move_PID_file_write_to_after_successful_upstream_launch/](FU-P13-T2-2_Move_PID_file_write_to_after_successful_upstream_launch/) | 2026-02-18 | PASS |
| FU-BUG-T7-1 | [FU-BUG-T7-1_Cap_pending_methods_map_to_guard_unbounded_growth/](FU-BUG-T7-1_Cap_pending_methods_map_to_guard_unbounded_growth/) | 2026-02-18 | PASS |
| FU-P12-T1-1 | [FU-P12-T1-1_Remove_or_document_MCPInitializeParams_in_schemas/](FU-P12-T1-1_Remove_or_document_MCPInitializeParams_in_schemas/) | 2026-02-18 | PASS |
| FU-P12-T1-2 | [FU-P12-T1-2_Add_code_comment_clarifying_stdin-only_client_capture_in_on_request/](FU-P12-T1-2_Add_code_comment_clarifying_stdin-only_client_capture_in_on_request/) | 2026-02-18 | PASS |

## Historical Artifacts

Expand Down Expand Up @@ -195,6 +196,7 @@
| [REVIEW_FU-P13-T2-2_pid_write_order.md](_Historical/REVIEW_FU-P13-T2-2_pid_write_order.md) | Review report for FU-P13-T2-2 |
| [REVIEW_fu_bug_t7_1_pending_methods_cap.md](_Historical/REVIEW_fu_bug_t7_1_pending_methods_cap.md) | Review report for FU-BUG-T7-1 |
| [REVIEW_FU-P12-T1-1_mcpinitializeparams.md](_Historical/REVIEW_FU-P12-T1-1_mcpinitializeparams.md) | Review report for FU-P12-T1-1 |
| [REVIEW_FU-P12-T1-2_stdin_capture_comment.md](_Historical/REVIEW_FU-P12-T1-2_stdin_capture_comment.md) | Review report for FU-P12-T1-2 |

## Archive Log

Expand Down Expand Up @@ -344,3 +346,5 @@
| 2026-02-18 | FU-BUG-T7-1 | Archived REVIEW_fu_bug_t7_1_pending_methods_cap report |
| 2026-02-18 | FU-P12-T1-1 | Archived Remove_or_document_MCPInitializeParams_in_schemas (PASS) |
| 2026-02-18 | FU-P12-T1-1 | Archived REVIEW_FU-P12-T1-1_mcpinitializeparams report |
| 2026-02-18 | FU-P12-T1-2 | Archived Add_code_comment_clarifying_stdin-only_client_capture_in_on_request (PASS) |
| 2026-02-18 | FU-P12-T1-2 | Archived REVIEW_FU-P12-T1-2_stdin_capture_comment report |
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## REVIEW REPORT — FU-P12-T1-2 stdin capture comment

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

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

### Critical Issues
- None.

### Secondary Issues
- None.

### Architectural Notes
- The comment added in `on_request()` correctly clarifies directional scope
(stdin client requests only) without altering request handling logic.
- Archive bookkeeping and task-tracking updates remain consistent with FLOW
conventions.

### Tests
- Full quality gates were executed during EXECUTE:
- `pytest` (582 passed, 5 skipped)
- `ruff check src/` (pass)
- `mypy src/` (pass)
- `pytest --cov` (92.18%, threshold 90%)

### Next Steps
- No actionable findings.
- FOLLOW-UP step is skipped per FLOW rules.
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 — FU-P12-T1-2: Add code comment clarifying stdin-only client capture in `on_request` (PASS)
- 2026-02-18 — FU-P12-T1-1: Remove or document `MCPInitializeParams` in schemas (PASS)
- 2026-02-18 — FU-BUG-T7-1: Cap `pending_methods` map to guard against unbounded growth (PASS)
- 2026-02-18 — FU-P13-T2-2: Move PID file write to after successful upstream launch (PASS)
- 2026-02-18 — FU-P13-T2-1: Replace run_forever() polling loop with asyncio.Event-based wait (PASS)
- 2026-02-18 — FU-P13-T4-2: Implement or remove reconnect parameter in BrokerProxy (PASS)
- 2026-02-18 — FU-P13-T4-1: Fix asyncio.get_event_loop() deprecation in BrokerProxy (PASS)

## Suggested Next Tasks

- P13-T5 follow-up — Complete interactive prompt verification in a desktop session (P1)
- FU-P12-T1-2Add code comment clarifying stdin-only client capture in `on_request` (P3)
- FU-P12-T1-3Show multi-client widgets in Web UI instead of single overwritten active client (P2)
- FU-P12-T3-2 — Add `error_code` column to audit CSV export (P3)
7 changes: 4 additions & 3 deletions SPECS/Workplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2217,16 +2217,17 @@ Phase 9 Follow-up Backlog

---

#### FU-P12-T1-2: Add code comment clarifying stdin-only client capture in `on_request`
#### ✅ FU-P12-T1-2: Add code comment clarifying stdin-only client capture in `on_request`
- **Status:** ✅ Completed (2026-02-18)
- **Description:** In `__main__.py`'s `on_request()`, the `initialize` client info capture only fires for requests arriving on stdin (client→bridge). Add a brief comment clarifying this intentional scope to prevent future confusion about whether stdout initialize messages are also handled.
- **Priority:** P3
- **Dependencies:** P12-T1
- **Parallelizable:** yes
- **Outputs/Artifacts:**
- Updated `src/mcpbridge_wrapper/__main__.py` — comment added near client info capture block
- **Acceptance Criteria:**
- [ ] Comment clearly states stdin-only capture direction
- [ ] No functional changes
- [x] Comment clearly states stdin-only capture direction
- [x] No functional changes

---

Expand Down
3 changes: 2 additions & 1 deletion src/mcpbridge_wrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def on_request(line: str) -> None:
max_size=MAX_PENDING_METHODS,
)

# Extract MCP client identity from initialize handshake
# This callback sees only stdin traffic (client -> wrapper), so client
# identity capture is intentionally limited to inbound initialize calls.
if method == "initialize" and metrics is not None:
client_info = req.get_client_info()
if client_info is not None:
Expand Down