mobile-mcp-server 1.0.1 → 1.0.4
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 +2 -2
- package/proxy_client.js +21 -1
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobile-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "MCP server for Android emulator and Appium mobile automation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/server.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mobile-mcp": "./dist/bin.js"
|
|
8
|
+
"mobile-mcp-server": "./dist/bin.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
package/proxy_client.js
CHANGED
|
@@ -52,6 +52,7 @@ async function forwardRequest(request) {
|
|
|
52
52
|
method: "POST",
|
|
53
53
|
headers: {
|
|
54
54
|
"Content-Type": "application/json",
|
|
55
|
+
"Accept": "application/json, text/event-stream",
|
|
55
56
|
"x-mcp-key": API_KEY
|
|
56
57
|
},
|
|
57
58
|
body: JSON.stringify(request)
|
|
@@ -69,7 +70,26 @@ async function forwardRequest(request) {
|
|
|
69
70
|
throw new Error(errorMessage);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const
|
|
73
|
+
const text = await response.text();
|
|
74
|
+
let jsonResponse;
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
// 1. Try to parse as raw JSON first
|
|
78
|
+
jsonResponse = JSON.parse(text);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// 2. If it fails, check if it's an SSE "event: message" stream
|
|
81
|
+
const match = text.match(/data: (\{.*\})/);
|
|
82
|
+
if (match) {
|
|
83
|
+
try {
|
|
84
|
+
jsonResponse = JSON.parse(match[1]);
|
|
85
|
+
} catch (innerE) {
|
|
86
|
+
throw new Error(`Invalid JSON inside SSE data: ${innerE.message}`);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// Not JSON and not SSE - throw the original parse error
|
|
90
|
+
throw new Error(`${e.message} (Raw: ${text.substring(0, 100)})`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
73
93
|
|
|
74
94
|
// 🛡️ CRITICAL: Ensure we return a spec-compliant ID
|
|
75
95
|
// If the server returned id: null but we have a valid request ID, fix it before sending to Claude
|