File size: 8,470 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# MCP Tool Reference

Complete parameter reference for all 21 tools exposed by the PinchTab MCP server.

All tool names are prefixed with `pinchtab_`. The server communicates over **stdio JSON-RPC 2.0** (MCP spec 2025-11-25).

---

## Navigation

### pinchtab_navigate

Navigate the browser to a URL.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `url` | string | **Yes** | Full URL including scheme (`http://` or `https://`) |
| `tabId` | string | No | Target tab. Uses current tab if omitted. |

**Returns:** JSON object with `tabId`, `url`, and `title`.

```json
{ "tabId": "abc123", "url": "https://example.com", "title": "Example Domain" }
```

---

### pinchtab_snapshot

Get an accessibility tree snapshot of the current page. This is the primary way agents understand page structure and discover interactive element refs.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Target tab |
| `interactive` | boolean | No | Only return interactive elements (buttons, links, inputs) |
| `compact` | boolean | No | Compact format — uses fewer tokens |
| `diff` | boolean | No | Only changes since the last snapshot |
| `selector` | string | No | CSS selector to scope the snapshot to a subtree |

**Returns:** Accessibility tree as text. Element refs (e.g. `e5`, `e12`) are used in interaction tool calls.

---

### pinchtab_screenshot

Capture a screenshot of the current page.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Target tab |
| `quality` | number | No | JPEG quality 0–100 (default PNG) |

**Returns:** Base64-encoded image string.

---

### pinchtab_get_text

Extract readable text content from the page, suitable for summarisation and Q&A.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Target tab |
| `raw` | boolean | No | Return raw text without formatting |

**Returns:** Plain text string.

---

## Interaction

All interaction tools that target page elements require a `ref` — the element identifier from a `pinchtab_snapshot` response (e.g. `e5`).

### pinchtab_click

Click an element by its accessibility ref.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | Element ref from snapshot (e.g. `e5`) |
| `tabId` | string | No | Target tab |

---

### pinchtab_type

Type text into an input element, simulating keystrokes.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | Element ref |
| `text` | string | **Yes** | Text to type |
| `tabId` | string | No | Target tab |

---

### pinchtab_press

Press a named keyboard key.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `key` | string | **Yes** | Key name: `Enter`, `Tab`, `Escape`, `ArrowDown`, `Backspace`, etc. |
| `tabId` | string | No | Target tab |

---

### pinchtab_hover

Hover the mouse over an element (triggers `:hover` styles and tooltips).

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | Element ref |
| `tabId` | string | No | Target tab |

---

### pinchtab_focus

Give keyboard focus to an element.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | Element ref |
| `tabId` | string | No | Target tab |

---

### pinchtab_select

Select an option from a `<select>` dropdown.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | `<select>` element ref |
| `value` | string | **Yes** | Option value to select |
| `tabId` | string | No | Target tab |

---

### pinchtab_scroll

Scroll the page or a specific element.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | No | Element ref. Omit to scroll the whole page. |
| `pixels` | number | No | Pixels to scroll. Positive = down/right, negative = up/left. Default 300. |
| `tabId` | string | No | Target tab |

---

### pinchtab_fill

Fill an input field using JavaScript event dispatch. Works with React, Vue, Angular, and other frameworks that intercept native input events.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ref` | string | **Yes** | Element ref or CSS selector |
| `value` | string | **Yes** | Value to set |
| `tabId` | string | No | Target tab |

> **Tip:** Use `pinchtab_fill` instead of `pinchtab_type` when the page uses a frontend framework that does not react to raw keystroke simulation.

---

## Content

### pinchtab_eval

Execute a JavaScript expression in the browser context and return the result.

> **Security note:** Requires `security.allowEvaluate: true` in the PinchTab config. Returns HTTP 403 by default.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `expression` | string | **Yes** | JavaScript expression to evaluate |
| `tabId` | string | No | Target tab |

**Returns:** JSON-serialised result of the expression.

```javascript
// Example expressions
"document.title"
"document.querySelectorAll('a').length"
"window.location.href"
```

---

### pinchtab_pdf

Export the current page as a PDF document.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Target tab |
| `landscape` | boolean | No | Landscape orientation (default portrait) |
| `scale` | number | No | Print scale 0.1–2.0 (default 1.0) |
| `pageRanges` | string | No | Pages to include, e.g. `"1-3,5"` |

**Returns:** Base64-encoded PDF bytes.

---

### pinchtab_find

Find elements by text content or CSS selector using semantic matching.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `query` | string | **Yes** | Text content or CSS selector |
| `tabId` | string | No | Target tab |

**Returns:** List of matching elements with their refs, text, and positions.

---

## Tab Management

### pinchtab_list_tabs

List all open browser tabs.

No parameters.

**Returns:** Array of tab objects with `tabId`, `url`, and `title`.

---

### pinchtab_close_tab

Close a browser tab.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Tab to close. Closes the current tab if omitted. |

---

### pinchtab_health

Check whether the PinchTab server is reachable and healthy.

No parameters.

**Returns:** `{"status":"ok"}` on success.

---

### pinchtab_cookies

Get cookies for the current page.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tabId` | string | No | Target tab |

**Returns:** Array of cookie objects (name, value, domain, path, etc.).

---

## Utility

### pinchtab_wait

Wait for a fixed duration. Use sparingly — prefer `pinchtab_wait_for_selector` when possible.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `ms` | number | **Yes** | Milliseconds to wait. Maximum 30000. |

---

### pinchtab_wait_for_selector

Wait for a CSS selector to appear on the page. Polls every 250 ms.

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `selector` | string | **Yes** | CSS selector to wait for |
| `timeout` | number | No | Timeout in milliseconds. Default 10000, maximum 30000. |
| `tabId` | string | No | Target tab |

**Returns:** `{"present": true}` when the selector is found, `{"present": false}` on timeout.

---

## Error Responses

All tools return errors as MCP tool errors (not Go-level errors). Common error patterns:

| Situation | Response |
|-----------|----------|
| PinchTab not running | Connection refused error |
| Element ref not found | `HTTP 500: ref not found` |
| `pinchtab_eval` without security flag | `HTTP 403: evaluate not allowed` |
| Invalid URL in navigate | `invalid URL: must start with http:// or https://` |
| Required parameter missing | Parameter validation error from MCP SDK |

---

## Related Pages

- [MCP User Guide](../mcp.md)
- [MCP Architecture](../architecture/mcp.md)
- [Security Guide](../guides/security.md)