High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
perf(mcp)!: collapse the wait, keyboard and record tool families into one tool each
Luigi Agosti15af50c15ef1
diff --git a/RELEASE.md b/RELEASE.mdindex c1524421..9440d040 100644--- a/RELEASE.md+++ b/RELEASE.md@@ -215,6 +215,33 @@ git push origin v0.7.1- One tag = one release (all artifacts)- npm version must match Go binary tag+## Breaking changes to note in the next release++**BREAKING (MCP tool surface): 14 tools collapsed into 3.** An MCP client re-reads the tool+list from the server on every session, so no client is stranded on the old names — but any+hand-written skill or prompt that names one has to be updated:++| Removed | Replacement |+| --- | --- |+| `pinchtab_wait(ms=…)` | `pinchtab_wait(for="ms", value=…)` |+| `pinchtab_wait_for_selector(selector=…)` | `pinchtab_wait(for="selector", value=…)` |+| `pinchtab_wait_for_text(text=…)` | `pinchtab_wait(for="text", value=…)` |+| `pinchtab_wait_for_url(url=…)` | `pinchtab_wait(for="url", value=…)` |+| `pinchtab_wait_for_load(load=…)` | `pinchtab_wait(for="load", value=…)` |+| `pinchtab_wait_for_function(fn=…)` | `pinchtab_wait(for="function", value=…)` |+| `pinchtab_press(key=…)` | `pinchtab_key(action="press", key=…)` |+| `pinchtab_keydown(key=…)` | `pinchtab_key(action="down", key=…)` |+| `pinchtab_keyup(key=…)` | `pinchtab_key(action="up", key=…)` |+| `pinchtab_keyboard_type(text=…)` | `pinchtab_key(action="type", text=…)` |+| `pinchtab_keyboard_inserttext(text=…)` | `pinchtab_key(action="insert", text=…)` |+| `pinchtab_record_start(file=…)` | `pinchtab_record(action="start", file=…)` |+| `pinchtab_record_stop(file=…)` | `pinchtab_record(action="stop", file=…)` |+| `pinchtab_record_status()` | `pinchtab_record(action="status")` |++Every parameter of the removed tools is carried over unchanged (`timeout` and `state` on+selector waits, `fps`/`quality`/`scale`/`tabId` on recording, `nodeId` on key presses). The+tool list an agent loads at session start drops from 47 tools to 36.+## See also- `.github/workflows/release.yml` — GitHub Actions workflowdiff --git a/docs/architecture/mcp.md b/docs/architecture/mcp.mdindex f7762815..5c01c910 100644--- a/docs/architecture/mcp.md+++ b/docs/architecture/mcp.md@@ -104,11 +104,11 @@ URL validation lives in `handleNavigate` (`handlers_navigation.go`), which calls| Category | Count | REST Endpoints Used ||----------|-------|---------------------|| Navigation | 5 | `/navigate`, `/snapshot`, `/frame`, `/screenshot`, `/text` |-| Interaction | 9 | `/action` |-| Keyboard | 4 | `/action` |+| Interaction | 8 | `/action` |+| Keyboard | 1 | `/action` || Content | 3 | `/evaluate`, `/pdf`, `/find` || Tab Management | 5 | `/tabs`, `/health`, `/cookies`, `/profiles/{id}/instance` |-| Wait utilities | 6 | `/wait` |+| Wait utilities | 1 | `/wait` || Network | 5 | `/network`, `/network/route` (POST/DELETE) || Dialog | 1 | `/dialog` |@@ -118,7 +118,7 @@ URL validation lives in `handleNavigate` (`handlers_navigation.go`), which calls- **`pinchtab_cookies`** and **`pinchtab_cookies_set`** call `/cookies`, which requires `security.allowCookies: true`. Cookie values can expose session credentials, and setting one grants a session, so cookie operations are disabled by default.- **URL validation** — `pinchtab_navigate` rejects non-HTTP/HTTPS URLs to prevent SSRF via `file://`, `javascript:`, or custom schemes.- **Token forwarding** — the MCP client forwards the configured bearer token to PinchTab, so access control at the PinchTab layer applies to all tool calls.-- **Wait caps** — `pinchtab_wait` and `pinchtab_wait_for_selector` enforce a 30-second maximum to prevent agent runaway.+- **Wait caps** — `pinchtab_wait` enforces a 30-second maximum on both the fixed `for=ms` sleep and the `timeout` of every browser-backed condition, to prevent agent runaway.## Related Pagesdiff --git a/docs/guides/mcp-agents.md b/docs/guides/mcp-agents.mdindex 48f33ffb..4a0e8400 100644--- a/docs/guides/mcp-agents.md+++ b/docs/guides/mcp-agents.md@@ -146,7 +146,7 @@ Tool calls:→ ...input[ref=e3] placeholder="Search Wikipedia"...pinchtab_click({selector: "e3"})pinchtab_type({selector: "e3", text: "climate change"})- pinchtab_press({key: "Enter"})+ pinchtab_key({action: "press", key: "Enter"})pinchtab_snapshot({format: "compact"})pinchtab_get_text({})```diff --git a/docs/mcp.md b/docs/mcp.mdindex caa95af8..2f91ef71 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -81,16 +81,16 @@ PINCHTAB_TOKEN=<that-host-token> pinchtab --server http://remote:9867 mcp## Available Tools-PinchTab currently exposes 47 tools:+PinchTab currently exposes 36 tools:- Navigation: 9-- Interaction: 9-- Keyboard: 4+- Interaction: 8+- Keyboard: 1- Content: 3-- Recording: 3+- Recording: 1- Site: 1- Tab management: 5-- Wait utilities: 6+- Wait utilities: 1- Network: 5- Dialog: 1@@ -110,7 +110,6 @@ PinchTab currently exposes 47 tools:- `pinchtab_click`- `pinchtab_type`-- `pinchtab_press`- `pinchtab_hover`- `pinchtab_focus`- `pinchtab_select`@@ -120,10 +119,7 @@ PinchTab currently exposes 47 tools:### Keyboard-- `pinchtab_keyboard_type`-- `pinchtab_keyboard_inserttext`-- `pinchtab_keydown`-- `pinchtab_keyup`+- `pinchtab_key` — `action` is `press`, `down`, `up`, `type` or `insert`### Content@@ -133,9 +129,7 @@ PinchTab currently exposes 47 tools:### Recording-- `pinchtab_record_start`-- `pinchtab_record_stop`-- `pinchtab_record_status`+- `pinchtab_record` — `action` is `start`, `stop` or `status`### Site@@ -152,12 +146,7 @@ PinchTab currently exposes 47 tools:### Wait Utilities-- `pinchtab_wait`-- `pinchtab_wait_for_selector`-- `pinchtab_wait_for_text`-- `pinchtab_wait_for_url`-- `pinchtab_wait_for_load`-- `pinchtab_wait_for_function`+- `pinchtab_wait` — `for` is `ms`, `selector`, `text`, `url`, `load` or `function`, and `value` carries the condition### Networkdiff --git a/docs/reference/mcp-tools.md b/docs/reference/mcp-tools.mdindex bc1272f4..a13fb9f4 100644--- a/docs/reference/mcp-tools.md+++ b/docs/reference/mcp-tools.md@@ -1,6 +1,6 @@# MCP Tool Reference-PinchTab currently exposes 43 MCP tools. All tool names are prefixed with `pinchtab_` and are served over stdio JSON-RPC.+PinchTab currently exposes 36 MCP tools. All tool names are prefixed with `pinchtab_` and are served over stdio JSON-RPC.For selector-based interaction tools, prefer `selector`. `ref` and `query` are still accepted as deprecated/alias fallbacks on the element-action tools (`query` is shorthand for `find:<text>`).@@ -40,7 +40,6 @@ All element-action tools accept the unified `selector` and the legacy aliases `r| --- | --- | --- || `pinchtab_click` | `selector`, `ref`, `query`, `tabId`, `x`, `y`, `nodeId`, `dialogAction`, `dialogText`, `waitNav`, `mode`, `snap` | Click element by selector or coordinate; `mode` accepts `dom` or `dispatch` as a broad low-level escape hatch for click delivery; `mode` and `humanize` are mutually exclusive; `dialogAction` handles a dialog opened by the click; `waitNav=true` waits for navigation; `snap=true` returns a snapshot || `pinchtab_type` | `selector`, `ref`, `query`, `nodeId`, `text` required, `tabId` | Sends key events at the targeted input; target with `selector` or `nodeId` |-| `pinchtab_press` | `key` required, `nodeId`, `tabId` | Press a key such as `Enter`; `nodeId` focuses that node first, otherwise the key goes to the focused element || `pinchtab_hover` | `selector`, `ref`, `query`, `tabId`, `x`, `y`, `nodeId` | Hover an element or coordinate || `pinchtab_focus` | `selector`, `ref`, `query`, `tabId`, `nodeId` | Focus element || `pinchtab_select` | `selector`, `ref`, `query`, `nodeId`, `value` required, `tabId`, `snap` | Select `<option>` by value or visible text; target with `selector` or `nodeId` |@@ -52,10 +51,7 @@ All element-action tools accept the unified `selector` and the legacy aliases `r| Tool | Key Parameters | Notes || --- | --- | --- |-| `pinchtab_keyboard_type` | `text` required, `tabId` | Types at the currently focused element |-| `pinchtab_keyboard_inserttext` | `text` required, `tabId` | Paste-like insert without key events |-| `pinchtab_keydown` | `key` required, `tabId` | Hold a key down |-| `pinchtab_keyup` | `key` required, `tabId` | Release a key |+| `pinchtab_key` | `action` required, `key`, `text`, `nodeId`, `tabId` | One keyboard tool. `action=press` presses a key such as `Enter` (`nodeId` focuses that node first, otherwise the key goes to the focused element); `down` holds a key; `up` releases it; `type` types at the focused element with key events; `insert` is a paste-like insert without key events. `press`/`down`/`up` need `key`, `type`/`insert` need `text`. `nodeId` is honoured by `press` only |## Content@@ -86,12 +82,7 @@ All element-action tools accept the unified `selector` and the legacy aliases `r| Tool | Key Parameters | Notes || --- | --- | --- |-| `pinchtab_wait` | `ms` required | Fixed-duration wait, capped at 30000 ms |-| `pinchtab_wait_for_selector` | `selector` required, `timeout`, `state`, `tabId` | `state` is `visible` (default) or `hidden` |-| `pinchtab_wait_for_text` | `text` required, `timeout`, `tabId` | Wait for body text |-| `pinchtab_wait_for_url` | `url` required, `timeout`, `tabId` | URL glob match |-| `pinchtab_wait_for_load` | `load` required, `timeout`, `tabId` | `load` is `ready-state` (`readyState=complete`), `content-loaded` (`readyState` in `{interactive, complete}`), or `network-idle` (0 in-flight requests for 500 ms) |-| `pinchtab_wait_for_function` | `fn` required, `timeout`, `tabId` | JS expression must become truthy |+| `pinchtab_wait` | `for` required, `value` required, `timeout`, `state`, `tabId` | One wait tool: `for` names the condition and `value` carries it. `for=ms` is a fixed-duration wait capped at 30000 ms; `selector` waits for an element (`state` is `visible` (default) or `hidden`); `text` waits for body text; `url` is a URL glob match; `load` is `ready-state` (`readyState=complete`), `content-loaded` (`readyState` in `{interactive, complete}`), or `network-idle` (0 in-flight requests for 500 ms); `function` waits for a JS expression to become truthy |## Network@@ -107,9 +98,7 @@ All element-action tools accept the unified `selector` and the legacy aliases `r| Tool | Key Parameters | Notes || --- | --- | --- |-| `pinchtab_record_start` | `file` required, `fps`, `quality`, `scale`, `tabId` | Start recording; format inferred from extension (`.gif`, `.webm`, `.mp4`). Requires `security.allowScreencast`. GIF works without ffmpeg |-| `pinchtab_record_stop` | `file` required | Stop recording, encode, and save to `file`. Encoding may take a while for long recordings |-| `pinchtab_record_status` | — | Returns active recording status (format, fps, duration, frame count) |+| `pinchtab_record` | `action` required, `file`, `fps`, `quality`, `scale`, `tabId` | One recording tool. `action=start` starts recording (format inferred from the `file` extension — `.gif`, `.webm`, `.mp4`; requires `security.allowScreencast`; GIF works without ffmpeg); `stop` encodes and saves to `file`, which may take a while for long recordings; `status` returns the active recording status (format, fps, duration, frame count) |## Dialogdiff --git a/internal/mcp/handlers.go b/internal/mcp/handlers.goindex ef46d205..211924f4 100644--- a/internal/mcp/handlers.go+++ b/internal/mcp/handlers.go@@ -35,7 +35,6 @@ func rawHandlerMap(c *Client) map[string]func(context.Context, mcp.CallToolReque"pinchtab_click": handleAction(c, "click"),"pinchtab_type": handleAction(c, "type"),- "pinchtab_press": handleAction(c, "press"),"pinchtab_hover": handleAction(c, "hover"),"pinchtab_focus": handleAction(c, "focus"),"pinchtab_select": handleAction(c, "select"),@@ -43,10 +42,7 @@ func rawHandlerMap(c *Client) map[string]func(context.Context, mcp.CallToolReque"pinchtab_scroll_into_view": handleAction(c, "scrollintoview"),"pinchtab_fill": handleAction(c, "fill"),- "pinchtab_keyboard_type": handleKeyboardText(c, "keyboard-type"),- "pinchtab_keyboard_inserttext": handleKeyboardText(c, "keyboard-inserttext"),- "pinchtab_keydown": handleKeyboardKey(c, "keydown"),- "pinchtab_keyup": handleKeyboardKey(c, "keyup"),+ "pinchtab_key": handleKeyboard(c),"pinchtab_eval": handleEval(c),"pinchtab_pdf": handlePDF(c),@@ -59,12 +55,7 @@ func rawHandlerMap(c *Client) map[string]func(context.Context, mcp.CallToolReque"pinchtab_cookies_set": handleCookiesSet(c),"pinchtab_connect_profile": handleConnectProfile(c),- "pinchtab_wait": handleWait(),- "pinchtab_wait_for_selector": handleWaitForSelector(c),- "pinchtab_wait_for_text": handleWaitForText(c),- "pinchtab_wait_for_url": handleWaitForURL(c),- "pinchtab_wait_for_load": handleWaitForLoad(c),- "pinchtab_wait_for_function": handleWaitForFunction(c),+ "pinchtab_wait": handleWait(c),"pinchtab_network": handleNetwork(c),"pinchtab_network_detail": handleNetworkDetail(c),@@ -72,9 +63,7 @@ func rawHandlerMap(c *Client) map[string]func(context.Context, mcp.CallToolReque"pinchtab_network_route": handleNetworkRoute(c),"pinchtab_network_unroute": handleNetworkUnroute(c),- "pinchtab_record_start": handleRecordStart(c),- "pinchtab_record_stop": handleRecordStop(c),- "pinchtab_record_status": handleRecordStatus(c),+ "pinchtab_record": handleRecord(c),"pinchtab_dialog": handleDialog(c),diff --git a/internal/mcp/handlers_helpers.go b/internal/mcp/handlers_helpers.goindex 8d97c39b..22034f84 100644--- a/internal/mcp/handlers_helpers.go+++ b/internal/mcp/handlers_helpers.go@@ -3,6 +3,7 @@ package mcpimport ("encoding/json""fmt"+ "sort""strconv""strings"@@ -55,6 +56,20 @@ func optBool(r mcp.CallToolRequest, key string) (bool, bool) {return false, false}+func pickMode[T any](r mcp.CallToolRequest, key string, table map[string]T) (string, T, *mcp.CallToolResult) {+ name := optTrimmedString(r, key)+ if entry, ok := table[name]; ok {+ return name, entry, nil+ }+ names := make([]string, 0, len(table))+ for candidate := range table {+ names = append(names, candidate)+ }+ sort.Strings(names)+ var zero T+ return "", zero, mcp.NewToolResultError(fmt.Sprintf("'%s' must be one of %s, got %q", key, strings.Join(names, ", "), name))+}+func firstNonEmptyString(r mcp.CallToolRequest, keys ...string) string {for _, key := range keys {if v := optTrimmedString(r, key); v != "" {diff --git a/internal/mcp/handlers_interaction.go b/internal/mcp/handlers_interaction.goindex 3ccbcedb..855862d7 100644--- a/internal/mcp/handlers_interaction.go+++ b/internal/mcp/handlers_interaction.go@@ -159,13 +159,6 @@ func handleAction(c *Client, kind string) func(context.Context, mcp.CallToolRequ}payload["text"] = text- case "press":- key, err := r.RequireString("key")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- payload["key"] = key-case "select":if _, refusal := resolveSelector(!hasNodeID); refusal != nil {return refusal, nil@@ -317,34 +310,36 @@ func handleAction(c *Client, kind string) func(context.Context, mcp.CallToolRequ}}-func handleKeyboardText(c *Client, kind string) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- text, err := r.RequireString("text")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- payload := map[string]any{"kind": kind, "text": text}- if tabID := optString(r, "tabId"); tabID != "" {- payload["tabId"] = tabID- }- body, code, err := c.Post(ctx, routedPathWithBody(r, "/action", payload), payload)- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return resultFromBytes(body, code)- }+type keyboardAction struct {+ kind string+ arg string+}++var keyboardActions = map[string]keyboardAction{+ "press": {kind: "press", arg: "key"},+ "down": {kind: "keydown", arg: "key"},+ "up": {kind: "keyup", arg: "key"},+ "type": {kind: "keyboard-type", arg: "text"},+ "insert": {kind: "keyboard-inserttext", arg: "text"},}-func handleKeyboardKey(c *Client, kind string) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {+func handleKeyboard(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- key, err := r.RequireString("key")+ _, action, refusal := pickMode(r, "action", keyboardActions)+ if refusal != nil {+ return refusal, nil+ }+ value, err := r.RequireString(action.arg)if err != nil {return mcp.NewToolResultError(err.Error()), nil}- payload := map[string]any{"kind": kind, "key": key}+ payload := map[string]any{"kind": action.kind, action.arg: value}if tabID := optString(r, "tabId"); tabID != "" {payload["tabId"] = tabID}+ if nodeID, ok := optInt(r, "nodeId"); ok && nodeID > 0 {+ payload["nodeId"] = nodeID+ }body, code, err := c.Post(ctx, routedPathWithBody(r, "/action", payload), payload)if err != nil {return mcp.NewToolResultError(err.Error()), nildiff --git a/internal/mcp/handlers_interaction_test.go b/internal/mcp/handlers_interaction_test.goindex ca4a232c..82274ed4 100644--- a/internal/mcp/handlers_interaction_test.go+++ b/internal/mcp/handlers_interaction_test.go@@ -223,8 +223,9 @@ func TestHandlePress(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_press", map[string]any{- "key": "Enter",+ r := callTool(t, "pinchtab_key", map[string]any{+ "action": "press",+ "key": "Enter",}, srv)text := resultText(t, r)@@ -233,6 +234,47 @@ func TestHandlePress(t *testing.T) {}}+// The five keyboard actions are one tool over one endpoint, so each has to reach+// /action under the bridge kind that implements it, carrying its own argument —+// a wrong kind is dispatched as a different keystroke, silently.+func TestEveryKeyboardActionReachesItsBridgeKind(t *testing.T) {+ for _, tc := range []struct{ action, arg, value, kind string }{+ {"press", "key", "Enter", "press"},+ {"down", "key", "Control", "keydown"},+ {"up", "key", "Control", "keyup"},+ {"type", "text", "hello", "keyboard-type"},+ {"insert", "text", "hello", "keyboard-inserttext"},+ } {+ t.Run(tc.action, func(t *testing.T) {+ srv, _ := upstreamRecorder(t)++ r := callTool(t, "pinchtab_key", map[string]any{"action": tc.action, tc.arg: tc.value}, srv)+ if r.IsError {+ t.Fatalf("action=%q was rejected: %s", tc.action, resultText(t, r))+ }+ body, _ := resultJSON(t, r)["body"].(map[string]any)+ if got, _ := body["kind"].(string); got != tc.kind {+ t.Errorf("action=%q sent kind=%q, want %q", tc.action, got, tc.kind)+ }+ if got, _ := body[tc.arg].(string); got != tc.value {+ t.Errorf("action=%q sent %s=%q, want %q", tc.action, tc.arg, got, tc.value)+ }+ })+ }+}++func TestKeyboardRefusesAnUnknownAction(t *testing.T) {+ srv, paths := upstreamRecorder(t)++ r := callTool(t, "pinchtab_key", map[string]any{"action": "tap", "key": "Enter"}, srv)+ if !r.IsError {+ t.Fatalf("action=\"tap\" was accepted; upstream saw %v", *paths)+ }+ if text := resultText(t, r); !strings.Contains(text, "press") || !strings.Contains(text, "insert") {+ t.Errorf("refusal %q does not list the accepted actions, so the caller cannot correct it", text)+ }+}+func TestHandleSelect(t *testing.T) {srv := mockPinchTab()defer srv.Close()@@ -514,7 +556,7 @@ var actionToolTargets = []struct {{tool: "pinchtab_select", requiredArgs: map[string]any{"value": "v"}, selectorOptionalWithNodeID: true},{tool: "pinchtab_scroll_into_view", selectorOptionalWithNodeID: true},{tool: "pinchtab_scroll"},- {tool: "pinchtab_press", requiredArgs: map[string]any{"key": "Enter"}},+ {tool: "pinchtab_key", requiredArgs: map[string]any{"action": "press", "key": "Enter"}},}func actionArgs(tool string, extra map[string]any) map[string]any {diff --git a/internal/mcp/handlers_navigation_test.go b/internal/mcp/handlers_navigation_test.goindex 5098533c..7e4655bb 100644--- a/internal/mcp/handlers_navigation_test.go+++ b/internal/mcp/handlers_navigation_test.go@@ -616,8 +616,8 @@ func TestWaitTimeoutAcceptsStringForm(t *testing.T) {srv := mockPinchTab()defer srv.Close()- text := resultText(t, callTool(t, "pinchtab_wait_for_selector",- map[string]any{"selector": "#done", "timeout": "5"}, srv))+ text := resultText(t, callTool(t, "pinchtab_wait",+ map[string]any{"for": "selector", "value": "#done", "timeout": "5"}, srv))if !strings.Contains(text, `"timeout":5`) {t.Errorf("string-form timeout did not reach the wait body: %s", text)}diff --git a/internal/mcp/handlers_record.go b/internal/mcp/handlers_record.goindex 3e07cd16..cd5d7ce4 100644--- a/internal/mcp/handlers_record.go+++ b/internal/mcp/handlers_record.go@@ -12,6 +12,21 @@ import ("github.com/pinchtab/pinchtab/internal/readiness")+func handleRecord(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {+ actions := map[string]func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error){+ "start": handleRecordStart(c),+ "stop": handleRecordStop(c),+ "status": handleRecordStatus(c),+ }+ return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {+ _, action, refusal := pickMode(r, "action", actions)+ if refusal != nil {+ return refusal, nil+ }+ return action(ctx, r)+ }+}+func handleRecordStart(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {file, err := r.RequireString("file")@@ -75,8 +90,6 @@ func handleRecordStop(c *Client) func(context.Context, mcp.CallToolRequest) (*mcreturn mcp.NewToolResultError(msg), nil}- // Server encodes to a controlled recordings directory; we move the- // file to the caller's desired destination after encoding completes.body, code, err := c.Post(ctx, "/record/stop", map[string]any{})if err != nil {return mcp.NewToolResultError(err.Error()), nildiff --git a/internal/mcp/handlers_record_test.go b/internal/mcp/handlers_record_test.goindex bb779b2e..11c8512f 100644--- a/internal/mcp/handlers_record_test.go+++ b/internal/mcp/handlers_record_test.go@@ -85,8 +85,9 @@ func TestRecordStartRejectsRelativePath(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_record_start", map[string]any{- "file": "relative/out.gif",+ r := callTool(t, "pinchtab_record", map[string]any{+ "action": "start",+ "file": "relative/out.gif",}, srv)text := resultText(t, r)@@ -105,8 +106,9 @@ func TestRecordStartRejectsExistingFile(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_record_start", map[string]any{- "file": existing,+ r := callTool(t, "pinchtab_record", map[string]any{+ "action": "start",+ "file": existing,}, srv)text := resultText(t, r)@@ -115,6 +117,32 @@ func TestRecordStartRejectsExistingFile(t *testing.T) {}}+func TestRecordStatusReachesTheStatusEndpoint(t *testing.T) {+ srv := mockPinchTab()+ defer srv.Close()++ r := callTool(t, "pinchtab_record", map[string]any{"action": "status"}, srv)+ if r.IsError {+ t.Fatalf("action=status was rejected: %s", resultText(t, r))+ }+ if got, _ := resultJSON(t, r)["path"].(string); got != "/record/status" {+ t.Errorf("action=status reached %q, want /record/status", got)+ }+}++func TestRecordRefusesAnUnknownAction(t *testing.T) {+ srv := mockPinchTab()+ defer srv.Close()++ r := callTool(t, "pinchtab_record", map[string]any{"action": "pause"}, srv)+ if !r.IsError {+ t.Fatal("action=\"pause\" was accepted")+ }+ if text := resultText(t, r); !strings.Contains(text, "start") || !strings.Contains(text, "status") {+ t.Errorf("refusal %q does not list the accepted actions, so the caller cannot correct it", text)+ }+}+func TestRecordStopBadPathStillStopsRecording(t *testing.T) {stopCalled := falsesrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -131,11 +159,11 @@ func TestRecordStopBadPathStillStopsRecording(t *testing.T) {c := NewClient(srv.URL, "")handlers := handlerMap(c)- h := handlers["pinchtab_record_stop"]+ h := handlers["pinchtab_record"]req := mcp.CallToolRequest{}- req.Params.Name = "pinchtab_record_stop"- req.Params.Arguments = map[string]any{"file": "relative/bad.gif"}+ req.Params.Name = "pinchtab_record"+ req.Params.Arguments = map[string]any{"action": "stop", "file": "relative/bad.gif"}result, err := h(context.Background(), req)if err != nil {@@ -187,14 +215,14 @@ func TestRecordStopUsesLongTimeout(t *testing.T) {c := NewClient(srv.URL, "")handlers := handlerMap(c)- h := handlers["pinchtab_record_stop"]+ h := handlers["pinchtab_record"]dir := t.TempDir()outFile := filepath.Join(dir, "test.gif")req := mcp.CallToolRequest{}- req.Params.Name = "pinchtab_record_stop"- req.Params.Arguments = map[string]any{"file": outFile}+ req.Params.Name = "pinchtab_record"+ req.Params.Arguments = map[string]any{"action": "stop", "file": outFile}_, err := h(context.Background(), req)if err != nil {diff --git a/internal/mcp/handlers_wait.go b/internal/mcp/handlers_wait.goindex 5515cf78..948e8eb0 100644--- a/internal/mcp/handlers_wait.go+++ b/internal/mcp/handlers_wait.go@@ -3,79 +3,58 @@ package mcpimport ("context""fmt"+ "strconv"+ "strings""time""github.com/mark3labs/mcp-go/mcp")-func handleWait() func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {+var waitModes = map[string]string{+ "ms": "ms",+ "selector": "selector",+ "text": "text",+ "url": "url",+ "load": "load",+ "function": "fn",+}++func handleWait(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- ms, err := r.RequireFloat("ms")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil+ mode, field, refusal := pickMode(r, "for", waitModes)+ if refusal != nil {+ return refusal, nil}- if ms < 0 {- ms = 0+ value, refusal := suppliedStringArg(r, "wait", "value", "", "value")+ if refusal != nil {+ return refusal, nil}- if ms > maxWaitMS {- ms = maxWaitMS+ if strings.TrimSpace(value) == "" {+ return mcp.NewToolResultError(fmt.Sprintf("wait for=%q needs a non-empty 'value'", mode)), nil}- select {- case <-time.After(time.Duration(ms) * time.Millisecond):- return mcp.NewToolResultText(fmt.Sprintf(`{"waited_ms":%d}`, int(ms))), nil- case <-ctx.Done():- return mcp.NewToolResultError("wait cancelled"), nil+ if mode == "ms" {+ return sleepFor(ctx, strings.TrimSpace(value))}+ return callWaitEndpoint(ctx, c, r, map[string]any{field: value})}}-func handleWaitForSelector(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- sel, err := r.RequireString("selector")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return callWaitEndpoint(ctx, c, r, map[string]any{"selector": sel})- }-}--func handleWaitForText(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- text, err := r.RequireString("text")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return callWaitEndpoint(ctx, c, r, map[string]any{"text": text})+func sleepFor(ctx context.Context, value string) (*mcp.CallToolResult, error) {+ ms, err := strconv.ParseFloat(value, 64)+ if err != nil {+ return mcp.NewToolResultError(fmt.Sprintf("wait for=\"ms\" needs a numeric 'value' in milliseconds, got %q", value)), nil}-}--func handleWaitForURL(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- u, err := r.RequireString("url")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return callWaitEndpoint(ctx, c, r, map[string]any{"url": u})+ if ms < 0 {+ ms = 0}-}--func handleWaitForLoad(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- load, err := r.RequireString("load")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return callWaitEndpoint(ctx, c, r, map[string]any{"load": load})+ if ms > maxWaitMS {+ ms = maxWaitMS}-}--func handleWaitForFunction(c *Client) func(context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error) {- return func(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, error) {- fn, err := r.RequireString("fn")- if err != nil {- return mcp.NewToolResultError(err.Error()), nil- }- return callWaitEndpoint(ctx, c, r, map[string]any{"fn": fn})+ select {+ case <-time.After(time.Duration(ms) * time.Millisecond):+ return mcp.NewToolResultText(fmt.Sprintf(`{"waited_ms":%d}`, int(ms))), nil+ case <-ctx.Done():+ return mcp.NewToolResultError("wait cancelled"), nil}}diff --git a/internal/mcp/handlers_wait_test.go b/internal/mcp/handlers_wait_test.goindex 760c0431..c078a44a 100644--- a/internal/mcp/handlers_wait_test.go+++ b/internal/mcp/handlers_wait_test.go@@ -14,7 +14,8 @@ func TestHandleWait(t *testing.T) {defer srv.Close()r := callTool(t, "pinchtab_wait", map[string]any{- "ms": float64(50),+ "for": "ms",+ "value": "50",}, srv)text := resultText(t, r)@@ -32,7 +33,7 @@ func TestHandleWaitClampsMax(t *testing.T) {h := handlers["pinchtab_wait"]req := mcp.CallToolRequest{}req.Params.Name = "pinchtab_wait"- req.Params.Arguments = map[string]any{"ms": float64(999999)}+ req.Params.Arguments = map[string]any{"for": "ms", "value": "999999"}r, err := h(ctx, req)if err != nil {t.Fatal(err)@@ -48,9 +49,10 @@ func TestHandleWaitForSelector(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_wait_for_selector", map[string]any{- "selector": ".loaded",- "timeout": float64(5000),+ r := callTool(t, "pinchtab_wait", map[string]any{+ "for": "selector",+ "value": ".loaded",+ "timeout": float64(5000),}, srv)text := resultText(t, r)@@ -65,9 +67,10 @@ func TestHandleWaitForSelectorForwardsBrowser(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_wait_for_selector", map[string]any{- "selector": ".loaded",- "browser": "cloak",+ r := callTool(t, "pinchtab_wait", map[string]any{+ "for": "selector",+ "value": ".loaded",+ "browser": "cloak",}, srv)text := resultText(t, r)@@ -80,17 +83,77 @@ func TestHandleWaitForSelectorMissing(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_wait_for_selector", map[string]any{}, srv)+ r := callTool(t, "pinchtab_wait", map[string]any{"for": "selector"}, srv)if !r.IsError {t.Error("expected error for missing selector")}}+func TestHandleWaitRefusesAnUnknownCondition(t *testing.T) {+ srv := mockPinchTab()+ defer srv.Close()++ r := callTool(t, "pinchtab_wait", map[string]any{"for": "element", "value": ".loaded"}, srv)+ if !r.IsError {+ t.Fatal("expected an error for an unknown 'for' value")+ }+ text := resultText(t, r)+ for _, want := range []string{"element", "selector", "function"} {+ if !strings.Contains(text, want) {+ t.Errorf("refusal %q does not name %q, so the caller cannot correct it", text, want)+ }+ }+}++// The five browser-backed conditions are one operation on the wire: each has to+// reach POST /wait under the field name that endpoint decodes, or the server+// answers "one of selector, text, url, load, fn, or ms is required".+func TestEveryWaitConditionReachesItsWireField(t *testing.T) {+ for _, tc := range []struct{ condition, value, field string }{+ {"selector", ".loaded", "selector"},+ {"text", "Success", "text"},+ {"url", "**/dashboard", "url"},+ {"load", "network-idle", "load"},+ {"function", "window.ready", "fn"},+ } {+ t.Run(tc.condition, func(t *testing.T) {+ srv := mockPinchTab()+ defer srv.Close()++ r := callTool(t, "pinchtab_wait", map[string]any{"for": tc.condition, "value": tc.value}, srv)+ if r.IsError {+ t.Fatalf("for=%q was rejected: %s", tc.condition, resultText(t, r))+ }+ body, _ := resultJSON(t, r)["body"].(map[string]any)+ if got, _ := body[tc.field].(string); got != tc.value {+ t.Errorf("for=%q sent %s=%q, want the value under %q — the endpoint reads that field only (body=%v)",+ tc.condition, tc.field, got, tc.field, body)+ }+ })+ }+}++func TestHandleWaitForSelectorForwardsState(t *testing.T) {+ srv := mockPinchTab()+ defer srv.Close()++ r := callTool(t, "pinchtab_wait", map[string]any{+ "for": "selector",+ "value": ".gone",+ "state": "hidden",+ }, srv)++ body, _ := resultJSON(t, r)["body"].(map[string]any)+ if got, _ := body["state"].(string); got != "hidden" {+ t.Errorf("state reached the wait body as %q, want hidden (body=%v)", got, body)+ }+}+func TestHandleWaitNegativeMs(t *testing.T) {srv := mockPinchTab()defer srv.Close()- r := callTool(t, "pinchtab_wait", map[string]any{"ms": float64(-100)}, srv)+ r := callTool(t, "pinchtab_wait", map[string]any{"for": "ms", "value": "-100"}, srv)text := resultText(t, r)if !strings.Contains(text, "waited_ms") {t.Errorf("expected waited_ms, got %s", text)diff --git a/internal/mcp/routing_test.go b/internal/mcp/routing_test.goindex 657f2558..a3707afc 100644--- a/internal/mcp/routing_test.go+++ b/internal/mcp/routing_test.go@@ -14,34 +14,26 @@ import (// `browser` fails TestEveryBrowserToolForwardsInTheQuery until it is added here,// which is what stops the next tool from picking the body form.var browserToolArgs = map[string]map[string]any{- "pinchtab_navigate": {"url": "https://example.com"},- "pinchtab_back": {},- "pinchtab_forward": {},- "pinchtab_reload": {},- "pinchtab_snapshot": {},- "pinchtab_frame": {"target": "#payment"},- "pinchtab_screenshot": {},- "pinchtab_capture": {},- "pinchtab_get_text": {},- "pinchtab_click": {"selector": "#go"},- "pinchtab_type": {"selector": "#q", "text": "hello"},- "pinchtab_press": {"key": "Enter"},- "pinchtab_hover": {"selector": "#go"},- "pinchtab_focus": {"selector": "#q"},- "pinchtab_select": {"selector": "#s", "value": "one"},- "pinchtab_scroll": {},- "pinchtab_scroll_into_view": {"selector": "#go"},- "pinchtab_fill": {"selector": "#q", "value": "hello"},- "pinchtab_keyboard_type": {"text": "hello"},- "pinchtab_keyboard_inserttext": {"text": "hello"},- "pinchtab_keydown": {"key": "a"},- "pinchtab_keyup": {"key": "a"},- "pinchtab_wait_for_selector": {"selector": ".loaded"},- "pinchtab_wait_for_text": {"text": "done"},- "pinchtab_wait_for_url": {"url": "https://example.com/done"},- "pinchtab_wait_for_load": {"load": "content-loaded"},- "pinchtab_wait_for_function": {"fn": "1"},- "pinchtab_scrape": {"url": "https://example.com"},+ "pinchtab_navigate": {"url": "https://example.com"},+ "pinchtab_back": {},+ "pinchtab_forward": {},+ "pinchtab_reload": {},+ "pinchtab_snapshot": {},+ "pinchtab_frame": {"target": "#payment"},+ "pinchtab_screenshot": {},+ "pinchtab_capture": {},+ "pinchtab_get_text": {},+ "pinchtab_click": {"selector": "#go"},+ "pinchtab_type": {"selector": "#q", "text": "hello"},+ "pinchtab_hover": {"selector": "#go"},+ "pinchtab_focus": {"selector": "#q"},+ "pinchtab_select": {"selector": "#s", "value": "one"},+ "pinchtab_scroll": {},+ "pinchtab_scroll_into_view": {"selector": "#go"},+ "pinchtab_fill": {"selector": "#q", "value": "hello"},+ "pinchtab_key": {"action": "press", "key": "Enter"},+ "pinchtab_wait": {"for": "selector", "value": ".loaded"},+ "pinchtab_scrape": {"url": "https://example.com"},}// bodyBrowserEndpoints are the endpoints whose own handler decodes a `browser`diff --git a/internal/mcp/server_test.go b/internal/mcp/server_test.goindex b44566e6..d54c0097 100644--- a/internal/mcp/server_test.go+++ b/internal/mcp/server_test.go@@ -18,8 +18,8 @@ func TestNewServerRegistersAllTools(t *testing.T) {// The server should have registered all tools.// We verify by checking that NewServer doesn't panic — the panic// in NewServer fires if any tool lacks a handler.- if len(tools) != 47 {- t.Errorf("expected 47 tools, got %d — if a tool was added or removed, update this count and the totals in docs/mcp.md", len(tools))+ if len(tools) != 36 {+ t.Errorf("expected 36 tools, got %d — if a tool was added or removed, update this count and the totals in docs/mcp.md", len(tools))}}diff --git a/internal/mcp/testdata/preamble_budget.json b/internal/mcp/testdata/preamble_budget.jsonindex 787aaf83..2611924e 100644--- a/internal/mcp/testdata/preamble_budget.json+++ b/internal/mcp/testdata/preamble_budget.json@@ -1,17 +1,17 @@[{"surface": "mcp:allTools",- "minBytes": 20044,- "maxBytes": 40088,+ "minBytes": 18092,+ "maxBytes": 36185,"takenOn": "2026-08-22",- "commit": "552ea6f9"+ "commit": "PENDING"},{"surface": "skills/pinchtab-mcp/SKILL.md",- "minBytes": 6634,- "maxBytes": 13269,+ "minBytes": 6789,+ "maxBytes": 13579,"takenOn": "2026-08-22",- "commit": "9cb14d50"+ "commit": "PENDING"},{"surface": "skills/pinchtab/SKILL.md",diff --git a/internal/mcp/tools.go b/internal/mcp/tools.goindex 1e951467..9263d5eb 100644--- a/internal/mcp/tools.go+++ b/internal/mcp/tools.go@@ -126,13 +126,6 @@ func allTools() []mcp.Tool {tabIDParam(),browserParam(),),- mcp.NewTool("pinchtab_press",- mcp.WithDescription("Press a keyboard key (Enter, Tab, Escape, etc.)"),- mcp.WithString("key", mcp.Required(), mcp.Description("Key to press (e.g., 'Enter', 'Tab', 'Escape')")),- nodeIDParam(),- tabIDParam(),- browserParam(),- ),mcp.NewTool("pinchtab_hover",mcp.WithDescription("Hover over an element"),selectorParam(),@@ -206,27 +199,12 @@ func allTools() []mcp.Tool {browserParam(),),- mcp.NewTool("pinchtab_keyboard_type",- mcp.WithDescription("Type text at the currently focused element via keystroke events (keyDown + keyUp per character)"),- textToTypeParam(),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_keyboard_inserttext",- mcp.WithDescription("Insert text at the currently focused element without key events (paste-like)"),- mcp.WithString("text", mcp.Required(), mcp.Description("Text to insert")),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_keydown",- mcp.WithDescription("Hold a key down (e.g. modifier keys like Control, Shift, Alt)"),- mcp.WithString("key", mcp.Required(), mcp.Description("Key to hold down (e.g. 'Control', 'Shift', 'Alt', 'a')")),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_keyup",- mcp.WithDescription("Release a held key"),- mcp.WithString("key", mcp.Required(), mcp.Description("Key to release (e.g. 'Control', 'Shift', 'Alt', 'a')")),+ mcp.NewTool("pinchtab_key",+ mcp.WithDescription("Send keyboard input; 'action' picks which. action='press': press a keyboard key (Enter, Tab, Escape, etc.) — needs 'key'. action='down': hold a key down, e.g. modifier keys like Control, Shift, Alt — needs 'key'. action='up': release a held key — needs 'key'. action='type': type text at the currently focused element via keystroke events (keyDown + keyUp per character) — needs 'text'. action='insert': insert text at the currently focused element without key events (paste-like) — needs 'text'. 'nodeId' is honoured by action='press', which focuses that node before the key is sent."),+ mcp.WithString("action", mcp.Required(), mcp.Enum("press", "down", "up", "type", "insert"), mcp.Description("Keyboard action to send")),+ mcp.WithString("key", mcp.Description("Key for action press/down/up (e.g. 'Enter', 'Tab', 'Escape', 'Control', 'Shift', 'Alt', 'a')")),+ mcp.WithString("text", mcp.Description("Text for action type/insert")),+ nodeIDParam(),tabIDParam(),browserParam(),),@@ -282,42 +260,11 @@ func allTools() []mcp.Tool {),mcp.NewTool("pinchtab_wait",- mcp.WithDescription("Wait for a specified number of milliseconds"),- mcp.WithNumber("ms", mcp.Required(), mcp.Description("Milliseconds to wait (max 30000)")),- ),- mcp.NewTool("pinchtab_wait_for_selector",- mcp.WithDescription("Wait for an element matching a selector to appear or disappear on the page"),- mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector to wait for (CSS, XPath, text, or ref)")),- timeoutParam(),- mcp.WithString("state", mcp.Description("Element state to wait for: 'visible' (default) or 'hidden'")),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_wait_for_text",- mcp.WithDescription("Wait for specific text to appear on the page"),- mcp.WithString("text", mcp.Required(), mcp.Description("Text to wait for")),- timeoutParam(),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_wait_for_url",- mcp.WithDescription("Wait for the page URL to match a glob pattern"),- mcp.WithString("url", mcp.Required(), mcp.Description("URL glob pattern to match (e.g. '**/dashboard')")),- timeoutParam(),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_wait_for_load",- mcp.WithDescription("Wait for a page load state"),- mcp.WithString("load", mcp.Required(), mcp.Description("Load state: 'ready-state' (readyState=complete), 'content-loaded' (readyState in {interactive, complete}), or 'network-idle' (0 in-flight requests for 500ms)")),- timeoutParam(),- tabIDParam(),- browserParam(),- ),- mcp.NewTool("pinchtab_wait_for_function",- mcp.WithDescription("Wait for a JavaScript expression to return a truthy value"),- expressionParam("fn"),+ mcp.WithDescription("Wait for one condition; 'for' picks which and 'value' carries it. for='ms': wait a specified number of milliseconds (max 30000; needs no browser). for='selector': wait for an element matching a unified selector (CSS, XPath, text, or ref) to appear or disappear on the page — see 'state'. for='text': wait for specific text to appear on the page. for='url': wait for the page URL to match a glob pattern (e.g. '**/dashboard'). for='load': wait for a page load state — 'ready-state' (readyState=complete), 'content-loaded' (readyState in {interactive, complete}), or 'network-idle' (0 in-flight requests for 500ms). for='function': wait for a JavaScript expression to return a truthy value."),+ mcp.WithString("for", mcp.Required(), mcp.Enum("ms", "selector", "text", "url", "load", "function"), mcp.Description("What to wait for")),+ mcp.WithString("value", mcp.Required(), mcp.Description("What to wait for, read as 'for' says: a millisecond count, a selector, page text, a URL glob pattern, a load state, or a JavaScript expression")),timeoutParam(),+ mcp.WithString("state", mcp.Description("Element state to wait for with for='selector': 'visible' (default) or 'hidden'")),tabIDParam(),browserParam(),),@@ -359,21 +306,15 @@ func allTools() []mcp.Tool {mcp.WithString("pattern", mcp.Description("Pattern to remove (omit to clear all rules)")),),- mcp.NewTool("pinchtab_record_start",- mcp.WithDescription("Start recording browser activity. Requires security.allowScreencast. GIF works without ffmpeg; WebM/MP4 need ffmpeg."),- mcp.WithString("file", mcp.Required(), mcp.Description("Output file path (.gif, .webm, or .mp4)")),+ mcp.NewTool("pinchtab_record",+ mcp.WithDescription("Record browser activity; 'action' picks which. action='start': start recording — requires security.allowScreencast, and GIF works without ffmpeg while WebM/MP4 need ffmpeg. action='stop': stop recording and save the encoded file; encoding may take a while for long recordings. action='status': check active recording status (format, fps, duration, frame count)."),+ mcp.WithString("action", mcp.Required(), mcp.Enum("start", "stop", "status"), mcp.Description("Recording action to take")),+ mcp.WithString("file", mcp.Description("Output file path for action start/stop (.gif, .webm, or .mp4); the format is read from the extension, and stop must be given the same path start was")),mcp.WithNumber("fps", mcp.Description("Frames per second 1-30 (default: 5)")),mcp.WithNumber("quality", mcp.Description("JPEG capture quality 1-100 (default: 80)")),mcp.WithNumber("scale", mcp.Description("Resolution scale 0-1.0 (default: 1.0)")),tabIDParam(),),- mcp.NewTool("pinchtab_record_stop",- mcp.WithDescription("Stop recording and save the encoded file. Encoding may take a while for long recordings."),- mcp.WithString("file", mcp.Required(), mcp.Description("Output file path (must match the format from record_start)")),- ),- mcp.NewTool("pinchtab_record_status",- mcp.WithDescription("Check active recording status (format, fps, duration, frame count)"),- ),mcp.NewTool("pinchtab_dialog",mcp.WithDescription("Handle a JavaScript dialog (alert, confirm, prompt). Accept or dismiss the currently open dialog."),diff --git a/internal/mcp/tools_params_test.go b/internal/mcp/tools_params_test.goindex 99ceaee0..faaf1fc1 100644--- a/internal/mcp/tools_params_test.go+++ b/internal/mcp/tools_params_test.go@@ -237,7 +237,7 @@ func TestSharedParamsHaveOneWordingPerConcept(t *testing.T) {want int}{{"ref", 1},- {"selector", 8},+ {"selector", 7},{"browser", 2},{"tabId", 3},} {diff --git a/skills/pinchtab-mcp/SKILL.md b/skills/pinchtab-mcp/SKILL.mdindex 5bd1d622..f50c07fb 100644--- a/skills/pinchtab-mcp/SKILL.md+++ b/skills/pinchtab-mcp/SKILL.md@@ -169,10 +169,10 @@ Use when the site needs real keystrokes (e.g., some autocomplete widgets).### Press key```-pinchtab_press(key="Enter")+pinchtab_key(action="press", key="Enter")```-Common keys: `Enter`, `Tab`, `Escape`, `ArrowDown`, `ArrowUp`, `Backspace`.+Common keys: `Enter`, `Tab`, `Escape`, `ArrowDown`, `ArrowUp`, `Backspace`. The same tool holds and releases a key with `action="down"` / `action="up"`, and types at the focused element with `action="type"` (key events) or `action="insert"` (paste-like).### Select dropdown@@ -293,11 +293,12 @@ pinchtab_close_tab(tabId="...") # Close a specific tabUse for async content (spinners, XHR, lazy-loaded elements):```-pinchtab_wait(ms=2000) # Fixed delay (last resort)-pinchtab_wait_for_selector(selector="e5") # Wait for element-pinchtab_wait_for_text(text="Success") # Wait for text-pinchtab_wait_for_url(url="**/dashboard") # Wait for URL change-pinchtab_wait_for_load(load="network-idle") # Wait for page load+pinchtab_wait(for="ms", value="2000") # Fixed delay (last resort)+pinchtab_wait(for="selector", value="e5") # Wait for element+pinchtab_wait(for="text", value="Success") # Wait for text+pinchtab_wait(for="url", value="**/dashboard") # Wait for URL change+pinchtab_wait(for="load", value="network-idle") # Wait for page load+pinchtab_wait(for="function", value="window.ready") # Wait for a truthy expression```Timeout: 10s default, 30s max. Prefer selector/text waits over fixed delays.@@ -359,5 +360,5 @@ For these, use the pinchtab CLI or HTTP API directly.| `ref not found` | Stale element ref | Re-call `pinchtab_snapshot()` || `evaluate not allowed` | `security.allowEvaluate` is false | Use `pinchtab_find` instead || `invalid URL` | Missing scheme | Include `http://` or `https://` |-| Element not found | Page not loaded | Use `pinchtab_wait_for_selector` |+| Element not found | Page not loaded | Use `pinchtab_wait(for="selector", value=…)` || Action seems ignored | Page changed mid-action | Re-snapshot, use fresh refs |diff --git a/skills/pinchtab/references/mcp.md b/skills/pinchtab/references/mcp.mdindex 6da84899..a19b590a 100644--- a/skills/pinchtab/references/mcp.md+++ b/skills/pinchtab/references/mcp.md@@ -63,7 +63,6 @@ All tool names are prefixed with `pinchtab_`.| `pinchtab_click` | Click element by selector. Required: `selector` or legacy `ref`. Optional: `waitNav`, `mode` (`dom` or `dispatch` as a broad low-level escape hatch), `tabId`. `mode` and `humanize` are mutually exclusive. || `pinchtab_type` | Type text keystroke-by-keystroke. Required: `selector` or legacy `ref`, plus `text`. Optional: `tabId`. || `pinchtab_fill` | Fill input via JS dispatch. Required: `selector` or legacy `ref`, plus `value` — send `value=""` to clear the field (omitting it is refused). Optional: `tabId`. |-| `pinchtab_press` | Press a named key (`Enter`, `Tab`, `Escape`, etc.). Required: `key`. Optional: `tabId`. || `pinchtab_hover` | Hover over element. Required: `selector` or legacy `ref`. Optional: `tabId`. || `pinchtab_focus` | Focus an element. Required: `selector` or legacy `ref`. Optional: `tabId`. || `pinchtab_select` | Select dropdown option. Required: `selector` or legacy `ref`, plus `value`. Optional: `tabId`. |@@ -72,10 +71,7 @@ All tool names are prefixed with `pinchtab_`.### Keyboard| Tool | Description ||------|-------------|-| `pinchtab_keyboard_type` | Type text into the focused element with keystroke events. Required: `text`. Optional: `tabId`. |-| `pinchtab_keyboard_inserttext` | Insert text into the focused element without key events. Required: `text`. Optional: `tabId`. |-| `pinchtab_keydown` | Hold a key down. Required: `key`. Optional: `tabId`. |-| `pinchtab_keyup` | Release a key. Required: `key`. Optional: `tabId`. |+| `pinchtab_key` | Keyboard input. Required: `action` — `press` a named key (`Enter`, `Tab`, `Escape`, etc.), `down` to hold one, `up` to release one, `type` to type into the focused element with keystroke events, or `insert` to insert text without key events. `press`/`down`/`up` require `key`; `type`/`insert` require `text`. Optional: `nodeId`, `tabId`. |### Content| Tool | Description |@@ -97,12 +93,7 @@ All tool names are prefixed with `pinchtab_`.### Utility| Tool | Description ||------|-------------|-| `pinchtab_wait` | Wait N milliseconds. Required: `ms` (max 30000). |-| `pinchtab_wait_for_selector` | Wait for selector to appear or disappear. Required: `selector`. Optional: `timeout`, `state`, `tabId`. |-| `pinchtab_wait_for_text` | Wait for text to appear. Required: `text`. Optional: `timeout`, `tabId`. |-| `pinchtab_wait_for_url` | Wait for a URL glob match. Required: `url`. Optional: `timeout`, `tabId`. |-| `pinchtab_wait_for_load` | Wait for a load state. Required: `load`. Optional: `timeout`, `tabId`. |-| `pinchtab_wait_for_function` | Wait for a JavaScript expression to become truthy. Required: `fn`. Optional: `timeout`, `tabId`. |+| `pinchtab_wait` | Wait for one condition. Required: `for` — `ms` (wait N milliseconds, max 30000), `selector` (appear or disappear), `text` (appear), `url` (glob match), `load` (`ready-state`, `content-loaded` or `network-idle`), or `function` (JavaScript expression becomes truthy) — plus `value` carrying it. Optional: `timeout`, `state` (with `for=selector`), `tabId`. |### Network| Tool | Description |