viyv-browser-mcp 0.6.3 → 0.6.4

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/dist/index.js CHANGED
@@ -1248,6 +1248,21 @@ var RESIZE_WINDOW_RETURNS = `{
1248
1248
  }`;
1249
1249
  var RESIZE_WINDOW_RELATED = ["screenshot"];
1250
1250
 
1251
+ // src/tools/advanced/save-pdf.ts
1252
+ var SAVE_PDF_DESCRIPTION = `Generate PDF from page. Supports landscape, margins, page ranges.
1253
+ Returns: { sizeBytes, filename } or { data (base64) }`;
1254
+ var SAVE_PDF_DETAIL = `Generate a PDF document from the current page via CDP Page.printToPDF.
1255
+ Use download:true to save to Downloads folder (recommended \u2014 base64 may exceed 1MB MCP message limit).
1256
+ Without download, returns base64 data.`;
1257
+ var SAVE_PDF_RETURNS = `{
1258
+ data?: string // base64 PDF (omitted when download:true)
1259
+ sizeBytes: number
1260
+ downloaded?: boolean
1261
+ filename?: string // when download:true
1262
+ warning?: string // when PDF > 700KB without download
1263
+ }`;
1264
+ var SAVE_PDF_RELATED = ["screenshot", "artifact_from_page"];
1265
+
1251
1266
  // src/tools/advanced/shortcuts-execute.ts
1252
1267
  var SHORTCUTS_EXECUTE_DESCRIPTION = `Execute shortcut by command or ID.
1253
1268
  Returns: execution result`;
@@ -1403,7 +1418,10 @@ Supports text inputs, textareas, selects, checkboxes, and radio buttons.
1403
1418
  The ref must be obtained from a prior find or snapshot operation
1404
1419
  to ensure the correct element is targeted.
1405
1420
  Use submit: true to press Enter after setting the value and wait for any
1406
- resulting navigation. Useful for search boxes and login forms.`;
1421
+ resulting navigation. Useful for search boxes and login forms.
1422
+ For select elements: use listOptions:true to list available options without changing selection
1423
+ (pass any value for the required value param, e.g. value:"").
1424
+ If no option matches, the error includes availableOptions (up to 20).`;
1407
1425
  var FORM_INPUT_RETURNS = `{
1408
1426
  set: true
1409
1427
  value?: string // new value
@@ -1628,6 +1646,22 @@ var WAIT_FOR_RETURNS = `// Navigation: { waited: "navigation" }
1628
1646
  // Timeout: { waited: number, type: "delay" }`;
1629
1647
  var WAIT_FOR_RELATED = ["click", "navigate", "form_input"];
1630
1648
 
1649
+ // src/tools/debug/network-intercept.ts
1650
+ var NETWORK_INTERCEPT_DESCRIPTION = `Intercept/mock/block network requests. Actions: add, remove, list, clear.
1651
+ Returns: { rules[] } or { cleared }`;
1652
+ var NETWORK_INTERCEPT_DETAIL = `Intercept network requests matching URL patterns.
1653
+ Use action "add" to add a rule. Each rule blocks or mocks requests matching the URL pattern.
1654
+ Use action "list" to see active rules, "remove" to delete by ruleId, "clear" to remove all.
1655
+ Max 10 rules per tab. Rules are auto-cleared when the tab is closed or agent disconnects.
1656
+ Caution: blocking critical requests may break page functionality \u2014 use "clear" to recover.`;
1657
+ var NETWORK_INTERCEPT_RETURNS = `{
1658
+ // add: { ruleId, rules[] }
1659
+ // remove: { removed, rules[] }
1660
+ // list: { rules[] }
1661
+ // clear: { cleared, removedCount }
1662
+ }`;
1663
+ var NETWORK_INTERCEPT_RELATED = ["read_network_requests"];
1664
+
1631
1665
  // src/tools/debug/read-console-messages.ts
1632
1666
  var READ_CONSOLE_MESSAGES_DESCRIPTION = `Read page console messages. Filter by level/pattern, clear after read.
1633
1667
  Returns: { messages[], total }`;
@@ -2921,6 +2955,7 @@ var BROWSER_HEALTH_RETURNS = `{
2921
2955
  currentGroup?: { groupId, tabs: number[], color } | null
2922
2956
  totalSessions: number
2923
2957
  extensionVersion: string
2958
+ recentActions: [{ tool, timestamp, durationMs, result, errorCode?, tabId?, meta? }]
2924
2959
  }`;
2925
2960
  var BROWSER_HEALTH_RELATED = ["tabs_context", "switch_browser"];
2926
2961
 
@@ -3124,7 +3159,8 @@ var formInputTool = {
3124
3159
  value: z.union([z.string(), z.boolean(), z.coerce.number()]).describe("Value to set"),
3125
3160
  submit: z.boolean().optional().describe(
3126
3161
  "Submit the form after setting value (dispatches Enter key and waits for navigation)"
3127
- )
3162
+ ),
3163
+ listOptions: z.boolean().optional().describe("List select options without changing selection")
3128
3164
  })
3129
3165
  };
3130
3166
  var javascriptExecTool = {
@@ -3295,6 +3331,24 @@ var readNetworkRequestsTool = {
3295
3331
  file_path: z.string().optional().describe("Save results to local file as JSON. Returns metadata only.")
3296
3332
  })
3297
3333
  };
3334
+ var networkInterceptTool = {
3335
+ name: "network_intercept",
3336
+ description: NETWORK_INTERCEPT_DESCRIPTION,
3337
+ detail: NETWORK_INTERCEPT_DETAIL,
3338
+ returns: NETWORK_INTERCEPT_RETURNS,
3339
+ category: "debug",
3340
+ related: NETWORK_INTERCEPT_RELATED,
3341
+ inputSchema: z.object({
3342
+ tabId: z.coerce.number().describe("Tab ID"),
3343
+ action: z.enum(["add", "remove", "list", "clear"]).describe("Operation"),
3344
+ urlPattern: z.string().optional().describe("URL substring to match (for add)"),
3345
+ response: z.enum(["block", "mock"]).optional().describe("What to do with matched requests (for add)"),
3346
+ mockStatus: z.coerce.number().optional().describe("Mock response status code"),
3347
+ mockBody: z.string().optional().describe("Mock response body"),
3348
+ mockContentType: z.string().optional().describe("Mock Content-Type header"),
3349
+ ruleId: z.string().optional().describe("Rule ID (for remove)")
3350
+ })
3351
+ };
3298
3352
  var gifCreatorTool = {
3299
3353
  name: "gif_creator",
3300
3354
  description: GIF_CREATOR_DESCRIPTION,
@@ -3390,6 +3444,23 @@ var switchBrowserTool = {
3390
3444
  related: SWITCH_BROWSER_RELATED,
3391
3445
  inputSchema: z.object({})
3392
3446
  };
3447
+ var savePdfTool = {
3448
+ name: "save_pdf",
3449
+ description: SAVE_PDF_DESCRIPTION,
3450
+ detail: SAVE_PDF_DETAIL,
3451
+ returns: SAVE_PDF_RETURNS,
3452
+ category: "advanced",
3453
+ related: SAVE_PDF_RELATED,
3454
+ inputSchema: z.object({
3455
+ tabId: z.coerce.number().describe("Tab ID"),
3456
+ landscape: z.boolean().optional().describe("Landscape orientation"),
3457
+ scale: z.coerce.number().min(0.1).max(2).optional().describe("Scale (default: 1)"),
3458
+ pageRanges: z.string().optional().describe('Pages (e.g. "1-3, 5")'),
3459
+ printBackground: z.boolean().optional().describe("Print backgrounds (default: true)"),
3460
+ download: z.boolean().optional().describe("Save to Downloads folder"),
3461
+ filename: z.string().optional().describe("Filename for download")
3462
+ })
3463
+ };
3393
3464
  var fileUploadTool = {
3394
3465
  name: "file_upload",
3395
3466
  description: FILE_UPLOAD_DESCRIPTION,
@@ -4289,10 +4360,11 @@ var allTools = [
4289
4360
  tabsCreateTool,
4290
4361
  tabCloseTool,
4291
4362
  selectTabTool,
4292
- // Debug (2)
4363
+ // Debug (3)
4293
4364
  readConsoleMessagesTool,
4294
4365
  readNetworkRequestsTool,
4295
- // Advanced (8)
4366
+ networkInterceptTool,
4367
+ // Advanced (9)
4296
4368
  gifCreatorTool,
4297
4369
  uploadImageTool,
4298
4370
  fileUploadTool,
@@ -4301,6 +4373,7 @@ var allTools = [
4301
4373
  shortcutsListTool,
4302
4374
  shortcutsExecuteTool,
4303
4375
  switchBrowserTool,
4376
+ savePdfTool,
4304
4377
  // viyv Integration (7)
4305
4378
  agentTabAssignTool,
4306
4379
  agentTabListTool,
@@ -5060,14 +5133,12 @@ async function callExtensionTool(tool, input) {
5060
5133
  };
5061
5134
  }
5062
5135
  if (tool === "browser_health") {
5063
- return {
5064
- content: [
5065
- {
5066
- type: "text",
5067
- text: JSON.stringify(getHealthStatus())
5068
- }
5069
- ]
5070
- };
5136
+ const health = getHealthStatus();
5137
+ if (!health.extensionConnected || !extensionSocket || extensionSocket.destroyed) {
5138
+ return {
5139
+ content: [{ type: "text", text: JSON.stringify(health) }]
5140
+ };
5141
+ }
5071
5142
  }
5072
5143
  if (tool === "switch_browser") {
5073
5144
  return handleSwitchBrowser();