mcp-web-inspector 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1017 -0
- package/dist/evals/evals.d.ts +5 -0
- package/dist/evals/evals.js +41 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +62 -0
- package/dist/requestHandler.d.ts +3 -0
- package/dist/requestHandler.js +53 -0
- package/dist/toolHandler.d.ts +91 -0
- package/dist/toolHandler.js +725 -0
- package/dist/tools/api/base.d.ts +33 -0
- package/dist/tools/api/base.js +49 -0
- package/dist/tools/api/index.d.ts +2 -0
- package/dist/tools/api/index.js +3 -0
- package/dist/tools/api/requests.d.ts +47 -0
- package/dist/tools/api/requests.js +168 -0
- package/dist/tools/browser/base.d.ts +51 -0
- package/dist/tools/browser/base.js +111 -0
- package/dist/tools/browser/cleanSession.d.ts +10 -0
- package/dist/tools/browser/cleanSession.js +42 -0
- package/dist/tools/browser/comparePositions.d.ts +11 -0
- package/dist/tools/browser/comparePositions.js +149 -0
- package/dist/tools/browser/computedStyles.d.ts +11 -0
- package/dist/tools/browser/computedStyles.js +128 -0
- package/dist/tools/browser/console.d.ts +37 -0
- package/dist/tools/browser/console.js +106 -0
- package/dist/tools/browser/elementExists.d.ts +9 -0
- package/dist/tools/browser/elementExists.js +57 -0
- package/dist/tools/browser/elementInspection.d.ts +21 -0
- package/dist/tools/browser/elementInspection.js +151 -0
- package/dist/tools/browser/elementPosition.d.ts +11 -0
- package/dist/tools/browser/elementPosition.js +107 -0
- package/dist/tools/browser/elementVisibility.d.ts +12 -0
- package/dist/tools/browser/elementVisibility.js +224 -0
- package/dist/tools/browser/findByText.d.ts +13 -0
- package/dist/tools/browser/findByText.js +207 -0
- package/dist/tools/browser/getRequestDetails.d.ts +9 -0
- package/dist/tools/browser/getRequestDetails.js +137 -0
- package/dist/tools/browser/getTestIds.d.ts +12 -0
- package/dist/tools/browser/getTestIds.js +148 -0
- package/dist/tools/browser/index.d.ts +7 -0
- package/dist/tools/browser/index.js +7 -0
- package/dist/tools/browser/inspectDom.d.ts +12 -0
- package/dist/tools/browser/inspectDom.js +447 -0
- package/dist/tools/browser/interaction.d.ts +104 -0
- package/dist/tools/browser/interaction.js +259 -0
- package/dist/tools/browser/listNetworkRequests.d.ts +10 -0
- package/dist/tools/browser/listNetworkRequests.js +74 -0
- package/dist/tools/browser/measureElement.d.ts +9 -0
- package/dist/tools/browser/measureElement.js +139 -0
- package/dist/tools/browser/navigation.d.ts +38 -0
- package/dist/tools/browser/navigation.js +109 -0
- package/dist/tools/browser/output.d.ts +11 -0
- package/dist/tools/browser/output.js +29 -0
- package/dist/tools/browser/querySelectorAll.d.ts +12 -0
- package/dist/tools/browser/querySelectorAll.js +201 -0
- package/dist/tools/browser/response.d.ts +29 -0
- package/dist/tools/browser/response.js +67 -0
- package/dist/tools/browser/screenshot.d.ts +16 -0
- package/dist/tools/browser/screenshot.js +70 -0
- package/dist/tools/browser/useragent.d.ts +15 -0
- package/dist/tools/browser/useragent.js +32 -0
- package/dist/tools/browser/visiblePage.d.ts +20 -0
- package/dist/tools/browser/visiblePage.js +170 -0
- package/dist/tools/browser/waitForElement.d.ts +10 -0
- package/dist/tools/browser/waitForElement.js +38 -0
- package/dist/tools/browser/waitForNetworkIdle.d.ts +8 -0
- package/dist/tools/browser/waitForNetworkIdle.js +32 -0
- package/dist/tools/codegen/generator.d.ts +21 -0
- package/dist/tools/codegen/generator.js +158 -0
- package/dist/tools/codegen/index.d.ts +11 -0
- package/dist/tools/codegen/index.js +187 -0
- package/dist/tools/codegen/recorder.d.ts +14 -0
- package/dist/tools/codegen/recorder.js +62 -0
- package/dist/tools/codegen/types.d.ts +28 -0
- package/dist/tools/codegen/types.js +1 -0
- package/dist/tools/common/types.d.ts +17 -0
- package/dist/tools/common/types.js +20 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools.d.ts +557 -0
- package/dist/tools.js +554 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/package.json +60 -0
package/dist/tools.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
export function createToolDefinitions(sessionConfig) {
|
|
2
|
+
// Build dynamic navigate description based on session config
|
|
3
|
+
const sessionEnabled = sessionConfig?.saveSession ?? true;
|
|
4
|
+
const userDataDir = sessionConfig?.userDataDir || './.mcp-web-inspector/user-data';
|
|
5
|
+
const screenshotsDir = sessionConfig?.screenshotsDir || './.mcp-web-inspector/screenshots';
|
|
6
|
+
const navigateDescription = sessionEnabled
|
|
7
|
+
? `Navigate to a URL. Browser sessions (cookies, localStorage, sessionStorage) are automatically saved in ${userDataDir} directory and persist across restarts. To clear saved sessions, delete the directory.`
|
|
8
|
+
: "Navigate to a URL. Browser starts fresh each time with no persistent session state (started with --no-save-session flag).";
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "navigate",
|
|
12
|
+
description: navigateDescription,
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
url: { type: "string", description: "URL to navigate to the website specified" },
|
|
17
|
+
browserType: { type: "string", description: "Browser type to use (chromium, firefox, webkit). Defaults to chromium", enum: ["chromium", "firefox", "webkit"] },
|
|
18
|
+
device: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Mobile device preset to emulate. Uses Playwright's built-in device configurations for viewport, user agent, and device scale factor. When specified, overrides width/height parameters.",
|
|
21
|
+
enum: ["iphone-se", "iphone-14", "iphone-14-pro", "pixel-5", "ipad", "samsung-s21"]
|
|
22
|
+
},
|
|
23
|
+
width: { type: "number", description: "Viewport width in pixels (default: 1280). Ignored if device is specified." },
|
|
24
|
+
height: { type: "number", description: "Viewport height in pixels (default: 720). Ignored if device is specified." },
|
|
25
|
+
timeout: { type: "number", description: "Navigation timeout in milliseconds" },
|
|
26
|
+
waitUntil: { type: "string", description: "Navigation wait condition" },
|
|
27
|
+
headless: { type: "boolean", description: "Run browser in headless mode (default: false)" }
|
|
28
|
+
},
|
|
29
|
+
required: ["url"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "screenshot",
|
|
34
|
+
description: `Take a screenshot of the current page or a specific element. Screenshots are saved to ${screenshotsDir} by default. Example: { name: "login-page", fullPage: true } or { name: "submit-btn", selector: "testid:submit" }`,
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
name: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Name for the screenshot file (without extension). Example: 'login-page' or 'error-state'"
|
|
41
|
+
},
|
|
42
|
+
selector: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "CSS selector or testid shorthand for element to screenshot. Example: '#submit-button' or 'testid:login-form'. Omit to capture full viewport."
|
|
45
|
+
},
|
|
46
|
+
fullPage: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Capture entire scrollable page instead of just viewport (default: false)"
|
|
49
|
+
},
|
|
50
|
+
downloadsDir: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: `Custom directory for saving screenshot (default: ${screenshotsDir}). Example: './my-screenshots'`
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: ["name"],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "click",
|
|
60
|
+
description: "Click an element on the page",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
selector: { type: "string", description: "CSS selector for the element to click" },
|
|
65
|
+
},
|
|
66
|
+
required: ["selector"],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "fill",
|
|
71
|
+
description: "fill out an input field",
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
selector: { type: "string", description: "CSS selector for input field" },
|
|
76
|
+
value: { type: "string", description: "Value to fill" },
|
|
77
|
+
},
|
|
78
|
+
required: ["selector", "value"],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "select",
|
|
83
|
+
description: "Select an element on the page with Select tag",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
selector: { type: "string", description: "CSS selector for element to select" },
|
|
88
|
+
value: { type: "string", description: "Value to select" },
|
|
89
|
+
},
|
|
90
|
+
required: ["selector", "value"],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "hover",
|
|
95
|
+
description: "Hover an element on the page",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
selector: { type: "string", description: "CSS selector for element to hover" },
|
|
100
|
+
},
|
|
101
|
+
required: ["selector"],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "upload_file",
|
|
106
|
+
description: "Upload a file to an input[type='file'] element on the page",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
selector: { type: "string", description: "CSS selector for the file input element" },
|
|
111
|
+
filePath: { type: "string", description: "Absolute path to the file to upload" }
|
|
112
|
+
},
|
|
113
|
+
required: ["selector", "filePath"],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "evaluate",
|
|
118
|
+
description: "Execute JavaScript in the browser console",
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: "object",
|
|
121
|
+
properties: {
|
|
122
|
+
script: { type: "string", description: "JavaScript code to execute" },
|
|
123
|
+
},
|
|
124
|
+
required: ["script"],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "get_console_logs",
|
|
129
|
+
description: "Retrieve console logs from the browser with filtering options",
|
|
130
|
+
inputSchema: {
|
|
131
|
+
type: "object",
|
|
132
|
+
properties: {
|
|
133
|
+
type: {
|
|
134
|
+
type: "string",
|
|
135
|
+
description: "Type of logs to retrieve (all, error, warning, log, info, debug, exception)",
|
|
136
|
+
enum: ["all", "error", "warning", "log", "info", "debug", "exception"]
|
|
137
|
+
},
|
|
138
|
+
search: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "Text to search for in logs (handles text with square brackets)"
|
|
141
|
+
},
|
|
142
|
+
limit: {
|
|
143
|
+
type: "number",
|
|
144
|
+
description: "Maximum number of logs to return"
|
|
145
|
+
},
|
|
146
|
+
since: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "Filter logs since a specific event: 'last-call' (since last get_console_logs call), 'last-navigation' (since last page navigation), or 'last-interaction' (since last user interaction like click, fill, etc.)",
|
|
149
|
+
enum: ["last-call", "last-navigation", "last-interaction"]
|
|
150
|
+
},
|
|
151
|
+
clear: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
description: "Whether to clear logs after retrieval (default: false)"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
required: [],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "close",
|
|
161
|
+
description: "Close the browser and release all resources",
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {},
|
|
165
|
+
required: [],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "get_text",
|
|
170
|
+
description: "Get the visible text content of the current page",
|
|
171
|
+
inputSchema: {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {},
|
|
174
|
+
required: [],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "get_html",
|
|
179
|
+
description: "Get the HTML content of the current page. By default, all <script> tags are removed from the output unless removeScripts is explicitly set to false.",
|
|
180
|
+
inputSchema: {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
selector: { type: "string", description: "CSS selector to limit the HTML to a specific container" },
|
|
184
|
+
removeScripts: { type: "boolean", description: "Remove all script tags from the HTML (default: true)" },
|
|
185
|
+
removeComments: { type: "boolean", description: "Remove all HTML comments (default: false)" },
|
|
186
|
+
removeStyles: { type: "boolean", description: "Remove all style tags from the HTML (default: false)" },
|
|
187
|
+
removeMeta: { type: "boolean", description: "Remove all meta tags from the HTML (default: false)" },
|
|
188
|
+
cleanHtml: { type: "boolean", description: "Perform comprehensive HTML cleaning (default: false)" },
|
|
189
|
+
minify: { type: "boolean", description: "Minify the HTML output (default: false)" },
|
|
190
|
+
maxLength: { type: "number", description: "Maximum number of characters to return (default: 20000)" }
|
|
191
|
+
},
|
|
192
|
+
required: [],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "go_back",
|
|
197
|
+
description: "Navigate back in browser history",
|
|
198
|
+
inputSchema: {
|
|
199
|
+
type: "object",
|
|
200
|
+
properties: {},
|
|
201
|
+
required: [],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "go_forward",
|
|
206
|
+
description: "Navigate forward in browser history",
|
|
207
|
+
inputSchema: {
|
|
208
|
+
type: "object",
|
|
209
|
+
properties: {},
|
|
210
|
+
required: [],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "drag",
|
|
215
|
+
description: "Drag an element to a target location",
|
|
216
|
+
inputSchema: {
|
|
217
|
+
type: "object",
|
|
218
|
+
properties: {
|
|
219
|
+
sourceSelector: { type: "string", description: "CSS selector for the element to drag" },
|
|
220
|
+
targetSelector: { type: "string", description: "CSS selector for the target location" }
|
|
221
|
+
},
|
|
222
|
+
required: ["sourceSelector", "targetSelector"],
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "press_key",
|
|
227
|
+
description: "Press a keyboard key",
|
|
228
|
+
inputSchema: {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
key: { type: "string", description: "Key to press (e.g. 'Enter', 'ArrowDown', 'a')" },
|
|
232
|
+
selector: { type: "string", description: "Optional CSS selector to focus before pressing key" }
|
|
233
|
+
},
|
|
234
|
+
required: ["key"],
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "check_visibility",
|
|
239
|
+
description: "Check if an element is visible to the user. CRITICAL for debugging click/interaction failures. Returns detailed visibility information including viewport intersection, clipping by overflow:hidden, and whether element needs scrolling. Supports testid shortcuts (e.g., 'testid:submit-button').",
|
|
240
|
+
inputSchema: {
|
|
241
|
+
type: "object",
|
|
242
|
+
properties: {
|
|
243
|
+
selector: {
|
|
244
|
+
type: "string",
|
|
245
|
+
description: "CSS selector, text selector, or testid shorthand (e.g., 'testid:login-button', '#submit', 'text=Click here')"
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
required: ["selector"],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "get_position",
|
|
253
|
+
description: "Get the position and size of an element. Returns x, y coordinates and width/height in pixels. Useful for finding where to click or checking element layout. Supports testid shortcuts (e.g., 'testid:submit-button').",
|
|
254
|
+
inputSchema: {
|
|
255
|
+
type: "object",
|
|
256
|
+
properties: {
|
|
257
|
+
selector: {
|
|
258
|
+
type: "string",
|
|
259
|
+
description: "CSS selector, text selector, or testid shorthand (e.g., 'testid:login-button', '#submit', 'text=Click here')"
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
required: ["selector"],
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "inspect_dom",
|
|
267
|
+
description: "Progressive DOM inspection with semantic filtering and spatial layout info. This is the PRIMARY tool for understanding page structure. Returns immediate semantic children only (header, nav, main, form, button, elements with test IDs, ARIA roles, etc.) while automatically drilling through non-semantic wrapper elements (div, span, etc.) up to maxDepth levels. Use without selector for page overview, then drill down by calling again with a child's selector. Returns compact text format with position, visibility, and layout pattern detection. Supports testid shortcuts.",
|
|
268
|
+
inputSchema: {
|
|
269
|
+
type: "object",
|
|
270
|
+
properties: {
|
|
271
|
+
selector: {
|
|
272
|
+
type: "string",
|
|
273
|
+
description: "CSS selector, text selector, or testid shorthand to inspect. Omit for page overview (defaults to body). Use 'testid:login-form', '#main', etc."
|
|
274
|
+
},
|
|
275
|
+
includeHidden: {
|
|
276
|
+
type: "boolean",
|
|
277
|
+
description: "Include hidden elements in results (default: false)"
|
|
278
|
+
},
|
|
279
|
+
maxChildren: {
|
|
280
|
+
type: "number",
|
|
281
|
+
description: "Maximum number of children to show (default: 20)"
|
|
282
|
+
},
|
|
283
|
+
maxDepth: {
|
|
284
|
+
type: "number",
|
|
285
|
+
description: "Maximum depth to drill through non-semantic wrapper elements when looking for semantic children (default: 5). Increase for extremely deeply nested components, decrease to 1 to see only immediate children without drilling."
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
required: [],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "get_test_ids",
|
|
293
|
+
description: "Discover all test identifiers on the page (data-testid, data-test, data-cy, etc.). Returns a compact text list grouped by attribute type. Essential for test-driven workflows and understanding what elements can be reliably selected. Use the returned test IDs with selector shortcuts like 'testid:submit-button'.",
|
|
294
|
+
inputSchema: {
|
|
295
|
+
type: "object",
|
|
296
|
+
properties: {
|
|
297
|
+
attributes: {
|
|
298
|
+
type: "string",
|
|
299
|
+
description: "Comma-separated list of test ID attributes to search for (default: 'data-testid,data-test,data-cy')"
|
|
300
|
+
},
|
|
301
|
+
showAll: {
|
|
302
|
+
type: "boolean",
|
|
303
|
+
description: "If true, display all test IDs without truncation. If false (default), shows first 8 test IDs per attribute with a summary for longer lists."
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
required: [],
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "query_selector",
|
|
311
|
+
description: "Test a selector and return detailed information about all matched elements. Essential for selector debugging and finding the right element to interact with. Returns compact text format with element tag, position, text content, visibility status, and interaction capability. Shows why elements are hidden (display:none, opacity:0, zero size). Supports testid shortcuts (e.g., 'testid:submit-button'). Use limit parameter to control how many matches to show (default: 10). NEW: Use onlyVisible parameter to filter results (true=visible only, false=hidden only, undefined=all).",
|
|
312
|
+
inputSchema: {
|
|
313
|
+
type: "object",
|
|
314
|
+
properties: {
|
|
315
|
+
selector: {
|
|
316
|
+
type: "string",
|
|
317
|
+
description: "CSS selector, text selector, or testid shorthand to test (e.g., 'button.submit', 'testid:login-form', 'text=Sign In')"
|
|
318
|
+
},
|
|
319
|
+
limit: {
|
|
320
|
+
type: "number",
|
|
321
|
+
description: "Maximum number of elements to return detailed info for (default: 10, recommended max: 50)"
|
|
322
|
+
},
|
|
323
|
+
onlyVisible: {
|
|
324
|
+
type: "boolean",
|
|
325
|
+
description: "Filter results by visibility: true = show only visible elements, false = show only hidden elements, undefined/not specified = show all elements (default: undefined)"
|
|
326
|
+
},
|
|
327
|
+
showAttributes: {
|
|
328
|
+
type: "string",
|
|
329
|
+
description: "Comma-separated list of HTML attributes to display for each element (e.g., 'id,name,aria-label,href,type'). If not specified, attributes are not shown."
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
required: ["selector"],
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "find_by_text",
|
|
337
|
+
description: "Find elements by their text content. Essential for finding elements without good selectors, especially in poorly structured DOM. Returns elements with position, visibility, and interaction state. Supports exact match, case-sensitive search, and NEW: regex pattern matching for advanced text searching (e.g., '/\\d+ items?/' to find elements with numbers).",
|
|
338
|
+
inputSchema: {
|
|
339
|
+
type: "object",
|
|
340
|
+
properties: {
|
|
341
|
+
text: {
|
|
342
|
+
type: "string",
|
|
343
|
+
description: "Text to search for in elements. If regex=true, this can be a regex pattern in /pattern/flags format (e.g., '/\\d+/i' for case-insensitive numbers) or a raw pattern string."
|
|
344
|
+
},
|
|
345
|
+
exact: {
|
|
346
|
+
type: "boolean",
|
|
347
|
+
description: "Whether to match text exactly (default: false, allows partial matches). Ignored if regex=true."
|
|
348
|
+
},
|
|
349
|
+
caseSensitive: {
|
|
350
|
+
type: "boolean",
|
|
351
|
+
description: "Whether search should be case-sensitive (default: false). Ignored if regex=true (use regex flags instead)."
|
|
352
|
+
},
|
|
353
|
+
regex: {
|
|
354
|
+
type: "boolean",
|
|
355
|
+
description: "Whether to treat 'text' as a regex pattern (default: false). If true, supports /pattern/flags format or raw pattern. Examples: '/sign.*/i' (case-insensitive), '/\\d+ items?/' (numbers + optional 's')."
|
|
356
|
+
},
|
|
357
|
+
limit: {
|
|
358
|
+
type: "number",
|
|
359
|
+
description: "Maximum number of elements to return (default: 10)"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
required: ["text"],
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: "get_computed_styles",
|
|
367
|
+
description: "Get computed CSS styles for an element. Essential for understanding why elements behave unexpectedly and debugging layout issues. Returns styles grouped by category (Layout, Visibility, Spacing, Typography). Use properties parameter to request specific CSS properties, or omit for common layout properties.",
|
|
368
|
+
inputSchema: {
|
|
369
|
+
type: "object",
|
|
370
|
+
properties: {
|
|
371
|
+
selector: {
|
|
372
|
+
type: "string",
|
|
373
|
+
description: "CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#main')"
|
|
374
|
+
},
|
|
375
|
+
properties: {
|
|
376
|
+
type: "string",
|
|
377
|
+
description: "Comma-separated list of CSS properties to retrieve (e.g., 'display,width,color'). If not specified, returns common layout properties: display, position, width, height, opacity, visibility, z-index, overflow, margin, padding, font-size, font-weight, color, background-color"
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
required: ["selector"],
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "measure_element",
|
|
385
|
+
description: "Get box model measurements (position, size, margin, padding, border) for an element. Use for layout debugging, spacing validation, and understanding CSS box model. Returns compact visual representation of content, padding, border, and margin with directional arrows.",
|
|
386
|
+
inputSchema: {
|
|
387
|
+
type: "object",
|
|
388
|
+
properties: {
|
|
389
|
+
selector: {
|
|
390
|
+
type: "string",
|
|
391
|
+
description: "CSS selector or testid shorthand (e.g., 'testid:submit', '#login-button')"
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
required: ["selector"],
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: "element_exists",
|
|
399
|
+
description: "Quick check if an element exists on the page. Ultra-lightweight alternative to query_selector_all when you only need existence confirmation. Returns simple exists/not found status. Most common check before attempting interaction. Supports testid shortcuts.",
|
|
400
|
+
inputSchema: {
|
|
401
|
+
type: "object",
|
|
402
|
+
properties: {
|
|
403
|
+
selector: {
|
|
404
|
+
type: "string",
|
|
405
|
+
description: "CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#main')"
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
required: ["selector"],
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: "compare_positions",
|
|
413
|
+
description: "Compare positions and alignment of two elements. Validates layout consistency by checking if elements are aligned (top, left, right, bottom) or have the same dimensions (width, height). Essential for visual regression testing and ensuring consistent spacing across components. Returns compact text format with alignment status and difference in pixels.",
|
|
414
|
+
inputSchema: {
|
|
415
|
+
type: "object",
|
|
416
|
+
properties: {
|
|
417
|
+
selector1: {
|
|
418
|
+
type: "string",
|
|
419
|
+
description: "CSS selector, text selector, or testid shorthand for the first element (e.g., 'testid:main-header', '#header')"
|
|
420
|
+
},
|
|
421
|
+
selector2: {
|
|
422
|
+
type: "string",
|
|
423
|
+
description: "CSS selector, text selector, or testid shorthand for the second element (e.g., 'testid:chat-header', '#secondary-header')"
|
|
424
|
+
},
|
|
425
|
+
checkAlignment: {
|
|
426
|
+
type: "string",
|
|
427
|
+
description: "What to check: 'top', 'left', 'right', 'bottom' (edge alignment), or 'width', 'height' (dimension matching)",
|
|
428
|
+
enum: ["top", "left", "right", "bottom", "width", "height"]
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
required: ["selector1", "selector2", "checkAlignment"],
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: "wait_for_element",
|
|
436
|
+
description: "Wait for an element to reach a specific state (visible, hidden, attached, detached). Better than sleep() for waiting on dynamic content. Returns duration and current element status. Supports testid shortcuts (e.g., 'testid:submit-button').",
|
|
437
|
+
inputSchema: {
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: {
|
|
440
|
+
selector: {
|
|
441
|
+
type: "string",
|
|
442
|
+
description: "CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#loading-spinner')"
|
|
443
|
+
},
|
|
444
|
+
state: {
|
|
445
|
+
type: "string",
|
|
446
|
+
description: "State to wait for: 'visible' (default), 'hidden', 'attached', 'detached'",
|
|
447
|
+
enum: ["visible", "hidden", "attached", "detached"]
|
|
448
|
+
},
|
|
449
|
+
timeout: {
|
|
450
|
+
type: "number",
|
|
451
|
+
description: "Maximum time to wait in milliseconds (default: 10000)"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
required: ["selector"],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "wait_for_network_idle",
|
|
459
|
+
description: "Wait for network activity to settle. Waits until there are no network connections for at least 500ms. Better than fixed delays when waiting for AJAX calls or dynamic content loading. Returns actual wait duration and confirmation of idle state.",
|
|
460
|
+
inputSchema: {
|
|
461
|
+
type: "object",
|
|
462
|
+
properties: {
|
|
463
|
+
timeout: {
|
|
464
|
+
type: "number",
|
|
465
|
+
description: "Maximum time to wait in milliseconds (default: 10000)"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
required: [],
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "list_network_requests",
|
|
473
|
+
description: "List recent network requests captured by the browser. Returns compact text format with method, URL, status, resource type, timing, and size. Essential for debugging API calls and performance issues. Use get_request_details() to inspect full headers and body for specific requests.",
|
|
474
|
+
inputSchema: {
|
|
475
|
+
type: "object",
|
|
476
|
+
properties: {
|
|
477
|
+
type: {
|
|
478
|
+
type: "string",
|
|
479
|
+
description: "Filter by resource type: 'xhr', 'fetch', 'script', 'stylesheet', 'image', 'font', 'document', etc. Omit to show all types."
|
|
480
|
+
},
|
|
481
|
+
limit: {
|
|
482
|
+
type: "number",
|
|
483
|
+
description: "Maximum number of requests to return, most recent first (default: 50)"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
required: [],
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "get_request_details",
|
|
491
|
+
description: "Get detailed information about a specific network request by index (from list_network_requests). Returns request/response headers, body (truncated at 500 chars), timing, and size. Request bodies with passwords are automatically masked. Essential for debugging API responses and investigating failed requests.",
|
|
492
|
+
inputSchema: {
|
|
493
|
+
type: "object",
|
|
494
|
+
properties: {
|
|
495
|
+
index: {
|
|
496
|
+
type: "number",
|
|
497
|
+
description: "Index of the request from list_network_requests output (e.g., [0], [1], etc.)"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
required: ["index"],
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
// Web inspection and debugging tools (browser-requiring)
|
|
506
|
+
export const BROWSER_TOOLS = [
|
|
507
|
+
// Navigation & Control
|
|
508
|
+
"navigate",
|
|
509
|
+
"go_back",
|
|
510
|
+
"go_forward",
|
|
511
|
+
"screenshot",
|
|
512
|
+
// DOM Inspection (PRIMARY)
|
|
513
|
+
"inspect_dom",
|
|
514
|
+
"get_test_ids",
|
|
515
|
+
"query_selector",
|
|
516
|
+
"find_by_text",
|
|
517
|
+
// Visibility & Position
|
|
518
|
+
"check_visibility",
|
|
519
|
+
"get_position",
|
|
520
|
+
"compare_positions",
|
|
521
|
+
"element_exists",
|
|
522
|
+
"wait_for_element",
|
|
523
|
+
"wait_for_network_idle",
|
|
524
|
+
// Style & Content
|
|
525
|
+
"get_computed_styles",
|
|
526
|
+
"measure_element",
|
|
527
|
+
"get_text",
|
|
528
|
+
"get_html",
|
|
529
|
+
"get_console_logs",
|
|
530
|
+
// Network Monitoring
|
|
531
|
+
"list_network_requests",
|
|
532
|
+
"get_request_details",
|
|
533
|
+
// Interactions (for debugging/testing workflows)
|
|
534
|
+
"click",
|
|
535
|
+
"fill",
|
|
536
|
+
"hover",
|
|
537
|
+
"select",
|
|
538
|
+
"upload_file",
|
|
539
|
+
"drag",
|
|
540
|
+
"press_key",
|
|
541
|
+
// JavaScript Execution
|
|
542
|
+
"evaluate",
|
|
543
|
+
// Cleanup
|
|
544
|
+
"close"
|
|
545
|
+
];
|
|
546
|
+
// Removed tools (not needed for web inspection/debugging):
|
|
547
|
+
// - HTTP API tools: get, post, put, patch, delete (use dedicated HTTP clients instead)
|
|
548
|
+
// - Code generation: start_codegen_session, end_codegen_session, get_codegen_session, clear_codegen_session
|
|
549
|
+
// - iFrame interactions: iframe_click, iframe_fill (can be added back if needed)
|
|
550
|
+
// - Tab management: click_and_switch_tab
|
|
551
|
+
// - Network: expect_response, assert_response
|
|
552
|
+
// - Other: set_user_agent, save_pdf
|
|
553
|
+
// All available tools (browser tools only)
|
|
554
|
+
export const tools = BROWSER_TOOLS;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export interface Tool {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: Record<string, unknown>;
|
|
8
|
+
required?: string[];
|
|
9
|
+
};
|
|
10
|
+
handler: (args: any) => Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolCall {
|
|
13
|
+
name: string;
|
|
14
|
+
parameters: Record<string, unknown>;
|
|
15
|
+
result?: CallToolResult;
|
|
16
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-web-inspector",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web Inspector MCP: Give LLMs visual superpowers to see, debug, and test any web page.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Anton",
|
|
7
|
+
"homepage": "https://github.com/antonzherdev/mcp-web-inspector",
|
|
8
|
+
"bugs": "https://github.com/antonzherdev/mcp-web-inspector/issues",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"mcp-web-inspector": "dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc && shx chmod +x dist/*.js",
|
|
19
|
+
"prepare": "npm run build",
|
|
20
|
+
"watch": "tsc --watch",
|
|
21
|
+
"test": "jest --testMatch=\"<rootDir>/src/__tests__/**/*.test.ts\"",
|
|
22
|
+
"test:coverage": "jest --coverage --testMatch=\"<rootDir>/src/__tests__/**/*.test.ts\"",
|
|
23
|
+
"test:custom": "node run-tests.cjs"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/antonzherdev/mcp-web-inspector.git"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "1.11.1",
|
|
31
|
+
"@playwright/browser-chromium": "1.53.1",
|
|
32
|
+
"@playwright/browser-firefox": "1.53.1",
|
|
33
|
+
"@playwright/browser-webkit": "1.53.1",
|
|
34
|
+
"@playwright/test": "^1.53.1",
|
|
35
|
+
"mcp-evals": "^1.0.18",
|
|
36
|
+
"playwright": "1.53.1",
|
|
37
|
+
"uuid": "11.1.0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"mcp",
|
|
41
|
+
"web-inspector",
|
|
42
|
+
"debugging",
|
|
43
|
+
"testing",
|
|
44
|
+
"playwright",
|
|
45
|
+
"automation",
|
|
46
|
+
"AI",
|
|
47
|
+
"Claude MCP",
|
|
48
|
+
"DOM inspection",
|
|
49
|
+
"element debugging"
|
|
50
|
+
],
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/jest": "^29.5.14",
|
|
53
|
+
"@types/node": "^20.10.5",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"jest-playwright-preset": "4.0.0",
|
|
56
|
+
"shx": "^0.3.4",
|
|
57
|
+
"ts-jest": "^29.2.6",
|
|
58
|
+
"typescript": "^5.8.3"
|
|
59
|
+
}
|
|
60
|
+
}
|