smart-image-scraper-mcp 2.12.1 → 2.12.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/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -224,13 +224,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
224
224
|
})
|
|
225
225
|
]);
|
|
226
226
|
clearTimeout(mcpTimeoutId);
|
|
227
|
+
orchestrator.cleanup();
|
|
227
228
|
return result;
|
|
228
229
|
} catch (error) {
|
|
229
230
|
clearTimeout(mcpTimeoutId);
|
|
230
|
-
|
|
231
|
-
if (orchestrator.abortController && !orchestrator.abortController.signal.aborted) {
|
|
232
|
-
orchestrator.abortController.abort();
|
|
233
|
-
}
|
|
231
|
+
orchestrator.cleanup();
|
|
234
232
|
console.error(`[MCP Error] ${error.message}`);
|
|
235
233
|
return {
|
|
236
234
|
content: [{
|
|
@@ -13,14 +13,14 @@ import logger from './logger.js';
|
|
|
13
13
|
// MCP 每次调用独立,keepalive 复用收益小,反而导致连接池堵塞
|
|
14
14
|
const httpAgent = new http.Agent({
|
|
15
15
|
keepAlive: false, // 禁用 Keep-Alive,用完立即释放
|
|
16
|
-
maxSockets:
|
|
16
|
+
maxSockets: Infinity, // 不限制并发(keepAlive=false 时每个 socket 短命)
|
|
17
17
|
maxFreeSockets: 0, // 不保留空闲连接
|
|
18
18
|
scheduling: 'fifo', // 先进先出,公平分配
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const httpsAgent = new https.Agent({
|
|
22
22
|
keepAlive: false, // 禁用 Keep-Alive
|
|
23
|
-
maxSockets:
|
|
23
|
+
maxSockets: Infinity, // 不限制并发
|
|
24
24
|
maxFreeSockets: 0,
|
|
25
25
|
scheduling: 'fifo',
|
|
26
26
|
rejectUnauthorized: false, // 允许自签名证书
|
|
@@ -35,6 +35,21 @@ export class Orchestrator {
|
|
|
35
35
|
this.abortController = null; // 用于取消正在进行的操作
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* 清理资源,防止内存泄漏
|
|
40
|
+
*/
|
|
41
|
+
cleanup() {
|
|
42
|
+
if (this.abortController) {
|
|
43
|
+
if (!this.abortController.signal.aborted) {
|
|
44
|
+
this.abortController.abort();
|
|
45
|
+
}
|
|
46
|
+
this.abortController = null;
|
|
47
|
+
}
|
|
48
|
+
this.linkValidator = null;
|
|
49
|
+
this.fileManager = null;
|
|
50
|
+
this.imageProcessor = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
/**
|
|
39
54
|
* 解析关键词字符串
|
|
40
55
|
* @param {string} query - 关键词字符串(逗号分隔)
|