metro-mcp 0.5.1 → 0.5.2
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/bin/metro-mcp.js
CHANGED
|
@@ -129,7 +129,7 @@ class CDPClient {
|
|
|
129
129
|
suppressReconnect = false;
|
|
130
130
|
_isConnected = false;
|
|
131
131
|
target = null;
|
|
132
|
-
|
|
132
|
+
lastPingAt = 0;
|
|
133
133
|
requestTimeout = 1e4;
|
|
134
134
|
keepAliveInterval = 1e4;
|
|
135
135
|
async connect(target) {
|
|
@@ -165,7 +165,7 @@ class CDPClient {
|
|
|
165
165
|
const socketForThisConnection = this.ws;
|
|
166
166
|
this.ws.on("open", () => {
|
|
167
167
|
this._isConnected = true;
|
|
168
|
-
this.
|
|
168
|
+
this.lastPingAt = Date.now();
|
|
169
169
|
this.startKeepAlive();
|
|
170
170
|
logger2.info(`Connected to ${this.target?.title || "unknown"}`);
|
|
171
171
|
resolve();
|
|
@@ -191,12 +191,9 @@ class CDPClient {
|
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
193
|
this.ws.on("ping", () => {
|
|
194
|
+
this.lastPingAt = Date.now();
|
|
194
195
|
logger2.debug("Received ping from Metro");
|
|
195
196
|
});
|
|
196
|
-
this.ws.on("pong", () => {
|
|
197
|
-
this.pongReceived = true;
|
|
198
|
-
logger2.debug("Received pong from Metro");
|
|
199
|
-
});
|
|
200
197
|
} catch (err) {
|
|
201
198
|
reject(err);
|
|
202
199
|
}
|
|
@@ -246,24 +243,16 @@ class CDPClient {
|
|
|
246
243
|
}
|
|
247
244
|
startKeepAlive() {
|
|
248
245
|
this.stopKeepAlive();
|
|
249
|
-
let missedKeepAlives = 0;
|
|
250
246
|
this.keepAliveTimer = setInterval(() => {
|
|
251
247
|
if (!this._isConnected || !this.ws)
|
|
252
248
|
return;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
} catch {}
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
missedKeepAlives = 0;
|
|
249
|
+
const elapsed = Date.now() - this.lastPingAt;
|
|
250
|
+
if (elapsed > 20000) {
|
|
251
|
+
logger2.warn(`No ping received from Metro in ${elapsed}ms — closing connection`);
|
|
252
|
+
try {
|
|
253
|
+
this.ws.close();
|
|
254
|
+
} catch {}
|
|
264
255
|
}
|
|
265
|
-
this.pongReceived = false;
|
|
266
|
-
this.ws.ping();
|
|
267
256
|
}, this.keepAliveInterval);
|
|
268
257
|
}
|
|
269
258
|
stopKeepAlive() {
|
|
@@ -525,12 +514,12 @@ function extractCDPExceptionMessage(details, fallback = "Evaluation failed") {
|
|
|
525
514
|
// package.json
|
|
526
515
|
var package_default = {
|
|
527
516
|
name: "metro-mcp",
|
|
528
|
-
version: "0.5.
|
|
517
|
+
version: "0.5.2",
|
|
529
518
|
description: "Plugin-based MCP server for React Native/Expo runtime debugging, inspection, and automation via Metro/CDP",
|
|
530
519
|
homepage: "https://github.com/steve228uk/metro-mcp",
|
|
531
520
|
repository: {
|
|
532
521
|
type: "git",
|
|
533
|
-
url: "https://github.com/steve228uk/metro-mcp.git"
|
|
522
|
+
url: "git+https://github.com/steve228uk/metro-mcp.git"
|
|
534
523
|
},
|
|
535
524
|
bugs: {
|
|
536
525
|
url: "https://github.com/steve228uk/metro-mcp/issues"
|
|
@@ -4894,7 +4883,12 @@ var statuslinePlugin = definePlugin({
|
|
|
4894
4883
|
name: "statusline",
|
|
4895
4884
|
description: "Writes CDP connection state to a file for Claude Code status bar integration",
|
|
4896
4885
|
async setup(ctx) {
|
|
4897
|
-
|
|
4886
|
+
let lastConnected = null;
|
|
4887
|
+
function write() {
|
|
4888
|
+
const connected = ctx.cdp.isConnected();
|
|
4889
|
+
if (connected === lastConnected)
|
|
4890
|
+
return;
|
|
4891
|
+
lastConnected = connected;
|
|
4898
4892
|
const target = ctx.cdp.getTarget();
|
|
4899
4893
|
writeStatus({
|
|
4900
4894
|
connected,
|
|
@@ -4904,9 +4898,10 @@ var statuslinePlugin = definePlugin({
|
|
|
4904
4898
|
updatedAt: Date.now()
|
|
4905
4899
|
});
|
|
4906
4900
|
}
|
|
4907
|
-
ctx.cdp.on("reconnected",
|
|
4908
|
-
ctx.cdp.on("disconnected",
|
|
4909
|
-
write
|
|
4901
|
+
ctx.cdp.on("reconnected", write);
|
|
4902
|
+
ctx.cdp.on("disconnected", write);
|
|
4903
|
+
setInterval(write, 5000);
|
|
4904
|
+
write();
|
|
4910
4905
|
ctx.registerTool("setup_statusline", {
|
|
4911
4906
|
description: "Writes the Metro CDP connection status script to ~/.claude/metro-mcp-statusline.sh. " + "Does not modify settings.json — tell the user to add it to their status line themselves " + '(e.g. ask Claude: "/statusline add the script at ~/.claude/metro-mcp-statusline.sh"). ' + "Only works with Claude Code.",
|
|
4912
4907
|
parameters: z19.object({}),
|
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ class CDPClient {
|
|
|
137
137
|
suppressReconnect = false;
|
|
138
138
|
_isConnected = false;
|
|
139
139
|
target = null;
|
|
140
|
-
|
|
140
|
+
lastPingAt = 0;
|
|
141
141
|
requestTimeout = 1e4;
|
|
142
142
|
keepAliveInterval = 1e4;
|
|
143
143
|
async connect(target) {
|
|
@@ -173,7 +173,7 @@ class CDPClient {
|
|
|
173
173
|
const socketForThisConnection = this.ws;
|
|
174
174
|
this.ws.on("open", () => {
|
|
175
175
|
this._isConnected = true;
|
|
176
|
-
this.
|
|
176
|
+
this.lastPingAt = Date.now();
|
|
177
177
|
this.startKeepAlive();
|
|
178
178
|
logger2.info(`Connected to ${this.target?.title || "unknown"}`);
|
|
179
179
|
resolve();
|
|
@@ -199,12 +199,9 @@ class CDPClient {
|
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
this.ws.on("ping", () => {
|
|
202
|
+
this.lastPingAt = Date.now();
|
|
202
203
|
logger2.debug("Received ping from Metro");
|
|
203
204
|
});
|
|
204
|
-
this.ws.on("pong", () => {
|
|
205
|
-
this.pongReceived = true;
|
|
206
|
-
logger2.debug("Received pong from Metro");
|
|
207
|
-
});
|
|
208
205
|
} catch (err) {
|
|
209
206
|
reject(err);
|
|
210
207
|
}
|
|
@@ -254,24 +251,16 @@ class CDPClient {
|
|
|
254
251
|
}
|
|
255
252
|
startKeepAlive() {
|
|
256
253
|
this.stopKeepAlive();
|
|
257
|
-
let missedKeepAlives = 0;
|
|
258
254
|
this.keepAliveTimer = setInterval(() => {
|
|
259
255
|
if (!this._isConnected || !this.ws)
|
|
260
256
|
return;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
} catch {}
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
} else {
|
|
271
|
-
missedKeepAlives = 0;
|
|
257
|
+
const elapsed = Date.now() - this.lastPingAt;
|
|
258
|
+
if (elapsed > 20000) {
|
|
259
|
+
logger2.warn(`No ping received from Metro in ${elapsed}ms — closing connection`);
|
|
260
|
+
try {
|
|
261
|
+
this.ws.close();
|
|
262
|
+
} catch {}
|
|
272
263
|
}
|
|
273
|
-
this.pongReceived = false;
|
|
274
|
-
this.ws.ping();
|
|
275
264
|
}, this.keepAliveInterval);
|
|
276
265
|
}
|
|
277
266
|
stopKeepAlive() {
|
|
@@ -533,12 +522,12 @@ function extractCDPExceptionMessage(details, fallback = "Evaluation failed") {
|
|
|
533
522
|
// package.json
|
|
534
523
|
var package_default = {
|
|
535
524
|
name: "metro-mcp",
|
|
536
|
-
version: "0.5.
|
|
525
|
+
version: "0.5.2",
|
|
537
526
|
description: "Plugin-based MCP server for React Native/Expo runtime debugging, inspection, and automation via Metro/CDP",
|
|
538
527
|
homepage: "https://github.com/steve228uk/metro-mcp",
|
|
539
528
|
repository: {
|
|
540
529
|
type: "git",
|
|
541
|
-
url: "https://github.com/steve228uk/metro-mcp.git"
|
|
530
|
+
url: "git+https://github.com/steve228uk/metro-mcp.git"
|
|
542
531
|
},
|
|
543
532
|
bugs: {
|
|
544
533
|
url: "https://github.com/steve228uk/metro-mcp/issues"
|
|
@@ -4897,7 +4886,12 @@ var statuslinePlugin = definePlugin({
|
|
|
4897
4886
|
name: "statusline",
|
|
4898
4887
|
description: "Writes CDP connection state to a file for Claude Code status bar integration",
|
|
4899
4888
|
async setup(ctx) {
|
|
4900
|
-
|
|
4889
|
+
let lastConnected = null;
|
|
4890
|
+
function write() {
|
|
4891
|
+
const connected = ctx.cdp.isConnected();
|
|
4892
|
+
if (connected === lastConnected)
|
|
4893
|
+
return;
|
|
4894
|
+
lastConnected = connected;
|
|
4901
4895
|
const target = ctx.cdp.getTarget();
|
|
4902
4896
|
writeStatus({
|
|
4903
4897
|
connected,
|
|
@@ -4907,9 +4901,10 @@ var statuslinePlugin = definePlugin({
|
|
|
4907
4901
|
updatedAt: Date.now()
|
|
4908
4902
|
});
|
|
4909
4903
|
}
|
|
4910
|
-
ctx.cdp.on("reconnected",
|
|
4911
|
-
ctx.cdp.on("disconnected",
|
|
4912
|
-
write
|
|
4904
|
+
ctx.cdp.on("reconnected", write);
|
|
4905
|
+
ctx.cdp.on("disconnected", write);
|
|
4906
|
+
setInterval(write, 5000);
|
|
4907
|
+
write();
|
|
4913
4908
|
ctx.registerTool("setup_statusline", {
|
|
4914
4909
|
description: "Writes the Metro CDP connection status script to ~/.claude/metro-mcp-statusline.sh. " + "Does not modify settings.json — tell the user to add it to their status line themselves " + '(e.g. ask Claude: "/statusline add the script at ~/.claude/metro-mcp-statusline.sh"). ' + "Only works with Claude Code.",
|
|
4915
4910
|
parameters: z19.object({}),
|
|
@@ -19,7 +19,7 @@ export declare class CDPClient implements CDPConnection {
|
|
|
19
19
|
private suppressReconnect;
|
|
20
20
|
private _isConnected;
|
|
21
21
|
private target;
|
|
22
|
-
private
|
|
22
|
+
private lastPingAt;
|
|
23
23
|
private readonly requestTimeout;
|
|
24
24
|
private readonly keepAliveInterval;
|
|
25
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/metro/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAA2B,WAAW,EAAE,MAAM,YAAY,CAAC;AAMvE,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAQjE;;;;;;;GAOG;AACH,qBAAa,SAAU,YAAW,aAAa;IAC7C,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,aAAa,CAA2C;IAChE,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/metro/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAA2B,WAAW,EAAE,MAAM,YAAY,CAAC;AAMvE,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAQjE;;;;;;;GAOG;AACH,qBAAa,SAAU,YAAW,aAAa;IAC7C,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,aAAa,CAA2C;IAChE,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,UAAU,CAAK;IAEvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAE3C;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ3C,OAAO,CAAC,SAAS;IAwDjB;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB9E;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAOjD;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAIlD;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,SAAS,IAAI,WAAW,GAAG,IAAI;IAI/B;;OAEG;IACH,UAAU,IAAI,IAAI;IAWlB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,aAAa;IAuCrB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,IAAI;CAYb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusline.d.ts","sourceRoot":"","sources":["../../src/plugins/statusline.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AA4CxD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"statusline.d.ts","sourceRoot":"","sources":["../../src/plugins/statusline.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AA4CxD,eAAO,MAAM,gBAAgB,yCAiD3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Plugin-based MCP server for React Native/Expo runtime debugging, inspection, and automation via Metro/CDP",
|
|
5
5
|
"homepage": "https://github.com/steve228uk/metro-mcp",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/steve228uk/metro-mcp.git"
|
|
8
|
+
"url": "git+https://github.com/steve228uk/metro-mcp.git"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/steve228uk/metro-mcp/issues"
|