Skip to content

Commit 8732c81

Browse files
committed
fix: MCP tools unavailable in spawned subagents (GH #31, v0.21.1)
Phase 84. MCP stdio connections don't propagate across subprocess boundaries, so spawning rn-tester/rn-debugger via Task tool fails. Multi-part fix (validated via multi-review): - Removed mcp__*cdp__* from agents/rn-tester.md + rn-debugger.md tools frontmatter (runtime gate — spawned subagents fail fast) - Removed agent: directive from test-feature/debug-screen/build-and-test commands; protocol now executes inline in parent session using skills - Added PARENT-SESSION-ONLY label + body blockquote warnings to agents - Updated using-rn-dev-agent meta-skill: Agent Map splits into "spawnable (read-only)" vs "parent-session-only (protocol playbooks)" - Fixed docs-site agents/index.mdx to reflect the split - Fixed stale "rn-tester agent cannot verify" in rn-code-reviewer.md - Fixed build-and-test.md bash invocations missing <platform> arg - Added README troubleshooting entry Convention D609: agents split by invocation pattern — MCP-bound ones are protocol playbooks for parent session, read-only ones are safe to spawn via Task tool.
1 parent 385aa11 commit 8732c81

11 files changed

Lines changed: 198 additions & 87 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{
1010
"name": "rn-dev-agent",
1111
"description": "AI agent that fully tests React Native features on simulator/emulator — navigates the app, verifies UI, walks user flows, and confirms internal state.",
12-
"version": "0.21.0",
12+
"version": "0.21.1",
1313
"source": "./",
1414
"category": "mobile-development",
1515
"homepage": "https://github.com/Lykhoyda/rn-dev-agent"

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-dev-agent",
3-
"version": "0.21.0",
3+
"version": "0.21.1",
44
"description": "AI agent that fully tests React Native features on simulator/emulator — navigates the app, verifies UI, walks user flows, and confirms internal state.",
55
"author": {
66
"name": "Anton Lykhoyda",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Claude Code
150150
| Zustand store error | Add `global.__ZUSTAND_STORES__` ([setup](https://lykhoyda.github.io/rn-dev-agent/getting-started/#zustand-stores-one-line)) |
151151
| Plugin not detected | `/plugin install rn-dev-agent@Lykhoyda-rn-dev-agent` then `/reload-plugins` |
152152
| Tools fail after upgrade | Restart Claude Code ([why](https://lykhoyda.github.io/rn-dev-agent/troubleshooting/)) |
153+
| Spawned subagent says "MCP tools unavailable" | Never spawn `rn-tester` / `rn-debugger` via Task tool — MCP stdio doesn't propagate to subprocesses (GH #31). Use `/rn-dev-agent:test-feature` or `/rn-dev-agent:debug-screen` instead; protocols run inline in the parent session. |
153154

154155
[Full troubleshooting guide](https://lykhoyda.github.io/rn-dev-agent/troubleshooting/)
155156

agents/rn-code-reviewer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Rate each potential issue 0–100:
6464

6565
- **testID coverage** (Critical): Every `Pressable`, `TouchableOpacity`, `Button`,
6666
`TextInput`, and scrollable container must have a `testID`. Without testIDs,
67-
the rn-tester agent cannot verify the feature via `cdp_component_tree` or Maestro.
67+
the rn-tester protocol (run via `/rn-dev-agent:test-feature`) cannot verify
68+
the feature via `cdp_component_tree` or Maestro.
6869
- **`__DEV__` guards** (Critical): All dev-only code must be wrapped in `if (__DEV__)`.
6970
This includes `global.__ZUSTAND_STORES__`, network mocks, debug logging, and
7071
dev menu setup. Shipping dev code to production is a security risk.

agents/rn-debugger.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: |
44
Diagnoses broken or unexpected behavior in a React Native app running
55
on simulator/emulator. Gathers parallel evidence (component tree, logs,
66
network, store), narrows root cause, applies a fix, and verifies recovery.
7+
PARENT-SESSION-ONLY: requires MCP tools (cdp_*, device_*, collect_logs) —
8+
do NOT spawn via Task tool, run protocol inline in parent session (GH #31).
79
Triggers: "something is broken", "debug this", "why isn't this working",
810
"the screen is blank", "I see an error", "fix the crash"
911
@@ -33,7 +35,7 @@ description: |
3335
Frozen app could be paused debugger, blocked JS thread, or native crash — needs structured diagnosis.
3436
</commentary>
3537
</example>
36-
tools: Bash, Read, Write, Edit, Glob, Grep, mcp__*cdp__*
38+
tools: Bash, Read, Write, Edit, Glob, Grep
3739
model: opus
3840
memory: true
3941
color: red
@@ -44,6 +46,20 @@ You are a React Native debugging agent. You diagnose broken UI, crashes,
4446
and unexpected behavior by gathering structured evidence from all available
4547
layers, then applying targeted fixes.
4648

49+
> **CRITICAL — Invocation Constraint (GH #31):**
50+
> This agent uses MCP tools (`cdp_*`, `device_*`, `collect_logs`) which only
51+
> work when invoked in the **parent Claude Code session**, not when spawned
52+
> as a subagent via the Task tool. MCP stdio connections do not propagate
53+
> across subprocess boundaries.
54+
>
55+
> - **DO** invoke this agent's protocol inline from `/rn-dev-agent:debug-screen`
56+
> or from the parent session directly
57+
> - **DO NOT** spawn this agent via `Task(subagent_type='rn-dev-agent:rn-debugger')`
58+
> — the spawned subagent will not have access to `cdp_*` / `device_*` tools
59+
>
60+
> If you are reading this as a spawned subagent and notice you cannot call
61+
> CDP/device tools, **stop immediately**. Return control to the parent session.
62+
4763
## Safety Constraints
4864

4965
- **NEVER change git state**: Do not run `git checkout`, `git stash`, `git reset`,

agents/rn-tester.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: |
44
Tests React Native features on simulator/emulator. Verifies UI renders
55
correctly, user flows work, and internal state matches expectations.
66
Use when a feature has been implemented and needs verification.
7+
PARENT-SESSION-ONLY: requires MCP tools (cdp_*, device_*) — do NOT spawn
8+
via Task tool, run protocol inline in parent session (GH #31).
79
Triggers: "test this feature", "verify it works", "check the implementation",
810
"test on simulator", "run on device", "does it work"
911
@@ -33,7 +35,7 @@ description: |
3335
User is asking whether a feature works correctly, which requires live device testing.
3436
</commentary>
3537
</example>
36-
tools: Bash, Read, Write, Edit, Glob, Grep, mcp__*cdp__*
38+
tools: Bash, Read, Write, Edit, Glob, Grep
3739
model: sonnet
3840
memory: true
3941
color: cyan
@@ -43,6 +45,21 @@ skills: rn-device-control, rn-testing, rn-debugging
4345
You are a React Native feature testing agent. After a feature is
4446
implemented, you verify it works correctly on a real simulator/emulator.
4547

48+
> **CRITICAL — Invocation Constraint (GH #31):**
49+
> This agent uses MCP tools (`cdp_*`, `device_*`) which only work when invoked
50+
> in the **parent Claude Code session**, not when spawned as a subagent via
51+
> the Task tool. MCP stdio connections do not propagate across subprocess
52+
> boundaries.
53+
>
54+
> - **DO** invoke this agent's protocol inline from a slash command
55+
> (`/rn-dev-agent:test-feature`) or from the parent session directly
56+
> - **DO NOT** spawn this agent via `Task(subagent_type='rn-dev-agent:rn-tester')`
57+
> — the spawned subagent will not have access to `cdp_*` / `device_*` tools
58+
>
59+
> If you are reading this as a spawned subagent and notice you cannot call
60+
> CDP/device tools, **stop immediately**. Return control to the parent session
61+
> and ask it to run the testing protocol directly.
62+
4663
## Your Testing Protocol
4764

4865
### Step 0: Environment Check

commands/build-and-test.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,46 @@ command: build-and-test
33
description: Build the Expo/React Native app (local or EAS), install on simulator/emulator, start Metro, then test the specified feature end-to-end.
44
argument-hint: [--eas profile] [feature-description]
55
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, mcp__*cdp__*
6-
agent: rn-tester
76
---
87

98
Build the app and test this feature: $ARGUMENTS
109

11-
## Usage
10+
## Run the build + test protocol INLINE (parent session)
1211

13-
```
14-
/rn-dev-agent:build-and-test <description>
15-
/rn-dev-agent:build-and-test --eas [profile] <description>
16-
```
12+
> **Important (GH #31):** Do NOT spawn the `rn-tester` agent via the Task tool.
13+
> MCP tools (`cdp_*`, `device_*`) are not available in spawned subagents.
14+
> Execute the build + test protocol directly in this parent session.
15+
16+
Phase A — Build pre-flight (run in this session):
17+
18+
1. **Detect platform** — check booted devices via `device_list` or `xcrun simctl
19+
list devices booted` / `adb devices`. Record the result as `<platform>` =
20+
`ios` or `android` — every script below needs it as argument 1.
21+
2. **Check if app is already running** — call `cdp_status`. If `cdp.connected
22+
== true` AND `app.dev == true`, skip to Phase B.
23+
3. **Build / install** (substitute `<platform>` with `ios` or `android`):
24+
- **No `--eas` flag:** run `bash $CLAUDE_PLUGIN_ROOT/scripts/expo_ensure_running.sh <platform>`
25+
which triggers `npx expo run:ios` or `npx expo run:android` (local build).
26+
- **With `--eas` flag:** run `bash $CLAUDE_PLUGIN_ROOT/scripts/eas_resolve_artifact.sh <platform> <profile>`
27+
to find the artifact, then `bash $CLAUDE_PLUGIN_ROOT/scripts/expo_ensure_running.sh <platform> --artifact <path>`
28+
to install.
29+
4. **Start Metro** if not running (`npx expo start` in background, or instruct
30+
user to start it).
31+
5. **Confirm CDP** — call `cdp_status` again, must return `ok:true`.
32+
33+
Phase B — Run the rn-tester 7-step protocol (load `rn-testing` skill):
34+
35+
Follow the same protocol as `/rn-dev-agent:test-feature` — environment check,
36+
understand the feature, plan, navigate, execute+verify, edge cases, generate
37+
persistent test.
38+
39+
## Verification (mandatory before declaring complete)
40+
41+
- [ ] `cdp_status` returns `ok:true` with `cdp.connected: true` after Phase A
42+
- [ ] Every test assertion has concrete Evidence
43+
- [ ] At least one `device_screenshot` saved
44+
- [ ] `flows/<feature-name>.yaml` written
45+
- [ ] `cdp_error_log` shows 0 new errors at end
1746

1847
## Examples
1948

@@ -23,18 +52,6 @@ Build the app and test this feature: $ARGUMENTS
2352
/rn-dev-agent:build-and-test --eas preview payment flow -- test a specific EAS profile
2453
```
2554

26-
## What This Does
27-
28-
Extends the standard `rn-tester` 7-step protocol with a build pre-flight:
29-
30-
1. **Detect platform** — checks for booted iOS simulator or Android emulator
31-
2. **Check if app is running** — calls `cdp_status` to see if Metro + Hermes are connected
32-
3. **Build/install if needed**:
33-
- **No `--eas` flag**: runs `expo_ensure_running.sh` which triggers `npx expo run:ios` or `npx expo run:android` (local build, blocks until done)
34-
- **With `--eas` flag**: runs `eas_resolve_artifact.sh` to find the artifact (cache → EAS servers), then `expo_ensure_running.sh --artifact <path>` to install
35-
4. **Start Metro** if not already running
36-
5. **Run the standard 7-step test protocol** (environment check, understand feature, plan test, navigate, execute+verify, edge cases, generate test file)
37-
3855
## Build Modes
3956

4057
| Mode | When | Command |

commands/debug-screen.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,42 @@
22
command: debug-screen
33
description: Diagnose why the current screen is broken, showing unexpected content, or crashing. Gathers parallel evidence from all layers and applies a targeted fix.
44
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, mcp__*cdp__*
5-
agent: rn-debugger
65
---
76

87
Diagnose and fix the current screen state on the simulator/emulator.
98

10-
## Usage
11-
12-
```
13-
/rn-dev-agent:debug-screen
14-
```
15-
16-
## What This Does
17-
18-
Invokes the `rn-debugger` agent, which runs a structured diagnostic flow:
19-
20-
1. **Screenshot** -- captures current screen state immediately
21-
2. **Parallel evidence gathering** -- simultaneously reads error log, console, network log, and component tree
22-
3. **Error type identification** -- routes to the right investigation path (JS error vs native crash vs data mismatch vs navigation issue)
23-
4. **Root cause narrowing** -- reads source files, checks store state, inspects native logs if CDP shows nothing
24-
5. **Fix** -- applies minimal targeted fix, waits for Fast Refresh
25-
6. **Verify recovery** -- confirms error is gone, re-runs the failing action
9+
## Run the rn-debugger protocol INLINE (parent session)
10+
11+
> **Important (GH #31):** Do NOT spawn the `rn-debugger` agent via the Task tool.
12+
> MCP tools (`cdp_*`, `device_*`, `collect_logs`) are not available in spawned
13+
> subagents. Execute the debugger protocol directly in this parent session
14+
> using the `rn-debugging` and `rn-device-control` skills as your reference.
15+
16+
Load the `rn-debugging` skill and follow this diagnostic flow in this session:
17+
18+
1. **Screenshot**`device_screenshot` to capture the broken state immediately.
19+
2. **Parallel evidence gathering** — call these in parallel:
20+
- `cdp_error_log` (JS errors)
21+
- `cdp_console_log` (console output)
22+
- `cdp_network_log` (recent requests)
23+
- `cdp_component_tree(filter=...)` (rendered fiber)
24+
- `collect_logs(sources=["native_ios"])` or `["native_android"]` for native crashes
25+
3. **Error type identification** — classify: JS error vs native crash vs data
26+
mismatch vs navigation issue vs blank screen.
27+
4. **Root cause narrowing** — read source files flagged by stack traces, check
28+
`cdp_store_state(path=...)`, inspect native logs if CDP shows nothing.
29+
5. **Fix** — apply the minimal targeted fix, save, wait for Fast Refresh
30+
(or `cdp_reload(full=true)` for native changes).
31+
6. **Verify recovery** — reproduce the failing action AGAIN, confirm the bug
32+
no longer reproduces, capture a "fixed" `device_screenshot`.
33+
34+
## Verification (mandatory before declaring "fixed")
35+
36+
- [ ] Root cause stated (not just symptom)
37+
- [ ] Reproduction steps executed AGAIN after the fix → bug gone
38+
- [ ] `cdp_error_log` shows 0 new errors after fix
39+
- [ ] "Before" and "after" screenshots both saved
40+
- [ ] No adjacent files refactored ("while I'm here")
2641

2742
## When to Use
2843

@@ -35,6 +50,6 @@ Invokes the `rn-debugger` agent, which runs a structured diagnostic flow:
3550

3651
## What You Don't Need to Do
3752

38-
You don't need to describe the problem in detail. The agent gathers its own
39-
evidence from the running app. Just run the command while the broken state
40-
is visible on the simulator.
53+
You don't need to describe the problem in detail. The MCP tools gather their
54+
own evidence from the running app. Just run the command while the broken
55+
state is visible on the simulator.

commands/test-feature.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,42 @@ command: test-feature
33
description: Test a React Native feature on the running simulator/emulator. Verifies UI, user flows, and internal state. Generates a persistent Maestro test file.
44
argument-hint: [feature-description]
55
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, mcp__*cdp__*
6-
agent: rn-tester
76
---
87

98
Test this React Native feature: $ARGUMENTS
109

11-
## Usage
12-
13-
```
14-
/rn-dev-agent:test-feature <description>
15-
```
10+
## Run the rn-tester protocol INLINE (parent session)
11+
12+
> **Important (GH #31):** Do NOT spawn the `rn-tester` agent via the Task tool.
13+
> MCP tools (`cdp_*`, `device_*`) are not available in spawned subagents.
14+
> Execute the rn-tester protocol directly in this parent session using the
15+
> `rn-testing` and `rn-device-control` skills as your reference.
16+
17+
Load the `rn-testing` skill and follow this 7-step protocol in this session:
18+
19+
1. **Environment check** — call `cdp_status`. If it fails, stop and tell the
20+
user to run `/rn-dev-agent:setup`.
21+
2. **Understand the feature** — read implementation files, find testIDs, routes,
22+
store slices.
23+
3. **Plan the test** — write test steps and expected outcomes BEFORE executing.
24+
4. **Navigate to start** — use `cdp_navigate` or `device_deeplink` to reach the
25+
starting screen.
26+
5. **Execute and verify** — for each step:
27+
- Act (`device_press`, `device_fill`, `device_find`)
28+
- Wait (`assertVisible` or 1-2s settle)
29+
- Verify UI (`cdp_component_tree(filter=...)`)
30+
- Verify data (`cdp_store_state(path=...)` + `cdp_network_log`)
31+
6. **Edge cases** — test empty state, error state, back navigation, rapid taps.
32+
7. **Generate persistent test** — write `flows/<feature-name>.yaml` for CI.
33+
34+
## Verification (mandatory before declaring "tested")
35+
36+
- [ ] `cdp_status` returned `ok:true` with `cdp.connected: true`
37+
- [ ] Every assertion has concrete Evidence (not "looks fine")
38+
- [ ] At least one `device_screenshot` saved
39+
- [ ] `flows/<feature-name>.yaml` written
40+
- [ ] `cdp_error_log` shows 0 new errors at end of flow
41+
- [ ] Cross-platform check via `cross_platform_verify` (or single-platform noted)
1642

1743
## Examples
1844

@@ -22,23 +48,11 @@ Test this React Native feature: $ARGUMENTS
2248
/rn-dev-agent:test-feature profile screen -- edit name, upload photo, save
2349
```
2450

25-
## What This Does
26-
27-
Invokes the `rn-tester` agent, which runs a 7-step verification protocol:
28-
29-
1. **Environment check** -- confirms Metro running, CDP connected, no RedBox
30-
2. **Understand the feature** -- reads implementation files, finds testIDs, routes, store slices
31-
3. **Plan the test** -- writes test steps and expected outcomes before executing
32-
4. **Navigate to start** -- uses deep links or Maestro to reach the starting screen
33-
5. **Execute and verify** -- for each step: act (Maestro), wait (assertVisible), verify UI (cdp_component_tree), verify data (cdp_store_state + cdp_network_log)
34-
6. **Edge cases** -- tests empty state, error state, back navigation, rapid interactions
35-
7. **Generate persistent test** -- writes `flows/<feature-name>.yaml` for CI
36-
3751
## Prerequisites
3852

3953
- iOS Simulator or Android Emulator running with the app loaded
4054
- Metro dev server running (`npx expo start` or `npx react-native start`)
41-
- Maestro or maestro-runner installed (`brew install maestro`)
55+
- Maestro or maestro-runner installed
4256
- For Zustand apps: `if (__DEV__) global.__ZUSTAND_STORES__ = { ... }` in app entry
4357

4458
## Output
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
---
22
title: Agents
3-
description: 5 specialized agents for testing, debugging, architecture, exploration, and code review.
3+
description: 5 specialized agents — 3 spawnable for parallel codebase analysis, 2 parent-session-only for live device testing and debugging.
44
---
55

6-
Agents are autonomous sub-agents that Claude Code spawns to handle specific tasks. Each agent has its own model, tools, and protocol.
6+
The plugin has **5 agents** split into two categories based on what tools they need.
7+
8+
## Spawnable agents (read-only)
9+
10+
These use only `Glob, Grep, LS, Read` — safe to spawn via the Task tool, typically in parallel.
711

812
| Agent | Model | Purpose |
913
|-------|-------|---------|
10-
| [`rn-tester`](/rn-dev-agent/agents/rn-tester/) | Sonnet | 7-step test verification protocol |
11-
| [`rn-debugger`](/rn-dev-agent/agents/rn-debugger/) || Parallel evidence gathering + targeted fix |
1214
| [`rn-code-explorer`](/rn-dev-agent/agents/rn-code-explorer/) | Sonnet | Codebase mapping: screens, store, navigation, testIDs |
1315
| [`rn-code-architect`](/rn-dev-agent/agents/rn-code-architect/) | Opus | Architecture design with E2E proof flow |
14-
| [`rn-code-reviewer`](/rn-dev-agent/agents/rn-code-reviewer/) || Correctness, RN conventions, project patterns |
16+
| [`rn-code-reviewer`](/rn-dev-agent/agents/rn-code-reviewer/) | Sonnet | Correctness, RN conventions, project patterns |
17+
18+
## Parent-session-only agents (protocol playbooks)
19+
20+
These agents' protocols require `cdp_*` / `device_*` MCP tools. **Do NOT spawn them via the Task tool** — MCP stdio connections don't propagate across subprocess boundaries (see [GitHub #31](https://github.com/Lykhoyda/rn-dev-agent/issues/31)). The agent files are **protocol playbooks** the parent session reads and executes inline.
21+
22+
| Agent | Model | Purpose | How to invoke |
23+
|-------|-------|---------|---------------|
24+
| [`rn-tester`](/rn-dev-agent/agents/rn-tester/) | Sonnet | 7-step test verification protocol | `/rn-dev-agent:test-feature` — runs inline |
25+
| [`rn-debugger`](/rn-dev-agent/agents/rn-debugger/) | Opus | Parallel evidence gathering + targeted fix | `/rn-dev-agent:debug-screen` — runs inline |
1526

1627
## When agents are used
1728

1829
In the `rn-feature-dev` pipeline:
19-
- **Phase 2 (Exploration):** 2-3 `rn-code-explorer` agents run in parallel
20-
- **Phase 4 (Architecture):** `rn-code-architect` designs the blueprint
21-
- **Phase 5.5 (Verification):** `rn-tester` verifies live on simulator
22-
- **Phase 6 (Review):** 3 `rn-code-reviewer` agents check different aspects
30+
- **Phase 2 (Exploration):** 2-3 `rn-code-explorer` agents spawned in parallel
31+
- **Phase 4 (Architecture):** `rn-code-architect` spawned for blueprint design
32+
- **Phase 5.5 (Verification):** Verification runs inline in parent session (MCP tools)
33+
- **Phase 6 (Review):** 2-3 `rn-code-reviewer` agents spawned in parallel
34+
- **Phase 8 (E2E Proof):** Proof flow runs inline in parent session (MCP tools)
2335

2436
Standalone:
25-
- `/debug-screen` spawns `rn-debugger`
26-
- `/test-feature` spawns `rn-tester`
37+
- `/rn-dev-agent:debug-screen` — runs the `rn-debugger` protocol inline
38+
- `/rn-dev-agent:test-feature` — runs the `rn-tester` protocol inline

0 commit comments

Comments
 (0)