@wdio/mcp 3.2.0 → 3.2.1

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/lib/server.js CHANGED
@@ -46,7 +46,7 @@ var package_default = {
46
46
  type: "git",
47
47
  url: "git://github.com/webdriverio/mcp.git"
48
48
  },
49
- version: "3.1.1",
49
+ version: "3.2.0",
50
50
  description: "MCP server with WebdriverIO for browser and mobile app automation (iOS/Android via Appium)",
51
51
  main: "./lib/server.js",
52
52
  module: "./lib/server.js",
@@ -3244,13 +3244,17 @@ var localAppiumProvider = new LocalAppiumProvider();
3244
3244
 
3245
3245
  // src/providers/cloud/browserstack.provider.ts
3246
3246
  import { promisify } from "util";
3247
+ import { tmpdir as tmpdir2 } from "os";
3248
+ import { join as join2 } from "path";
3247
3249
  import { Local as BrowserstackTunnel } from "browserstack-local";
3248
3250
  var BrowserStackProvider = class {
3249
3251
  name = "browserstack";
3250
- getConnectionConfig(_options) {
3252
+ getConnectionConfig(options) {
3253
+ const platform2 = options.platform;
3254
+ const hostname = platform2 === "browser" ? "hub.browserstack.com" : "hub-cloud.browserstack.com";
3251
3255
  return {
3252
3256
  protocol: "https",
3253
- hostname: "hub.browserstack.com",
3257
+ hostname,
3254
3258
  port: 443,
3255
3259
  path: "/wd/hub",
3256
3260
  user: process.env.BROWSERSTACK_USERNAME,
@@ -3316,9 +3320,10 @@ var BrowserStackProvider = class {
3316
3320
  const tunnel = new BrowserstackTunnel();
3317
3321
  const start = promisify(tunnel.start.bind(tunnel));
3318
3322
  try {
3319
- await start({ key });
3323
+ const logFile = join2(tmpdir2(), "browserstack-local.log");
3324
+ await start({ key, forceLocal: true, logFile });
3320
3325
  } catch (e) {
3321
- const msg = e instanceof Error ? e.message : String(e);
3326
+ const msg = (e !== null && typeof e === "object" ? e.message : void 0) ?? String(e);
3322
3327
  if (msg.includes("another browserstack local client is running") || msg.includes("server is listening on port")) {
3323
3328
  console.error("[BrowserStack] Tunnel already running \u2014 reusing existing tunnel");
3324
3329
  return null;
@@ -3477,7 +3482,7 @@ var startSessionToolDefinition = {
3477
3482
  port: z14.number().optional(),
3478
3483
  path: z14.string().optional()
3479
3484
  }).optional().describe("Appium server connection (local provider only)"),
3480
- browserstackLocal: coerceBoolean.optional().default(false).describe("Enable BrowserStack Local tunnel for testing against local/internal URLs (BrowserStack only, default: false). When true, the tunnel is started automatically before the session and stopped when the session is closed."),
3485
+ browserstackLocal: z14.union([coerceBoolean, z14.literal("external")]).optional().default(false).describe('Enable BrowserStack Local tunnel routing (BrowserStack only, default: false). true = auto-start tunnel before session and stop on close. "external" = tunnel already running externally, set local: true in capabilities only.'),
3481
3486
  navigationUrl: z14.string().optional().describe("URL to navigate to after starting"),
3482
3487
  capabilities: z14.record(z14.string(), z14.unknown()).optional().describe("Additional capabilities to merge")
3483
3488
  }
@@ -3563,7 +3568,7 @@ async function startBrowserSession(args) {
3563
3568
  windowHeight,
3564
3569
  capabilities: userCapabilities
3565
3570
  });
3566
- const tunnelHandle = args.browserstackLocal ? await provider.startTunnel?.(args) : void 0;
3571
+ const tunnelHandle = args.browserstackLocal === true ? await provider.startTunnel?.(args) : void 0;
3567
3572
  const wdioBrowser = await remote({ ...connectionConfig, capabilities: mergedCapabilities });
3568
3573
  const { sessionId } = wdioBrowser;
3569
3574
  const sessionMetadata = {
@@ -3613,7 +3618,7 @@ async function startMobileSession(args) {
3613
3618
  const provider = getProvider(args.provider ?? "local", args.platform);
3614
3619
  const serverConfig = provider.getConnectionConfig(args);
3615
3620
  const mergedCapabilities = provider.buildCapabilities(args);
3616
- const tunnelHandle = args.browserstackLocal ? await provider.startTunnel?.(args) : void 0;
3621
+ const tunnelHandle = args.browserstackLocal === true ? await provider.startTunnel?.(args) : void 0;
3617
3622
  const browser = await remote({ ...serverConfig, capabilities: mergedCapabilities });
3618
3623
  const { sessionId } = browser;
3619
3624
  const shouldAutoDetach = provider.shouldAutoDetach(args);