byclaw-mcp 0.4.14 → 0.4.15
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/index.js +32 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53,16 +53,43 @@ function imageUrlOf(p) {
|
|
|
53
53
|
const url = typeof p?.image_url === 'string' ? p.image_url.trim() : '';
|
|
54
54
|
return url.startsWith('https://') || url.startsWith('http://') ? url : IMAGE_FALLBACK;
|
|
55
55
|
}
|
|
56
|
+
// Hard cap on every backend request. Without it, if the backend is wedged
|
|
57
|
+
// (Anthropic 503 + SDK retry storm, ES lock, …) the MCP process would hang
|
|
58
|
+
// forever and the client (Claude Desktop) would only break out at its own
|
|
59
|
+
// 4 min cap with a "Server disconnected" disconnect — the very symptom
|
|
60
|
+
// Finding 094 described. 60 s is comfortably above normal backend latency
|
|
61
|
+
// (10-15 s for /api/mcp/shop) but below the client timeout, so the user
|
|
62
|
+
// gets a real error message instead of a stall.
|
|
63
|
+
const BACKEND_TIMEOUT_MS = 60000;
|
|
56
64
|
async function apiCall(path, options = {}) {
|
|
57
65
|
const headers = {
|
|
58
66
|
'Authorization': `Bearer ${API_KEY}`,
|
|
59
67
|
'Content-Type': 'application/json',
|
|
60
68
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
try {
|
|
70
|
+
const res = await fetch(`${API_BASE}${path}`, {
|
|
71
|
+
...options,
|
|
72
|
+
signal: AbortSignal.timeout(BACKEND_TIMEOUT_MS),
|
|
73
|
+
headers: { ...headers, ...options.headers },
|
|
74
|
+
});
|
|
75
|
+
return res.json();
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// AbortError fires when the timeout above kicks in. Translate to an
|
|
79
|
+
// ok=false body the existing call sites already know how to print.
|
|
80
|
+
if (err?.name === 'AbortError' || err?.name === 'TimeoutError') {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
error: `Backend timeout after ${BACKEND_TIMEOUT_MS / 1000}s (${path})`,
|
|
84
|
+
retryable: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
ok: false,
|
|
89
|
+
error: `Backend request failed: ${err?.message || 'unknown error'} (${path})`,
|
|
90
|
+
retryable: false,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
66
93
|
}
|
|
67
94
|
const server = new index_js_1.Server({ name: 'byclaw', version: SERVER_VERSION }, { capabilities: { tools: {}, prompts: {} } });
|
|
68
95
|
// Prompts
|
package/package.json
CHANGED