mobile-mcp-server 1.0.3 → 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 +1 -1
- package/proxy_client.js +20 -1
package/package.json
CHANGED
package/proxy_client.js
CHANGED
|
@@ -70,7 +70,26 @@ async function forwardRequest(request) {
|
|
|
70
70
|
throw new Error(errorMessage);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
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
|
+
}
|
|
74
93
|
|
|
75
94
|
// 🛡️ CRITICAL: Ensure we return a spec-compliant ID
|
|
76
95
|
// If the server returned id: null but we have a valid request ID, fix it before sending to Claude
|