mobile-debug-mcp 0.12.6 → 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,13 +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
- const response = {
394
- device: res.device,
395
- appStarted: res.appStarted,
396
- launchTimeMs: res.launchTimeMs
397
- };
398
- 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
+ }
399
423
  }
400
424
  if (name === "terminate_app") {
401
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.6",
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,13 +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
- const response: StartAppResponse = {
417
- device: res.device,
418
- appStarted: res.appStarted,
419
- launchTimeMs: res.launchTimeMs
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 } })
420
439
  }
421
- return wrapResponse(response)
422
440
  }
423
441
 
424
442
  if (name === "terminate_app") {