Skip to content

Mobile MCP: let AI agents drive your iOS and Android apps. MCP server for simulators, emulators and real devices. Works with Claude Code, Codex, Cursor and any MCP client.

fix: catch system signals for clean v8 exit (#366)

Gil Megidishd647ed00baef
diff --git a/.c8rc.json b/.c8rc.json
index a09091a..fcf53a5 100644
--- a/.c8rc.json
+++ b/.c8rc.json
@@ -1,6 +1,6 @@
{
- "all": true,
- "src": ["src"],
- "include": ["src/**/*.ts"],
- "reporter": ["text", "html"]
+ "include": ["lib/**/*.js"],
+ "exclude": ["node_modules/**", "lib/**/*.js.map"],
+ "reporter": ["html", "text"],
+ "temp-directory": "./coverage/tmp"
}
diff --git a/src/index.ts b/src/index.ts
index 1fc6593..d851fdf 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -76,6 +76,17 @@ const startStdioServer = async () => {
const server = createMcpServer();
await server.connect(transport);
+ // Exit cleanly on termination signals so node flushes pending work
+ // (including NODE_V8_COVERAGE output). Node's default SIGINT/SIGTERM
+ // handling terminates the process without writing the coverage file,
+ // which makes the `test:mcp` report come back all zeros.
+ const shutdown = () => {
+ process.exit(0);
+ };
+
+ process.on("SIGINT", shutdown);
+ process.on("SIGTERM", shutdown);
+
error("mobile-mcp server running on stdio");
} catch (err: any) {
console.error("Fatal error in main():", err);
diff --git a/src/mobilecli.ts b/src/mobilecli.ts
index 083ff5c..f5394f8 100644
--- a/src/mobilecli.ts
+++ b/src/mobilecli.ts
@@ -34,16 +34,24 @@ export interface MobilecliDevicesOptions {
type?: "real" | "emulator" | "simulator";
}
+export interface MobilecliDeviceProvider {
+ type: string; // e.g. "mobilefleet" for remote devices
+ allocationId?: string;
+}
+
+export interface MobilecliDevice {
+ id: string;
+ name: string;
+ platform: "android" | "ios";
+ type: "real" | "emulator" | "simulator";
+ version: string;
+ provider?: MobilecliDeviceProvider;
+}
+
export interface MobilecliDevicesResponse {
status: "ok";
data: {
- devices: Array<{
- id: string;
- name: string;
- platform: "android" | "ios";
- type: "real" | "emulator" | "simulator";
- version: string;
- }>;
+ devices: MobilecliDevice[];
};
}