@tontoko/fast-playwright-mcp 0.0.8 → 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.
Files changed (44) hide show
  1. package/README.md +277 -117
  2. package/lib/batch/batch-executor.js +4 -5
  3. package/lib/browser-context-factory.js +2 -4
  4. package/lib/browser-server-backend.js +5 -7
  5. package/lib/config.js +1 -1
  6. package/lib/context.js +1 -4
  7. package/lib/diagnostics/common/error-enrichment-utils.js +3 -2
  8. package/lib/diagnostics/common/index.js +4 -55
  9. package/lib/diagnostics/element-discovery.js +1 -2
  10. package/lib/diagnostics/frame-reference-manager.js +5 -6
  11. package/lib/diagnostics/resource-manager.js +1 -2
  12. package/lib/diagnostics/smart-config.js +5 -6
  13. package/lib/diagnostics/smart-handle.js +1 -2
  14. package/lib/extension/cdp-relay.js +32 -34
  15. package/lib/extension/extension-context-factory.js +4 -5
  16. package/lib/in-process-client.js +1 -1
  17. package/lib/loop/loop.js +5 -5
  18. package/lib/loopTools/main.js +1 -1
  19. package/lib/mcp/proxy-backend.js +2 -2
  20. package/lib/mcp/server.js +4 -6
  21. package/lib/{log.js → mcp/tool.js} +17 -11
  22. package/lib/mcp/transport.js +2 -4
  23. package/lib/program.js +2 -3
  24. package/lib/response.js +1 -2
  25. package/lib/session-log.js +1 -1
  26. package/lib/tab.js +2 -4
  27. package/lib/tools/diagnose/diagnose-config-handler.js +2 -3
  28. package/lib/tools/evaluate.js +1 -1
  29. package/lib/tools/keyboard.js +1 -1
  30. package/lib/tools/network.js +97 -6
  31. package/lib/tools/pdf.js +1 -1
  32. package/lib/tools/screenshot.js +1 -1
  33. package/lib/tools/snapshot.js +1 -1
  34. package/lib/tools/utils.js +6 -7
  35. package/lib/{javascript.js → utils/codegen.js} +1 -1
  36. package/lib/utils/common-formatters.js +2 -3
  37. package/lib/utils/error-handler-middleware.js +1 -2
  38. package/lib/{utils.js → utils/guid.js} +1 -1
  39. package/lib/utils/index.js +6 -0
  40. package/lib/utils/log.js +90 -0
  41. package/lib/utils/network-filter.js +114 -0
  42. package/lib/{package.js → utils/package.js} +2 -2
  43. package/lib/utils/request-logger.js +1 -1
  44. package/package.json +3 -3
package/README.md CHANGED
@@ -1,4 +1,7 @@
1
- ## Playwright MCP
1
+ ## **Fast** Playwright MCP
2
+
3
+ This MCP server is a fork of the Microsoft one.
4
+ <https://github.com/microsoft/playwright-mcp>
2
5
 
3
6
  A Model Context Protocol (MCP) server that provides browser automation capabilities using [Playwright](https://playwright.dev). This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models.
4
7
 
@@ -15,10 +18,6 @@ A Model Context Protocol (MCP) server that provides browser automation capabilit
15
18
  - `includeSnapshot: false` - Skip page snapshot for minimal responses (70-80% token reduction)
16
19
  - `includeConsole: false` - Exclude console messages
17
20
  - `includeTabs: false` - Hide tab information
18
- - **Ultra-Compact Tool Descriptions**. One-line tool descriptions with full parameter details:
19
- - 70-80% reduction in tool description tokens
20
- - All expectation parameters inline without formatting overhead
21
- - Smart tips for efficient usage (e.g., "Use selector to focus on specific area")
22
21
  - **Image Compression**. Screenshot tool supports `imageOptions`:
23
22
  - `format: 'jpeg'` - Use JPEG instead of PNG
24
23
  - `quality: 1-100` - Compress images (e.g., 50 for 50% quality)
@@ -133,6 +132,29 @@ Go to `Advanced settings` -> `Extensions` -> `Add custom extension`. Name to you
133
132
  Go to `Program` in the right sidebar -> `Install` -> `Edit mcp.json`. Use the standard config above.
134
133
  </details>
135
134
 
135
+ <details>
136
+ <summary>opencode</summary>
137
+
138
+ Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). For example in `~/.config/opencode/opencode.json`:
139
+
140
+ ```json
141
+ {
142
+ "$schema": "https://opencode.ai/config.json",
143
+ "mcp": {
144
+ "playwright": {
145
+ "type": "local",
146
+ "command": [
147
+ "npx",
148
+ "@tontoko/fast-playwright-mcp"
149
+ ],
150
+ "enabled": true
151
+ }
152
+ }
153
+ }
154
+
155
+ ```
156
+ </details>
157
+
136
158
  <details>
137
159
  <summary>Qodo Gen</summary>
138
160
 
@@ -191,6 +213,9 @@ Playwright MCP server supports following arguments. They can be provided in the
191
213
  --config <path> path to the configuration file.
192
214
  --device <device> device to emulate, for example: "iPhone 15"
193
215
  --executable-path <path> path to the browser executable.
216
+ --extension Connect to a running browser instance
217
+ (Edge/Chrome only). Requires the "Playwright MCP
218
+ Bridge" browser extension to be installed.
194
219
  --headless run browser in headless mode, headed by default
195
220
  --host <host> host to bind server to. Default is localhost. Use
196
221
  0.0.0.0 to bind to all interfaces.
@@ -224,7 +249,7 @@ Playwright MCP server supports following arguments. They can be provided in the
224
249
 
225
250
  ### User profile
226
251
 
227
- You can run Playwright MCP with persistent profile like a regular browser (default), or in the isolated contexts for the testing sessions.
252
+ You can run Playwright MCP with persistent profile like a regular browser (default), in isolated contexts for testing sessions, or connect to your existing browser using the browser extension.
228
253
 
229
254
  **Persistent profile**
230
255
 
@@ -264,6 +289,10 @@ state [here](https://playwright.dev/docs/auth).
264
289
  }
265
290
  ```
266
291
 
292
+ **Browser Extension**
293
+
294
+ The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [extension/README.md](extension/README.md) for installation and setup instructions.
295
+
267
296
  ### Configuration file
268
297
 
269
298
  The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file
@@ -581,8 +610,14 @@ http.createServer(async (req, res) => {
581
610
 
582
611
  - **browser_network_requests**
583
612
  - Title: List network requests
584
- - Description: Returns all network requests since loading the page
585
- - Parameters: None
613
+ - Description: Returns network requests since loading the page with optional filtering. urlPatterns:["api/users"] to filter by URL patterns. excludeUrlPatterns:["analytics"] to exclude specific patterns. statusRanges:[{min:200,max:299}] for success codes only. methods:["GET","POST"] to filter by HTTP method. maxRequests:10 to limit results. newestFirst:false for chronological order. Supports regex patterns for advanced filtering.
614
+ - Parameters:
615
+ - `urlPatterns` (array, optional): URL patterns to include (supports regex)
616
+ - `excludeUrlPatterns` (array, optional): URL patterns to exclude (supports regex)
617
+ - `statusRanges` (array, optional): Status code ranges to include
618
+ - `methods` (array, optional): HTTP methods to filter by
619
+ - `maxRequests` (number, optional): Maximum number of results to return (default: 20)
620
+ - `newestFirst` (boolean, optional): Sort order - true for newest first (default: true)
586
621
  - Read-only: **true**
587
622
 
588
623
  <!-- NOTE: This has been generated via update-readme.js -->
@@ -792,19 +827,27 @@ All browser tools support an optional `expectation` parameter that controls what
792
827
 
793
828
  #### Basic Usage
794
829
 
795
- ```javascript
830
+ ```json
796
831
  // Standard call - includes all information (snapshot, console, tabs, etc.)
797
- await browser_navigate({ url: 'https://example.com' });
832
+ {
833
+ "name": "browser_navigate",
834
+ "arguments": {
835
+ "url": "https://example.com"
836
+ }
837
+ }
798
838
 
799
839
  // Optimized call - only includes essential information
800
- await browser_navigate({
801
- url: 'https://example.com',
802
- expectation: {
803
- includeSnapshot: false, // Skip page snapshot
804
- includeConsole: false, // Skip console messages
805
- includeTabs: false // Skip tab information
840
+ {
841
+ "name": "browser_navigate",
842
+ "arguments": {
843
+ "url": "https://example.com",
844
+ "expectation": {
845
+ "includeSnapshot": false,
846
+ "includeConsole": false,
847
+ "includeTabs": false
848
+ }
806
849
  }
807
- });
850
+ }
808
851
  ```
809
852
 
810
853
  #### Expectation Options
@@ -817,36 +860,42 @@ await browser_navigate({
817
860
 
818
861
  #### Advanced Snapshot Options
819
862
 
820
- ```javascript
821
- await browser_click({
822
- element: 'Login button',
823
- ref: '#login-btn',
824
- expectation: {
825
- includeSnapshot: true,
826
- snapshotOptions: {
827
- selector: '.dashboard', // Only capture dashboard area
828
- maxLength: 1000, // Limit snapshot length
829
- format: 'text' // Use text format instead of aria
863
+ ```json
864
+ {
865
+ "name": "browser_click",
866
+ "arguments": {
867
+ "element": "Login button",
868
+ "ref": "#login-btn",
869
+ "expectation": {
870
+ "includeSnapshot": true,
871
+ "snapshotOptions": {
872
+ "selector": ".dashboard",
873
+ "maxLength": 1000,
874
+ "format": "text"
875
+ }
830
876
  }
831
877
  }
832
- });
878
+ }
833
879
  ```
834
880
 
835
881
  #### Console Filtering Options
836
882
 
837
- ```javascript
838
- await browser_navigate({
839
- url: 'https://example.com',
840
- expectation: {
841
- includeConsole: true,
842
- consoleOptions: {
843
- levels: ['error', 'warn'], // Only errors and warnings
844
- maxMessages: 5, // Limit to 5 messages
845
- patterns: ['^Error:'], // Filter by regex patterns
846
- removeDuplicates: true // Remove duplicate messages
883
+ ```json
884
+ {
885
+ "name": "browser_navigate",
886
+ "arguments": {
887
+ "url": "https://example.com",
888
+ "expectation": {
889
+ "includeConsole": true,
890
+ "consoleOptions": {
891
+ "levels": ["error", "warn"],
892
+ "maxMessages": 5,
893
+ "patterns": ["^Error:"],
894
+ "removeDuplicates": true
895
+ }
847
896
  }
848
897
  }
849
- });
898
+ }
850
899
  ```
851
900
 
852
901
  ### Batch Execution
@@ -855,63 +904,69 @@ Execute multiple browser actions in a single request with optimized response han
855
904
 
856
905
  #### Basic Batch Execution
857
906
 
858
- ```javascript
859
- await browser_batch_execute({
860
- steps: [
861
- {
862
- tool: 'browser_navigate',
863
- arguments: { url: 'https://example.com/login' }
864
- },
865
- {
866
- tool: 'browser_type',
867
- arguments: {
868
- element: 'username field',
869
- ref: '#username',
870
- text: 'testuser'
871
- }
872
- },
873
- {
874
- tool: 'browser_type',
875
- arguments: {
876
- element: 'password field',
877
- ref: '#password',
878
- text: 'password'
907
+ ```json
908
+ {
909
+ "name": "browser_batch_execute",
910
+ "arguments": {
911
+ "steps": [
912
+ {
913
+ "tool": "browser_navigate",
914
+ "arguments": { "url": "https://example.com/login" }
915
+ },
916
+ {
917
+ "tool": "browser_type",
918
+ "arguments": {
919
+ "element": "username field",
920
+ "ref": "#username",
921
+ "text": "testuser"
922
+ }
923
+ },
924
+ {
925
+ "tool": "browser_type",
926
+ "arguments": {
927
+ "element": "password field",
928
+ "ref": "#password",
929
+ "text": "password"
930
+ }
931
+ },
932
+ {
933
+ "tool": "browser_click",
934
+ "arguments": { "element": "login button", "ref": "#login-btn" }
879
935
  }
880
- },
881
- {
882
- tool: 'browser_click',
883
- arguments: { element: 'login button', ref: '#login-btn' }
884
- }
885
- ]
886
- });
936
+ ]
937
+ }
938
+ }
887
939
  ```
888
940
 
889
941
  #### Advanced Batch Configuration
890
942
 
891
- ```javascript
892
- await browser_batch_execute({
893
- steps: [
894
- {
895
- tool: 'browser_navigate',
896
- arguments: { url: 'https://example.com' },
897
- expectation: { includeSnapshot: false }, // Step-specific optimization
898
- continueOnError: true // Continue if this step fails
899
- },
900
- {
901
- tool: 'browser_click',
902
- arguments: { element: 'button', ref: '#submit' },
903
- expectation: {
904
- includeSnapshot: true,
905
- snapshotOptions: { selector: '.result-area' }
943
+ ```json
944
+ {
945
+ "name": "browser_batch_execute",
946
+ "arguments": {
947
+ "steps": [
948
+ {
949
+ "tool": "browser_navigate",
950
+ "arguments": { "url": "https://example.com" },
951
+ "expectation": { "includeSnapshot": false },
952
+ "continueOnError": true
953
+ },
954
+ {
955
+ "tool": "browser_click",
956
+ "arguments": { "element": "button", "ref": "#submit" },
957
+ "expectation": {
958
+ "includeSnapshot": true,
959
+ "snapshotOptions": { "selector": ".result-area" }
960
+ }
906
961
  }
962
+ ],
963
+ "stopOnFirstError": false,
964
+ "globalExpectation": {
965
+ "includeConsole": false,
966
+ "includeTabs": false
907
967
  }
908
- ],
909
- stopOnFirstError: false, // Continue executing remaining steps
910
- globalExpectation: { // Default for all steps
911
- includeConsole: false,
912
- includeTabs: false
913
968
  }
914
- });
969
+ }
915
970
  ```
916
971
 
917
972
  #### Error Handling Options
@@ -941,22 +996,24 @@ Each tool has optimized defaults based on typical usage patterns:
941
996
 
942
997
  The Fast Server includes automatic diff detection to efficiently track changes between consecutive tool executions:
943
998
 
944
- ```javascript
945
- // Enable diff detection for any tool
946
- await browser_click({
947
- element: 'Load more button',
948
- ref: '#load-more',
949
- expectation: {
950
- includeSnapshot: true,
951
- diffOptions: {
952
- enabled: true,
953
- threshold: 0.1, // Show diff if >10% changed
954
- format: 'unified', // or 'split', 'minimal'
955
- maxDiffLines: 50, // Limit diff output size
956
- context: 3 // Lines of context around changes
999
+ ```json
1000
+ {
1001
+ "name": "browser_click",
1002
+ "arguments": {
1003
+ "element": "Load more button",
1004
+ "ref": "#load-more",
1005
+ "expectation": {
1006
+ "includeSnapshot": true,
1007
+ "diffOptions": {
1008
+ "enabled": true,
1009
+ "threshold": 0.1,
1010
+ "format": "unified",
1011
+ "maxDiffLines": 50,
1012
+ "context": 3
1013
+ }
957
1014
  }
958
1015
  }
959
- });
1016
+ }
960
1017
  ```
961
1018
 
962
1019
  #### Diff Detection Benefits
@@ -973,23 +1030,25 @@ await browser_click({
973
1030
  3. **Form interactions**: Track changes as users fill forms
974
1031
  4. **Selective monitoring**: Use with CSS selectors to track specific areas
975
1032
 
976
- ```javascript
977
- // Example: Track only search results changes
978
- await browser_type({
979
- element: 'Search input',
980
- ref: '#search',
981
- text: 'playwright',
982
- expectation: {
983
- includeSnapshot: true,
984
- snapshotOptions: {
985
- selector: '#search-results' // Only monitor results area
986
- },
987
- diffOptions: {
988
- enabled: true,
989
- format: 'minimal' // Just show what changed
1033
+ ```json
1034
+ {
1035
+ "name": "browser_type",
1036
+ "arguments": {
1037
+ "element": "Search input",
1038
+ "ref": "#search",
1039
+ "text": "playwright",
1040
+ "expectation": {
1041
+ "includeSnapshot": true,
1042
+ "snapshotOptions": {
1043
+ "selector": "#search-results"
1044
+ },
1045
+ "diffOptions": {
1046
+ "enabled": true,
1047
+ "format": "minimal"
1048
+ }
990
1049
  }
991
1050
  }
992
- });
1051
+ }
993
1052
  ```
994
1053
 
995
1054
  ### Best Practices
@@ -1037,6 +1096,107 @@ All tools automatically provide enhanced error messages with:
1037
1096
  - Context-aware troubleshooting tips
1038
1097
  - Performance insights
1039
1098
 
1099
+ ### Network Request Filtering
1100
+
1101
+ The `browser_network_requests` tool provides advanced filtering capabilities to reduce token usage by up to 80-95% when working with network logs.
1102
+
1103
+ #### Basic Usage Examples
1104
+
1105
+ ```json
1106
+ // Filter API requests only
1107
+ {
1108
+ "name": "browser_network_requests",
1109
+ "arguments": {
1110
+ "urlPatterns": ["api/", "/graphql"]
1111
+ }
1112
+ }
1113
+
1114
+ // Exclude analytics and tracking
1115
+ {
1116
+ "name": "browser_network_requests",
1117
+ "arguments": {
1118
+ "excludeUrlPatterns": ["analytics", "tracking", "ads"]
1119
+ }
1120
+ }
1121
+
1122
+ // Success responses only
1123
+ {
1124
+ "name": "browser_network_requests",
1125
+ "arguments": {
1126
+ "statusRanges": [{ "min": 200, "max": 299 }]
1127
+ }
1128
+ }
1129
+
1130
+ // Recent errors only
1131
+ {
1132
+ "name": "browser_network_requests",
1133
+ "arguments": {
1134
+ "statusRanges": [{ "min": 400, "max": 599 }],
1135
+ "maxRequests": 5,
1136
+ "newestFirst": true
1137
+ }
1138
+ }
1139
+ ```
1140
+
1141
+ #### Advanced Filtering
1142
+
1143
+ ```json
1144
+ // Complex filtering for API debugging
1145
+ {
1146
+ "name": "browser_network_requests",
1147
+ "arguments": {
1148
+ "urlPatterns": ["/api/users", "/api/posts"],
1149
+ "excludeUrlPatterns": ["/api/health"],
1150
+ "methods": ["GET", "POST"],
1151
+ "statusRanges": [
1152
+ { "min": 200, "max": 299 },
1153
+ { "min": 400, "max": 499 }
1154
+ ],
1155
+ "maxRequests": 10,
1156
+ "newestFirst": true
1157
+ }
1158
+ }
1159
+
1160
+ // Monitor only failed requests
1161
+ {
1162
+ "name": "browser_network_requests",
1163
+ "arguments": {
1164
+ "statusRanges": [
1165
+ { "min": 400, "max": 499 },
1166
+ { "min": 500, "max": 599 }
1167
+ ],
1168
+ "maxRequests": 3
1169
+ }
1170
+ }
1171
+ ```
1172
+
1173
+ #### Regex Pattern Support
1174
+
1175
+ ```json
1176
+ {
1177
+ "name": "browser_network_requests",
1178
+ "arguments": {
1179
+ "urlPatterns": ["^/api/v[0-9]+/users$"],
1180
+ "excludeUrlPatterns": ["\\.(css|js|png)$"]
1181
+ }
1182
+ }
1183
+ ```
1184
+
1185
+ #### Token Optimization Benefits
1186
+
1187
+ - **Massive reduction**: 80-95% fewer tokens for large applications
1188
+ - **Focused debugging**: See only relevant network activity
1189
+ - **Performance monitoring**: Track specific endpoints or error patterns
1190
+ - **Cost savings**: Lower API costs due to reduced token usage
1191
+
1192
+ #### When to Use Network Filtering
1193
+
1194
+ 1. **API debugging**: Focus on specific endpoints and methods
1195
+ 2. **Error monitoring**: Track only failed requests
1196
+ 3. **Performance analysis**: Monitor slow or problematic endpoints
1197
+ 4. **Large applications**: Reduce overwhelming network logs
1198
+ 5. **Token management**: Stay within LLM context limits
1199
+
1040
1200
  ### Migration Guide
1041
1201
 
1042
1202
  Existing code continues to work without changes. To optimize:
@@ -19,11 +19,10 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
19
 
20
20
  // src/batch/batch-executor.ts
21
21
  import { randomBytes } from "node:crypto";
22
- import debug from "debug";
23
22
  import { Response } from "../response.js";
24
23
  import { mergeExpectations } from "../schemas/expectation.js";
25
24
  import { getErrorMessage } from "../utils/common-formatters.js";
26
- var batchDebug = debug("pw:mcp:batch");
25
+ import { batchExecutorDebug } from "../utils/log.js";
27
26
 
28
27
  class BatchExecutor {
29
28
  toolRegistry;
@@ -66,7 +65,7 @@ class BatchExecutor {
66
65
  batchId: this.generateBatchId(),
67
66
  startTime
68
67
  };
69
- batchDebug(`Starting batch execution ${this.currentBatchContext.batchId} with ${options.steps.length} steps`);
68
+ batchExecutorDebug(`Starting batch execution ${this.currentBatchContext.batchId} with ${options.steps.length} steps`);
70
69
  this.validateAllSteps(options.steps);
71
70
  const executeSequentially = async (index) => {
72
71
  if (index >= options.steps.length) {
@@ -132,10 +131,10 @@ class BatchExecutor {
132
131
  this.context.batchContext = batchContext;
133
132
  try {
134
133
  const response = new Response(this.context, step.tool, argsWithExpectation, mergedExpectation);
135
- batchDebug(`Executing batch step: ${step.tool}`);
134
+ batchExecutorDebug(`Executing batch step: ${step.tool}`);
136
135
  await tool.handle(this.context, argsWithExpectation, response);
137
136
  await response.finish();
138
- batchDebug(`Batch step ${step.tool} completed`);
137
+ batchExecutorDebug(`Batch step ${step.tool} completed`);
139
138
  return response.serialize();
140
139
  } finally {
141
140
  this.context.batchContext = previousBatchContext;
@@ -21,7 +21,6 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
21
  import { promises as fsPromises } from "node:fs";
22
22
  import { createServer } from "node:net";
23
23
  import { join as pathJoin } from "node:path";
24
- import debug from "debug";
25
24
  import {
26
25
  chromium,
27
26
  firefox,
@@ -29,9 +28,8 @@ import {
29
28
  } from "playwright";
30
29
  import { registryDirectory } from "playwright-core/lib/server/registry/index";
31
30
  import { outputFile } from "./config.js";
32
- import { logUnhandledError, testDebug } from "./log.js";
33
- import { createHash } from "./utils.js";
34
- var browserDebug = debug("pw:mcp:browser");
31
+ import { createHash } from "./utils/guid.js";
32
+ import { browserDebug, logUnhandledError, testDebug } from "./utils/log.js";
35
33
  function getBrowserType(browserName) {
36
34
  switch (browserName) {
37
35
  case "chromium":
@@ -19,16 +19,14 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
19
 
20
20
  // src/browser-server-backend.ts
21
21
  import { fileURLToPath } from "node:url";
22
- import debug from "debug";
23
22
  import { z } from "zod";
24
23
  import { Context } from "./context.js";
25
- import { logUnhandledError } from "./log.js";
26
- import { packageJSON } from "./package.js";
27
24
  import { Response } from "./response.js";
28
25
  import { SessionLog } from "./session-log.js";
29
26
  import { defineTool } from "./tools/tool.js";
30
27
  import { filteredTools } from "./tools.js";
31
- var backendDebug = debug("pw:mcp:backend");
28
+ import { browserServerBackendDebug, logUnhandledError } from "./utils/log.js";
29
+ import { packageJSON } from "./utils/package.js";
32
30
 
33
31
  class BrowserServerBackend {
34
32
  name = "Playwright";
@@ -79,14 +77,14 @@ class BrowserServerBackend {
79
77
  throw new Error(`Tool not found: ${schema.name}`);
80
78
  }
81
79
  context.setRunningTool(true);
82
- backendDebug(`Executing tool: ${schema.name}`);
80
+ browserServerBackendDebug(`Executing tool: ${schema.name}`);
83
81
  try {
84
82
  await matchedTool.handle(context, parsedArguments, response);
85
83
  await response.finish();
86
84
  this._sessionLog?.logResponse(response);
87
- backendDebug(`Tool ${schema.name} completed successfully`);
85
+ browserServerBackendDebug(`Tool ${schema.name} completed successfully`);
88
86
  } catch (error) {
89
- backendDebug(`Error executing tool ${schema.name}:`, error);
87
+ browserServerBackendDebug(`Error executing tool ${schema.name}:`, error);
90
88
  response.addError(String(error));
91
89
  } finally {
92
90
  context.setRunningTool(false);
package/lib/config.js CHANGED
@@ -22,7 +22,7 @@ import { promises as fsPromises } from "node:fs";
22
22
  import { platform, tmpdir } from "node:os";
23
23
  import { join as pathJoin } from "node:path";
24
24
  import { devices } from "playwright";
25
- import { sanitizeForFilePath } from "./utils.js";
25
+ import { sanitizeForFilePath } from "./utils/guid.js";
26
26
  var defaultConfig = {
27
27
  browser: {
28
28
  browserName: "chromium",
package/lib/context.js CHANGED
@@ -18,13 +18,10 @@ var __toESM = (mod, isNodeMode, target) => {
18
18
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
19
 
20
20
  // src/context.ts
21
- import debug from "debug";
22
21
  import { BatchExecutor } from "./batch/batch-executor.js";
23
22
  import { outputFile } from "./config.js";
24
- import { logUnhandledError } from "./log.js";
25
23
  import { Tab } from "./tab.js";
26
- var testDebug = debug("pw:mcp:test");
27
- var contextDebug = debug("pw:mcp:context");
24
+ import { contextDebug, logUnhandledError, testDebug } from "./utils/log.js";
28
25
 
29
26
  class Context {
30
27
  tools;
@@ -19,6 +19,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
19
 
20
20
  // src/diagnostics/common/error-enrichment-utils.ts
21
21
  import { deduplicateAndLimit } from "../../utils/array-utils.js";
22
+ import { errorEnrichmentDebug } from "../../utils/log.js";
22
23
  var errorPatterns = new Map([
23
24
  [
24
25
  /timeout/i,
@@ -101,11 +102,11 @@ function generateSuggestions(error, context) {
101
102
  }
102
103
  return deduplicateAndLimit(suggestions, 5);
103
104
  }
104
- async function safeDispose(resource, _resourceType, _operation) {
105
+ async function safeDispose(resource, resourceType, operation) {
105
106
  try {
106
107
  await resource.dispose();
107
108
  } catch (error) {
108
- console.warn(`Failed to dispose ${_resourceType} during ${_operation}:`, error);
109
+ errorEnrichmentDebug(`Failed to dispose ${resourceType} during ${operation}:`, error);
109
110
  }
110
111
  }
111
112
  async function safeDisposeAll(resources, resourceType, operation) {