@aiwerk/mcp-bridge 2.7.2 → 2.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiwerk/mcp-bridge",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Standalone MCP server that multiplexes multiple MCP servers into one interface",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -317,7 +317,32 @@ elif [[ -f "$ENV_VARS_FILE" ]] && [[ -s "$ENV_VARS_FILE" ]]; then
317
317
  ENV_VAR_NAME="$(head -n 1 "$ENV_VARS_FILE" | tr -d '[:space:]')"
318
318
  fi
319
319
 
320
- if [[ -n "$ENV_VAR_NAME" ]]; then
320
+ # Check if this is an OAuth2 Authorization Code server (browser login, not API key)
321
+ OAUTH2_AUTH_CODE="false"
322
+ if [[ "$RECIPE_FORMAT" == "v2" ]]; then
323
+ OAUTH2_AUTH_CODE=$(python3 -c "
324
+ import json, sys
325
+ with open(sys.argv[1]) as f:
326
+ r = json.load(f)
327
+ auth = r.get('auth', {})
328
+ # OAuth2 auth code: explicitly requires grantType=authorization_code
329
+ # and no envVars (login via browser, not API key)
330
+ if auth.get('type') == 'oauth2' and auth.get('grantType') == 'authorization_code':
331
+ if not auth.get('envVars'):
332
+ print('true')
333
+ else:
334
+ print('false')
335
+ else:
336
+ print('false')
337
+ " "$RECIPE_FILE" 2>/dev/null)
338
+ fi
339
+
340
+ if [[ "$OAUTH2_AUTH_CODE" == "true" ]]; then
341
+ echo ""
342
+ echo "🔐 This server uses OAuth2 browser login (no API key needed)."
343
+ echo "After config is saved, we'll open your browser for authentication."
344
+ SKIP_TOKEN_PROMPT="true"
345
+ elif [[ -n "$ENV_VAR_NAME" ]]; then
321
346
  TOKEN_URL="$(get_token_url)"
322
347
  [[ -n "$TOKEN_URL" ]] && echo "Get your API token here: ${TOKEN_URL}"
323
348
 
@@ -416,7 +441,38 @@ with open(config_path, "w", encoding="utf-8") as f:
416
441
  print(f"✅ Configuration merged for: {server_name} (recipe {recipe_format})")
417
442
  PY
418
443
 
419
- # 5. Gateway restart
444
+ # 5. OAuth2 browser login (if applicable)
445
+ if [[ "$OAUTH2_AUTH_CODE" == "true" ]]; then
446
+ echo ""
447
+ echo "🔐 Starting OAuth2 login for ${SERVER_TITLE}..."
448
+
449
+ # Find the mcp-bridge CLI
450
+ MCP_BRIDGE_BIN=""
451
+ if command -v mcp-bridge &>/dev/null; then
452
+ MCP_BRIDGE_BIN="mcp-bridge"
453
+ elif [[ -x "$(dirname "$0")/../dist/bin/mcp-bridge.js" ]]; then
454
+ MCP_BRIDGE_BIN="node $(dirname "$0")/../dist/bin/mcp-bridge.js"
455
+ elif command -v npx &>/dev/null; then
456
+ MCP_BRIDGE_BIN="npx @aiwerk/mcp-bridge"
457
+ fi
458
+
459
+ if [[ -n "$MCP_BRIDGE_BIN" ]]; then
460
+ # Detect if we have a browser available
461
+ if command -v xdg-open &>/dev/null || command -v open &>/dev/null || command -v wslview &>/dev/null; then
462
+ echo "Opening browser for authentication..."
463
+ $MCP_BRIDGE_BIN auth login "$SERVER_NAME"
464
+ else
465
+ echo "No browser detected (headless environment)."
466
+ echo "Using device code flow — follow the instructions below:"
467
+ $MCP_BRIDGE_BIN auth login "$SERVER_NAME" --device-code
468
+ fi
469
+ else
470
+ echo "⚠️ mcp-bridge CLI not found. Run manually after install:"
471
+ echo " mcp-bridge auth login ${SERVER_NAME}"
472
+ fi
473
+ fi
474
+
475
+ # 6. Gateway restart
420
476
  echo ""
421
477
  echo "✅ ${SERVER_TITLE} MCP Server installed."
422
478
  echo "Restart mcp-bridge to pick up the new server configuration."