Skip to content

Commit 5980041

Browse files
committed
feat(mcp): add clear-recordings agent tool
Add the clear-recordings agent tool to clear recorded HTTP calls, router navigations, and Analog server calls between reproduction runs. Gate the tool by the corresponding actions (http, router, analog) and broadcast clear events so connected devtools panels stay synchronized. Fixes pangular-inspector#331
1 parent d610a14 commit 5980041

7 files changed

Lines changed: 410 additions & 35 deletions

File tree

‎apps/docs/src/content/agents/mcp-server.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ The server registers tools with a colon, as `pangular:get-routes`. MCP clients s
208208

209209
### Read and action tools
210210

211-
The server marks read-only tools as read-only for your client. Eight tools act on the app, so the server does not mark them:
211+
The server marks read-only tools as read-only for your client. Nine tools act on the app, so the server does not mark them:
212212

213213
| Tool | Reference |
214214
| ---------------------- | ------------------------------------------------------------------ |
@@ -220,6 +220,7 @@ The server marks read-only tools as read-only for your client. Eight tools act o
220220
| `set-http-rule` | [Fault rules](./tools.md#fault-rules) |
221221
| `remove-http-rule` | [Fault rules](./tools.md#fault-rules) |
222222
| `analog-call-api` | [Call a server route](./tools.md#call-a-server-route) |
223+
| `clear-recordings` | [Clear recordings](./tools.md#clear-recordings) |
223224

224225
Your client can ask you before it runs them. To drop them from the server, set `agent.readOnly`. See [Inspectors and agent tools](../getting-started/configuration.md#inspectors-and-agent-tools).
225226

‎apps/docs/src/content/agents/tools.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Every agent tool the devtools expose, grouped by inspector, with wh
44
---
55

66
<ngmd-hero title="Tools" logo="https://cdn.simpleicons.org/modelcontextprotocol/71717A" gradient>
7-
Sixty-one tools, grouped by inspector. Each one answers a question you would otherwise answer by clicking through the panel.
7+
Sixty-two tools, grouped by inspector. Each one answers a question you would otherwise answer by clicking through the panel.
88
</ngmd-hero>
99

1010
# Tools
@@ -48,12 +48,12 @@ The URL comes from the HTTP or router report. A page that sends neither (no rout
4848
### Action tools
4949

5050
<ngmd-alert severity="important">
51-
<code>highlight</code>, <code>navigate</code>, <code>dispatch-ngrx-action</code>, <code>form-action</code>, <code>fill-form</code>, <code>set-http-rule</code>, <code>remove-http-rule</code> and <code>analog-call-api</code> act on the app. Every other tool is marked read-only for your client.
51+
<code>highlight</code>, <code>navigate</code>, <code>dispatch-ngrx-action</code>, <code>form-action</code>, <code>fill-form</code>, <code>set-http-rule</code>, <code>remove-http-rule</code>, <code>analog-call-api</code> and <code>clear-recordings</code> act on the app. Every other tool is marked read-only for your client.
5252
</ngmd-alert>
5353

5454
### Turn tools off
5555

56-
The server decides which tools exist. Set `agent.readOnly` to drop the eight action tools. Set `agent.tools.<inspector>` to `false` to hide one inspector's tools and resources, and keep its tab. Turning an inspector off with `inspectors`, or blocking an action with `actions`, drops the matching tools too. `actions.router` is the exception: `navigate` stays and refuses `navigate`, `abort`, `replay` and `probe`. See [Inspectors and agent tools](../getting-started/configuration.md#inspectors-and-agent-tools).
56+
The server decides which tools exist. Set `agent.readOnly` to drop the nine action tools. Set `agent.tools.<inspector>` to `false` to hide one inspector's tools and resources, and keep its tab. Turning an inspector off with `inspectors`, or blocking an action with `actions`, drops the matching tools too. `actions.router` is the exception: `navigate` stays and refuses `navigate`, `abort`, `replay` and `probe`. See [Inspectors and agent tools](../getting-started/configuration.md#inspectors-and-agent-tools).
5757

5858
## Source scan
5959

@@ -410,6 +410,18 @@ These tools read and change the rules of [Fault injection](../inspectors/ssr-htt
410410

411411
With [`actions.http`](../getting-started/configuration.md#actions) set to `false`, `set-http-rule` and `remove-http-rule` are dropped, and `list-http-rules` says that no rule applies.
412412

413+
### Clear recordings <ngmd-badge variant="alpha">Action</ngmd-badge>
414+
415+
Resets recorded data between reproduction runs: recorded HTTP calls, router navigations, and Analog server calls. Reads: page.
416+
417+
| Tool | What it does | Arguments |
418+
| ------------------ | -------------------------------------------------------------------------------------------------------------- | --------------------------- |
419+
| `clear-recordings` | Clears recorded HTTP calls, router navigations, or Analog server calls, and broadcasts the reset to the panel. | `target` (required), `page` |
420+
421+
`target` is one of `http`, `router`, `analog`, or `all`. With `router`, `page` clears navigations for that browser tab only; when left out, it clears navigations for every reporting page.
422+
423+
`clear-recordings` needs the matching write action ([`actions.http`](../getting-started/configuration.md#actions), `actions.router`, `actions.analog`). When `target` is `all` and an action is disabled, the permitted recordings are cleared and the disabled ones are reported as skipped.
424+
413425
## Capacitor
414426

415427
These tools read what a Capacitor app reported: its platform, its plugins and the plugin calls it made. See [Capacitor](../inspectors/capacitor.md). Reads: page.

‎apps/docs/src/content/getting-started/configuration.md‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ interface PangularConfig {
122122

123123
### Inspectors and agent tools
124124

125-
| Option | Default | What it does |
126-
| -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127-
| `inspectors.<name>` | `true` | `false` removes the inspector: no tab or dock, no page collector, no RPC functions, and no agent tools or resources. Its actions are blocked too. |
128-
| `agent.readOnly` | `false` | `true` drops every agent tool that acts on the page or the server: `highlight`, `form-action`, `fill-form`, `navigate`, `dispatch-ngrx-action`, `set-http-rule`, `remove-http-rule` and `analog-call-api`. |
129-
| `agent.tools.<name>` | `true` | `false` hides one inspector's agent tools and resources. The tab stays. |
125+
| Option | Default | What it does |
126+
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
127+
| `inspectors.<name>` | `true` | `false` removes the inspector: no tab or dock, no page collector, no RPC functions, and no agent tools or resources. Its actions are blocked too. |
128+
| `agent.readOnly` | `false` | `true` drops every agent tool that acts on the page or the server: `highlight`, `form-action`, `fill-form`, `navigate`, `dispatch-ngrx-action`, `set-http-rule`, `remove-http-rule`, `analog-call-api` and `clear-recordings`. |
129+
| `agent.tools.<name>` | `true` | `false` hides one inspector's agent tools and resources. The tab stays. |
130130

131131
`agent.tools` has the same keys as `inspectors`. An inspector that is off has no agent tools, whatever `agent.tools` says.
132132

@@ -136,14 +136,14 @@ If you open a tab that is turned off, the panel says so, shows the option that t
136136

137137
Actions are the writes that the panel and agents make to your app or the server.
138138

139-
| Option | Default | What `false` blocks |
140-
| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
141-
| `actions.forms` | `true` | Form writes: set value, fill, mark touched, untouched, dirty or pristine, touch all, revalidate, reset, enable, disable, submit and restore. Drops `form-action` and `fill-form`. |
142-
| `actions.router` | `true` | Navigate, abort, replay and probe, and clearing the navigations list. Probe runs your app's `canMatch` guards. The `navigate` agent tool stays for `instrument` and `resolve-lazy` and refuses the other four. |
143-
| `actions.ngrx` | `true` | Restoring NgRx state from the change log and dispatching `@ngrx/store` actions. Drops the `dispatch-ngrx-action` agent tool. |
144-
| `actions.http` | `true` | Editing fault injection rules and SSR overrides, and clearing the HTTP timeline. Drops the `set-http-rule` and `remove-http-rule` agent tools. |
145-
| `actions.analog` | `true` | The Analog request playground. Drops the `analog-call-api` agent tool. |
146-
| `actions` | `true` | All of the above. |
139+
| Option | Default | What `false` blocks |
140+
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
141+
| `actions.forms` | `true` | Form writes: set value, fill, mark touched, untouched, dirty or pristine, touch all, revalidate, reset, enable, disable, submit and restore. Drops `form-action` and `fill-form`. |
142+
| `actions.router` | `true` | Navigate, abort, replay and probe, and clearing the navigations list. Drops router clearing in `clear-recordings`. The `navigate` agent tool stays for `instrument` and `resolve-lazy` and refuses the other four. |
143+
| `actions.ngrx` | `true` | Restoring NgRx state from the change log and dispatching `@ngrx/store` actions. Drops the `dispatch-ngrx-action` agent tool. |
144+
| `actions.http` | `true` | Editing fault injection rules and SSR overrides, and clearing the HTTP timeline. Drops the `set-http-rule` and `remove-http-rule` agent tools and HTTP clearing in `clear-recordings`. |
145+
| `actions.analog` | `true` | The Analog request playground and clearing server calls. Drops the `analog-call-api` agent tool and Analog clearing in `clear-recordings`. |
146+
| `actions` | `true` | All of the above. |
147147

148148
Pass `actions: false` to block every action, or an object to block some. Keys you leave out of the object stay on.
149149

0 commit comments

Comments
 (0)