@agimon-ai/mcp-proxy 0.10.3 → 0.10.5
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/cli.cjs
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as DefinitionsCacheService, D as version, T as findConfigFile, b as RuntimeStateService, d as StdioHttpTransportHandler, f as StdioTransportHandler, m as HttpTransportHandler, n as createServer, o as createProxyIoCContainer, p as SseTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, v as StopServerService, w as generateServerId } from "./src-
|
|
2
|
+
import { C as DefinitionsCacheService, D as version, T as findConfigFile, b as RuntimeStateService, d as StdioHttpTransportHandler, f as StdioTransportHandler, m as HttpTransportHandler, n as createServer, o as createProxyIoCContainer, p as SseTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, v as StopServerService, w as generateServerId } from "./src-Dv4pMmyW.mjs";
|
|
3
3
|
import { constants, existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { access, writeFile } from "node:fs/promises";
|
|
5
5
|
import yaml from "js-yaml";
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-Bf27zWoI.cjs");
|
|
3
3
|
exports.ConfigFetcherService = require_src.ConfigFetcherService;
|
|
4
4
|
exports.DefinitionsCacheService = require_src.DefinitionsCacheService;
|
|
5
5
|
exports.DescribeToolsTool = require_src.DescribeToolsTool;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as DefinitionsCacheService, E as ConfigFetcherService, S as createProxyLogger, T as findConfigFile, _ as DescribeToolsTool, a as createProxyContainer, b as RuntimeStateService, c as createStdioHttpTransportHandler, d as StdioHttpTransportHandler, f as StdioTransportHandler, g as SearchListToolsTool, h as UseToolTool, i as createHttpTransportHandler, l as createStdioTransportHandler, m as HttpTransportHandler, n as createServer, p as SseTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as StopServerService, w as generateServerId, x as McpClientManagerService, y as SkillService } from "./src-
|
|
1
|
+
import { C as DefinitionsCacheService, E as ConfigFetcherService, S as createProxyLogger, T as findConfigFile, _ as DescribeToolsTool, a as createProxyContainer, b as RuntimeStateService, c as createStdioHttpTransportHandler, d as StdioHttpTransportHandler, f as StdioTransportHandler, g as SearchListToolsTool, h as UseToolTool, i as createHttpTransportHandler, l as createStdioTransportHandler, m as HttpTransportHandler, n as createServer, p as SseTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as StopServerService, w as generateServerId, x as McpClientManagerService, y as SkillService } from "./src-Dv4pMmyW.mjs";
|
|
2
2
|
export { ConfigFetcherService, DefinitionsCacheService, DescribeToolsTool, HttpTransportHandler, McpClientManagerService, RuntimeStateService, SearchListToolsTool, SkillService, SseTransportHandler, StdioHttpTransportHandler, StdioTransportHandler, StopServerService, TRANSPORT_MODE, UseToolTool, createHttpTransportHandler, createProxyContainer, createProxyLogger, createServer, createSessionServer, createSseTransportHandler, createStdioHttpTransportHandler, createStdioTransportHandler, findConfigFile, generateServerId, initializeSharedServices };
|
|
@@ -48,7 +48,7 @@ let _modelcontextprotocol_sdk_server_sse_js = require("@modelcontextprotocol/sdk
|
|
|
48
48
|
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
49
49
|
let _modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/sdk/server/index.js");
|
|
50
50
|
//#region package.json
|
|
51
|
-
var version = "0.10.
|
|
51
|
+
var version = "0.10.5";
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/utils/mcpConfigSchema.ts
|
|
54
54
|
/**
|
|
@@ -1544,14 +1544,17 @@ const PROCESS_REGISTRY_SERVICE_TYPE = "tool";
|
|
|
1544
1544
|
* Checks if an error is a session-related error from an HTTP backend
|
|
1545
1545
|
* (e.g., downstream server restarted and no longer recognizes the session ID).
|
|
1546
1546
|
*/
|
|
1547
|
-
function isSessionError(error) {
|
|
1548
|
-
return getErrorChain(error).some(({ message, code }) => {
|
|
1547
|
+
function isSessionError$1(error) {
|
|
1548
|
+
return getErrorChain$1(error).some(({ message, code }) => {
|
|
1549
1549
|
const normalizedMessage = message.toLowerCase();
|
|
1550
|
-
const normalizedCode = code
|
|
1550
|
+
const normalizedCode = normalizeErrorCode$1(code);
|
|
1551
1551
|
return normalizedMessage.includes("unknown session") || normalizedMessage.includes("session not found") || normalizedMessage.includes("transport closed") || normalizedMessage.includes("connection closed") || normalizedMessage.includes("socket hang up") || normalizedMessage.includes("fetch failed") || normalizedCode === "econnreset";
|
|
1552
1552
|
});
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function normalizeErrorCode$1(code) {
|
|
1555
|
+
return typeof code === "string" ? code.toLowerCase() : void 0;
|
|
1556
|
+
}
|
|
1557
|
+
function getErrorChain$1(error) {
|
|
1555
1558
|
const visited = /* @__PURE__ */ new Set();
|
|
1556
1559
|
const chain = [];
|
|
1557
1560
|
let current = error;
|
|
@@ -1655,14 +1658,14 @@ var McpClient = class {
|
|
|
1655
1658
|
while (true) try {
|
|
1656
1659
|
return await operation();
|
|
1657
1660
|
} catch (error) {
|
|
1658
|
-
if (!this.reconnectFn || !isSessionError(error) || recoveryAttempts >= 2) throw error;
|
|
1661
|
+
if (!this.reconnectFn || !isSessionError$1(error) || recoveryAttempts >= 2) throw error;
|
|
1659
1662
|
recoveryAttempts += 1;
|
|
1660
1663
|
this.logger.warn(`Session error for ${this.serverName}, reconnecting: ${error instanceof Error ? error.message : String(error)}`);
|
|
1661
1664
|
while (true) try {
|
|
1662
1665
|
await this.reconnectClient();
|
|
1663
1666
|
break;
|
|
1664
1667
|
} catch (reconnectError) {
|
|
1665
|
-
if (!isSessionError(reconnectError) || recoveryAttempts >= 2) throw reconnectError;
|
|
1668
|
+
if (!isSessionError$1(reconnectError) || recoveryAttempts >= 2) throw reconnectError;
|
|
1666
1669
|
this.logger.warn(`Reconnect attempt ${String(recoveryAttempts)} for ${this.serverName} failed, retrying: ${reconnectError instanceof Error ? reconnectError.message : String(reconnectError)}`);
|
|
1667
1670
|
recoveryAttempts += 1;
|
|
1668
1671
|
}
|
|
@@ -4329,6 +4332,49 @@ function isConnectionError(error) {
|
|
|
4329
4332
|
const message = error.message.toLowerCase();
|
|
4330
4333
|
return CONNECTION_ERROR_PATTERNS.some((pattern) => message.includes(pattern));
|
|
4331
4334
|
}
|
|
4335
|
+
function getErrorChain(error) {
|
|
4336
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4337
|
+
const chain = [];
|
|
4338
|
+
let current = error;
|
|
4339
|
+
while (current && !visited.has(current)) {
|
|
4340
|
+
visited.add(current);
|
|
4341
|
+
if (current instanceof Error) {
|
|
4342
|
+
const currentWithCode = current;
|
|
4343
|
+
chain.push({
|
|
4344
|
+
message: current.message,
|
|
4345
|
+
code: currentWithCode.code
|
|
4346
|
+
});
|
|
4347
|
+
current = currentWithCode.cause;
|
|
4348
|
+
continue;
|
|
4349
|
+
}
|
|
4350
|
+
if (typeof current === "object") {
|
|
4351
|
+
const currentRecord = current;
|
|
4352
|
+
chain.push({
|
|
4353
|
+
message: typeof currentRecord.message === "string" ? currentRecord.message : String(current),
|
|
4354
|
+
code: typeof currentRecord.code === "string" ? currentRecord.code : void 0
|
|
4355
|
+
});
|
|
4356
|
+
current = currentRecord.cause;
|
|
4357
|
+
continue;
|
|
4358
|
+
}
|
|
4359
|
+
chain.push({ message: String(current) });
|
|
4360
|
+
break;
|
|
4361
|
+
}
|
|
4362
|
+
return chain;
|
|
4363
|
+
}
|
|
4364
|
+
/**
|
|
4365
|
+
* Checks if an error is a session-related error from an HTTP backend
|
|
4366
|
+
* (e.g., downstream server restarted and no longer recognizes the session ID).
|
|
4367
|
+
*/
|
|
4368
|
+
function isSessionError(error) {
|
|
4369
|
+
return getErrorChain(error).some(({ message, code }) => {
|
|
4370
|
+
const normalizedMessage = message.toLowerCase();
|
|
4371
|
+
const normalizedCode = normalizeErrorCode(code);
|
|
4372
|
+
return normalizedMessage.includes("unknown session") || normalizedMessage.includes("session not found") || normalizedMessage.includes("transport closed") || normalizedMessage.includes("connection closed") || normalizedMessage.includes("socket hang up") || normalizedMessage.includes("fetch failed") || normalizedCode === "econnreset";
|
|
4373
|
+
});
|
|
4374
|
+
}
|
|
4375
|
+
function normalizeErrorCode(code) {
|
|
4376
|
+
return typeof code === "string" ? code.toLowerCase() : void 0;
|
|
4377
|
+
}
|
|
4332
4378
|
/**
|
|
4333
4379
|
* Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
|
|
4334
4380
|
* Automatically reconnects to the HTTP backend with exponential backoff when the
|
|
@@ -4435,7 +4481,7 @@ var StdioHttpTransportHandler = class {
|
|
|
4435
4481
|
try {
|
|
4436
4482
|
return await fn();
|
|
4437
4483
|
} catch (error) {
|
|
4438
|
-
if (isConnectionError(error)) {
|
|
4484
|
+
if (isConnectionError(error) || isSessionError(error)) {
|
|
4439
4485
|
await this.reconnectWithBackoff();
|
|
4440
4486
|
return await fn();
|
|
4441
4487
|
}
|
|
@@ -25,7 +25,7 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
|
25
25
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
26
26
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "0.10.
|
|
28
|
+
var version = "0.10.5";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/utils/mcpConfigSchema.ts
|
|
31
31
|
/**
|
|
@@ -1521,14 +1521,17 @@ const PROCESS_REGISTRY_SERVICE_TYPE = "tool";
|
|
|
1521
1521
|
* Checks if an error is a session-related error from an HTTP backend
|
|
1522
1522
|
* (e.g., downstream server restarted and no longer recognizes the session ID).
|
|
1523
1523
|
*/
|
|
1524
|
-
function isSessionError(error) {
|
|
1525
|
-
return getErrorChain(error).some(({ message, code }) => {
|
|
1524
|
+
function isSessionError$1(error) {
|
|
1525
|
+
return getErrorChain$1(error).some(({ message, code }) => {
|
|
1526
1526
|
const normalizedMessage = message.toLowerCase();
|
|
1527
|
-
const normalizedCode = code
|
|
1527
|
+
const normalizedCode = normalizeErrorCode$1(code);
|
|
1528
1528
|
return normalizedMessage.includes("unknown session") || normalizedMessage.includes("session not found") || normalizedMessage.includes("transport closed") || normalizedMessage.includes("connection closed") || normalizedMessage.includes("socket hang up") || normalizedMessage.includes("fetch failed") || normalizedCode === "econnreset";
|
|
1529
1529
|
});
|
|
1530
1530
|
}
|
|
1531
|
-
function
|
|
1531
|
+
function normalizeErrorCode$1(code) {
|
|
1532
|
+
return typeof code === "string" ? code.toLowerCase() : void 0;
|
|
1533
|
+
}
|
|
1534
|
+
function getErrorChain$1(error) {
|
|
1532
1535
|
const visited = /* @__PURE__ */ new Set();
|
|
1533
1536
|
const chain = [];
|
|
1534
1537
|
let current = error;
|
|
@@ -1632,14 +1635,14 @@ var McpClient = class {
|
|
|
1632
1635
|
while (true) try {
|
|
1633
1636
|
return await operation();
|
|
1634
1637
|
} catch (error) {
|
|
1635
|
-
if (!this.reconnectFn || !isSessionError(error) || recoveryAttempts >= 2) throw error;
|
|
1638
|
+
if (!this.reconnectFn || !isSessionError$1(error) || recoveryAttempts >= 2) throw error;
|
|
1636
1639
|
recoveryAttempts += 1;
|
|
1637
1640
|
this.logger.warn(`Session error for ${this.serverName}, reconnecting: ${error instanceof Error ? error.message : String(error)}`);
|
|
1638
1641
|
while (true) try {
|
|
1639
1642
|
await this.reconnectClient();
|
|
1640
1643
|
break;
|
|
1641
1644
|
} catch (reconnectError) {
|
|
1642
|
-
if (!isSessionError(reconnectError) || recoveryAttempts >= 2) throw reconnectError;
|
|
1645
|
+
if (!isSessionError$1(reconnectError) || recoveryAttempts >= 2) throw reconnectError;
|
|
1643
1646
|
this.logger.warn(`Reconnect attempt ${String(recoveryAttempts)} for ${this.serverName} failed, retrying: ${reconnectError instanceof Error ? reconnectError.message : String(reconnectError)}`);
|
|
1644
1647
|
recoveryAttempts += 1;
|
|
1645
1648
|
}
|
|
@@ -4306,6 +4309,49 @@ function isConnectionError(error) {
|
|
|
4306
4309
|
const message = error.message.toLowerCase();
|
|
4307
4310
|
return CONNECTION_ERROR_PATTERNS.some((pattern) => message.includes(pattern));
|
|
4308
4311
|
}
|
|
4312
|
+
function getErrorChain(error) {
|
|
4313
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4314
|
+
const chain = [];
|
|
4315
|
+
let current = error;
|
|
4316
|
+
while (current && !visited.has(current)) {
|
|
4317
|
+
visited.add(current);
|
|
4318
|
+
if (current instanceof Error) {
|
|
4319
|
+
const currentWithCode = current;
|
|
4320
|
+
chain.push({
|
|
4321
|
+
message: current.message,
|
|
4322
|
+
code: currentWithCode.code
|
|
4323
|
+
});
|
|
4324
|
+
current = currentWithCode.cause;
|
|
4325
|
+
continue;
|
|
4326
|
+
}
|
|
4327
|
+
if (typeof current === "object") {
|
|
4328
|
+
const currentRecord = current;
|
|
4329
|
+
chain.push({
|
|
4330
|
+
message: typeof currentRecord.message === "string" ? currentRecord.message : String(current),
|
|
4331
|
+
code: typeof currentRecord.code === "string" ? currentRecord.code : void 0
|
|
4332
|
+
});
|
|
4333
|
+
current = currentRecord.cause;
|
|
4334
|
+
continue;
|
|
4335
|
+
}
|
|
4336
|
+
chain.push({ message: String(current) });
|
|
4337
|
+
break;
|
|
4338
|
+
}
|
|
4339
|
+
return chain;
|
|
4340
|
+
}
|
|
4341
|
+
/**
|
|
4342
|
+
* Checks if an error is a session-related error from an HTTP backend
|
|
4343
|
+
* (e.g., downstream server restarted and no longer recognizes the session ID).
|
|
4344
|
+
*/
|
|
4345
|
+
function isSessionError(error) {
|
|
4346
|
+
return getErrorChain(error).some(({ message, code }) => {
|
|
4347
|
+
const normalizedMessage = message.toLowerCase();
|
|
4348
|
+
const normalizedCode = normalizeErrorCode(code);
|
|
4349
|
+
return normalizedMessage.includes("unknown session") || normalizedMessage.includes("session not found") || normalizedMessage.includes("transport closed") || normalizedMessage.includes("connection closed") || normalizedMessage.includes("socket hang up") || normalizedMessage.includes("fetch failed") || normalizedCode === "econnreset";
|
|
4350
|
+
});
|
|
4351
|
+
}
|
|
4352
|
+
function normalizeErrorCode(code) {
|
|
4353
|
+
return typeof code === "string" ? code.toLowerCase() : void 0;
|
|
4354
|
+
}
|
|
4309
4355
|
/**
|
|
4310
4356
|
* Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
|
|
4311
4357
|
* Automatically reconnects to the HTTP backend with exponential backoff when the
|
|
@@ -4412,7 +4458,7 @@ var StdioHttpTransportHandler = class {
|
|
|
4412
4458
|
try {
|
|
4413
4459
|
return await fn();
|
|
4414
4460
|
} catch (error) {
|
|
4415
|
-
if (isConnectionError(error)) {
|
|
4461
|
+
if (isConnectionError(error) || isSessionError(error)) {
|
|
4416
4462
|
await this.reconnectWithBackoff();
|
|
4417
4463
|
return await fn();
|
|
4418
4464
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/mcp-proxy",
|
|
3
3
|
"description": "MCP proxy server package",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.5",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"js-yaml": "4.1.1",
|
|
29
29
|
"liquidjs": "10.25.5",
|
|
30
30
|
"zod": "4.3.6",
|
|
31
|
-
"@agimon-ai/foundation-port-registry": "0.8.0",
|
|
32
|
-
"@agimon-ai/foundation-process-registry": "0.8.0",
|
|
33
31
|
"@agimon-ai/foundation-validator": "0.5.0",
|
|
34
|
-
"@agimon-ai/log-sink-mcp": "0.8.0"
|
|
32
|
+
"@agimon-ai/log-sink-mcp": "0.8.0",
|
|
33
|
+
"@agimon-ai/foundation-port-registry": "0.8.0",
|
|
34
|
+
"@agimon-ai/foundation-process-registry": "0.8.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/js-yaml": "4.0.9",
|