mobile-debug-mcp 0.12.7 → 0.12.8

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/server.js CHANGED
@@ -389,17 +389,37 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
389
389
  try {
390
390
  if (name === "start_app") {
391
391
  const { platform, appId, deviceId } = args;
392
- const res = await (platform === 'android' ? new AndroidManage().startApp(appId, deviceId) : new iOSManage().startApp(appId, deviceId));
393
- // Preserve diagnostics and instrumentation from platform managers so agents receive full context
394
- const response = {
395
- device: res.device,
396
- appStarted: res.appStarted,
397
- launchTimeMs: res.launchTimeMs,
398
- error: res.error,
399
- diagnostics: res.diagnostics,
400
- instrumentation: res.instrumentation
401
- };
402
- return wrapResponse(response);
392
+ // Defensive validation: ensure required args are present and log malformed requests
393
+ if (!platform || !appId) {
394
+ try {
395
+ require('fs').appendFileSync('/tmp/mcp_bad_requests.log', JSON.stringify({ ts: new Date().toISOString(), tool: 'start_app', args }) + '\n');
396
+ }
397
+ catch (e) { }
398
+ const deviceFallback = { platform: platform || 'ios', id: deviceId || 'unknown', osVersion: '', model: '', simulator: true };
399
+ const response = { device: deviceFallback, appStarted: false, launchTimeMs: 0, error: 'Missing required argument: platform and/or appId', diagnostics: { receivedArgs: args } };
400
+ return wrapResponse(response);
401
+ }
402
+ try {
403
+ const res = await (platform === 'android' ? new AndroidManage().startApp(appId, deviceId) : new iOSManage().startApp(appId, deviceId));
404
+ // Preserve diagnostics and instrumentation from platform managers so agents receive full context
405
+ const response = {
406
+ device: res.device,
407
+ appStarted: res.appStarted,
408
+ launchTimeMs: res.launchTimeMs,
409
+ error: res.error,
410
+ diagnostics: res.diagnostics,
411
+ instrumentation: res.instrumentation
412
+ };
413
+ return wrapResponse(response);
414
+ }
415
+ catch (err) {
416
+ try {
417
+ require('fs').appendFileSync('/tmp/mcp_bad_requests.log', JSON.stringify({ ts: new Date().toISOString(), tool: 'start_app', args, error: err && err.message ? err.message : String(err) }) + '\n');
418
+ }
419
+ catch (e) { }
420
+ const deviceFallback = { platform: platform || 'ios', id: deviceId || 'unknown', osVersion: '', model: '', simulator: true };
421
+ return wrapResponse({ device: deviceFallback, appStarted: false, launchTimeMs: 0, error: err instanceof Error ? err.message : String(err), diagnostics: { receivedArgs: args } });
422
+ }
403
423
  }
404
424
  if (name === "terminate_app") {
405
425
  const { platform, appId, deviceId } = args;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-debug-mcp",
3
- "version": "0.12.7",
3
+ "version": "0.12.8",
4
4
  "description": "MCP server for mobile app debugging (Android + iOS), with focus on security and reliability",
5
5
  "type": "module",
6
6
  "bin": {
package/src/server.ts CHANGED
@@ -412,17 +412,31 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
412
412
  try {
413
413
  if (name === "start_app") {
414
414
  const { platform, appId, deviceId } = args as any
415
- const res = await (platform === 'android' ? new AndroidManage().startApp(appId, deviceId) : new iOSManage().startApp(appId, deviceId))
416
- // Preserve diagnostics and instrumentation from platform managers so agents receive full context
417
- const response: StartAppResponse = {
418
- device: res.device,
419
- appStarted: res.appStarted,
420
- launchTimeMs: res.launchTimeMs,
421
- error: (res as any).error,
422
- diagnostics: (res as any).diagnostics,
423
- instrumentation: (res as any).instrumentation
415
+ // Defensive validation: ensure required args are present and log malformed requests
416
+ if (!platform || !appId) {
417
+ try { require('fs').appendFileSync('/tmp/mcp_bad_requests.log', JSON.stringify({ ts: new Date().toISOString(), tool: 'start_app', args }) + '\n') } catch (e) {}
418
+ const deviceFallback: any = { platform: platform || 'ios', id: deviceId || 'unknown', osVersion: '', model: '', simulator: true }
419
+ const response: StartAppResponse = { device: deviceFallback, appStarted: false, launchTimeMs: 0, error: 'Missing required argument: platform and/or appId', diagnostics: { receivedArgs: args } }
420
+ return wrapResponse(response)
421
+ }
422
+
423
+ try {
424
+ const res = await (platform === 'android' ? new AndroidManage().startApp(appId, deviceId) : new iOSManage().startApp(appId, deviceId))
425
+ // Preserve diagnostics and instrumentation from platform managers so agents receive full context
426
+ const response: StartAppResponse = {
427
+ device: res.device,
428
+ appStarted: res.appStarted,
429
+ launchTimeMs: res.launchTimeMs,
430
+ error: (res as any).error,
431
+ diagnostics: (res as any).diagnostics,
432
+ instrumentation: (res as any).instrumentation
433
+ }
434
+ return wrapResponse(response)
435
+ } catch (err:any) {
436
+ try { require('fs').appendFileSync('/tmp/mcp_bad_requests.log', JSON.stringify({ ts: new Date().toISOString(), tool: 'start_app', args, error: err && err.message ? err.message : String(err) }) + '\n') } catch (e) {}
437
+ const deviceFallback: any = { platform: platform || 'ios', id: deviceId || 'unknown', osVersion: '', model: '', simulator: true }
438
+ return wrapResponse({ device: deviceFallback, appStarted: false, launchTimeMs: 0, error: err instanceof Error ? err.message : String(err), diagnostics: { receivedArgs: args } })
424
439
  }
425
- return wrapResponse(response)
426
440
  }
427
441
 
428
442
  if (name === "terminate_app") {