You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(mcp): pause is a follow-up to run_test, not standalone
run_test now spawns its subprocess in pause yield mode and returns early
with {status:"paused"} when the test hits pause(). The agent then drives
the REPL through the new "pause" tool, which only takes a code string.
Drops the standalone pause_session.start action — pause only makes sense
when a test is already running. Resume / step / exit are just code values
(matching the TTY pause REPL conventions).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
description: 'Run a specific test. If the test calls pause(), this tool returns early with status "paused" — call the "pause" tool to interact, then send code:"resume" to let the test finish. Otherwise returns when the test completes with the json reporter result.',
description: 'Run code inside a paused test, mirroring the human pause() REPL. Two actions: "start" spawns a test and waits for it to hit pause(); "run" sends a code line (same syntax as the TTY pause REPL — empty string steps to the next test step, "resume" continues the test, "exit" aborts; any other input is treated as I.<expr> unless prefixed with "=>"). Each run returns the value plus an artifact bundle (URL, ARIA, HTML, screenshot, console, storage), like run_code.',
429
+
name: 'pause',
430
+
description: 'Send a single line of code to a paused test (one that called pause() during run_test). Same syntax as the TTY pause REPL: an expression like "click(\'Save\')" runs as I.click(\'Save\'); prefix "=>" for raw JS; empty string steps to the next test step; "resume" continues the test to completion; "exit" aborts. Returns the next protocol message — typically {event:"result", ok, value, artifacts, error}, or {event:"paused"} after a step, or {event:"exited", exitInfo} if the test ended.',
Copy file name to clipboardExpand all lines: docs/mcp.md
+46-40Lines changed: 46 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,80 +235,86 @@ Capture the current state of the browser without performing any action. Useful f
235
235
}
236
236
```
237
237
238
-
### pause_session
238
+
### pause
239
239
240
-
Mirrors the human `pause()` REPL for an AI agent: send a code string, get a result with artifacts (same shape as `run_code`).
240
+
Send one line of input to a test that's currently paused at `pause()`. Mirrors the human pause REPL — send code, get a result with the same artifact bundle as `run_code`.
241
241
242
-
Two actions:
242
+
`pause` is only valid while a `run_test` invocation is yielded at a paused subprocess. The flow is:
243
243
244
-
| Action | Params | Effect |
245
-
|---|---|---|
246
-
|`start`|`test`, `config?`, `timeout?`| Spawn the test subprocess in pause yield mode. Resolves when the test hits `pause()` and emits `{event:"paused"}`. |
247
-
|`run`|`code`, `timeout?`| Send one line of input — same syntax as the TTY REPL. Returns the next protocol message from the subprocess. |
244
+
1. Agent calls `run_test`. If the test reaches `pause()`, `run_test` returns `{status:"paused", paused:{event:"paused"}}` and keeps the subprocess alive.
245
+
2. Agent calls `pause` with `code` strings to drive the REPL.
246
+
3. Agent sends `code:"resume"` (or `code:"exit"`) to let the test finish; the subprocess exits and pause state is cleared.
248
247
249
-
`code` follows the TTY pause REPL conventions:
250
-
- An expression like `click('Save')` runs as `I.click('Save')` and returns `{event:"result", ok, value, artifacts, error}`.
251
-
- Prefix `=>` to evaluate raw JS: `=> myVar.id`.
252
-
-`""` (empty) → step to the next test step. The subprocess re-pauses; response is `{event:"step"}` followed by `{event:"paused"}` on the next `run` call.
253
-
-`"resume"` → continue the test to completion. Response is `{event:"resumed"}`; the subprocess will exit on its own.
254
-
-`"exit"` → abort the paused test. Same `{event:"resumed"}` response, then exit.
248
+
`code` syntax (same as the TTY pause REPL):
255
249
256
-
Each result includes the artifact bundle (URL, ARIA, HTML, screenshot, console, storage), like `run_code`. If the subprocess exits during a `run`, the response is `{event:"exited", exitInfo:{code, signal}}`.
|`"=> myVar.id"`| Evaluates raw JS in the paused scope. Returns `{event:"result", ...}`. |
254
+
|`""` (empty) | Step to the next test step. Returns `{event:"step"}`; the subprocess re-pauses, and the next `pause` call returns `{event:"paused"}` again. |
255
+
|`"resume"`| Continue the test to completion. Returns `{event:"resumed"}`; the subprocess will exit on its own. |
256
+
|`"exit"`| Abort the paused test. Returns `{event:"resumed"}`, then the subprocess exits. |
257
257
258
-
**Lifecycle example:**
258
+
If the subprocess exits during a call, the response is `{event:"exited", exitInfo:{code, signal}}` and pause state is cleared.
259
+
260
+
**Parameters:**
261
+
-`code` (optional, default `""`): the line to send.
262
+
-`timeout` (optional): ms to wait for the response (default 60000).
-The subprocess is spawned with `CODECEPTJS_MCP=1` and `CODECEPTJS_MCP_PAUSE=1` so `pause()`calls in the test land in yield mode.
271
-
-`pause()`calls running under`CODECEPTJS_MCP=1`*without*`CODECEPTJS_MCP_PAUSE=1` print a notice and return immediately so leftover `pause()` calls don't deadlock CI runs invoked through MCP.
278
+
-`run_test` always spawns its subprocess with `CODECEPTJS_MCP=1` and `CODECEPTJS_MCP_PAUSE=1`, so any `pause()`call in the test lands in yield mode.
279
+
-A `pause()`call running with`CODECEPTJS_MCP=1`set but `CODECEPTJS_MCP_PAUSE` unset (e.g., a different MCP-aware caller, or future tooling) prints a notice and returns immediately, so leftover `pause()` calls don't deadlock.
272
280
- TTY behaviour (`npx codeceptjs run --debug` at a terminal) is unchanged — the readline REPL is used whenever `process.stdin.isTTY` is true.
273
281
274
282
### run_test
275
283
276
-
Run a specific test by name or file path. Uses subprocess to run tests with isolation.
284
+
Run a specific test by name or file path. Subprocess is spawned with pause yield mode enabled — if the test calls `pause()`, this tool returns early and the agent drives the REPL via the [`pause`](#pause) tool.
277
285
278
286
**Parameters:**
279
287
-`test` (required): Test name or file path
280
288
-`timeout` (optional): Timeout in milliseconds (default: 60000)
0 commit comments