@agimon-ai/mcp-proxy 0.4.8 → 0.4.9
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 +39 -2
- package/dist/cli.mjs +39 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-CTeN-GJT.cjs → src-5rGDc0sh.cjs} +3 -3
- package/dist/{src-koR2D9Bb.mjs → src-BErGW2ax.mjs} +3 -3
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-5rGDc0sh.cjs');
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -217,11 +217,31 @@ function spawnBackgroundRuntime(args, env, cwd) {
|
|
|
217
217
|
child.unref();
|
|
218
218
|
return child;
|
|
219
219
|
}
|
|
220
|
+
async function stopExistingRuntime(runtimeStateService, serverId, host, port) {
|
|
221
|
+
const runtimes = await runtimeStateService.list();
|
|
222
|
+
const targetHost = host || DEFAULT_HOST$1;
|
|
223
|
+
const match = runtimes.find((r) => {
|
|
224
|
+
if (serverId && r.serverId === serverId) return true;
|
|
225
|
+
if (port !== void 0 && r.host === targetHost && r.port === port) return true;
|
|
226
|
+
return false;
|
|
227
|
+
});
|
|
228
|
+
if (!match) return;
|
|
229
|
+
const stopService = new require_src.StopServerService(runtimeStateService);
|
|
230
|
+
try {
|
|
231
|
+
await stopService.stop({
|
|
232
|
+
serverId: match.serverId,
|
|
233
|
+
force: true
|
|
234
|
+
});
|
|
235
|
+
} catch {
|
|
236
|
+
await runtimeStateService.remove(match.serverId);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
220
239
|
async function prestartHttpRuntime(options) {
|
|
221
240
|
const serverId = options.id || require_src.generateServerId();
|
|
222
241
|
const timeoutMs = parseTimeoutMs(options.timeoutMs);
|
|
223
242
|
const registryPath = options.registryPath || options.registryDir;
|
|
224
243
|
const workspaceRoot = resolveWorkspaceRoot();
|
|
244
|
+
await stopExistingRuntime(new require_src.RuntimeStateService(), options.id, options.host, options.port);
|
|
225
245
|
const childEnv = {
|
|
226
246
|
...process.env,
|
|
227
247
|
...registryPath ? {
|
|
@@ -672,7 +692,24 @@ async function startStdioTransport(serverOptions) {
|
|
|
672
692
|
}
|
|
673
693
|
async function startSseTransport(serverOptions, config) {
|
|
674
694
|
try {
|
|
675
|
-
|
|
695
|
+
const requestedPort = config.port;
|
|
696
|
+
const portRange = requestedPort !== void 0 ? {
|
|
697
|
+
min: requestedPort,
|
|
698
|
+
max: requestedPort
|
|
699
|
+
} : __agimon_ai_foundation_port_registry.DEFAULT_PORT_RANGE;
|
|
700
|
+
const portLease = await createPortRegistryLease("mcp-proxy-sse", config.host ?? DEFAULT_HOST, requestedPort, serverOptions.serverId ?? require_src.generateServerId(), TRANSPORT_TYPE_SSE, void 0, portRange);
|
|
701
|
+
const resolvedConfig = {
|
|
702
|
+
...config,
|
|
703
|
+
port: portLease.port
|
|
704
|
+
};
|
|
705
|
+
const handler = new require_src.SseTransportHandler(await require_src.createServer(serverOptions), resolvedConfig);
|
|
706
|
+
const shutdown = async () => {
|
|
707
|
+
await handler.stop();
|
|
708
|
+
await portLease.release();
|
|
709
|
+
};
|
|
710
|
+
process.on("SIGINT", shutdown);
|
|
711
|
+
process.on("SIGTERM", shutdown);
|
|
712
|
+
await startServer(handler);
|
|
676
713
|
} catch (error) {
|
|
677
714
|
throw new Error(`Failed to start SSE transport: ${toErrorMessage$9(error)}`);
|
|
678
715
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as findConfigFile, E as generateServerId, T as DefinitionsCacheService, d as version, f as StdioHttpTransportHandler, h as HttpTransportHandler, m as SseTransportHandler, n as createServer, o as createProxyIoCContainer, p as StdioTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, v as RuntimeStateService } from "./src-
|
|
2
|
+
import { D as findConfigFile, E as generateServerId, T as DefinitionsCacheService, _ as StopServerService, d as version, f as StdioHttpTransportHandler, h as HttpTransportHandler, m as SseTransportHandler, n as createServer, o as createProxyIoCContainer, p as StdioTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, v as RuntimeStateService } from "./src-BErGW2ax.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { access, writeFile } from "node:fs/promises";
|
|
5
5
|
import path, { join, resolve } from "node:path";
|
|
@@ -216,11 +216,31 @@ function spawnBackgroundRuntime(args, env, cwd) {
|
|
|
216
216
|
child.unref();
|
|
217
217
|
return child;
|
|
218
218
|
}
|
|
219
|
+
async function stopExistingRuntime(runtimeStateService, serverId, host, port) {
|
|
220
|
+
const runtimes = await runtimeStateService.list();
|
|
221
|
+
const targetHost = host || DEFAULT_HOST$1;
|
|
222
|
+
const match = runtimes.find((r) => {
|
|
223
|
+
if (serverId && r.serverId === serverId) return true;
|
|
224
|
+
if (port !== void 0 && r.host === targetHost && r.port === port) return true;
|
|
225
|
+
return false;
|
|
226
|
+
});
|
|
227
|
+
if (!match) return;
|
|
228
|
+
const stopService = new StopServerService(runtimeStateService);
|
|
229
|
+
try {
|
|
230
|
+
await stopService.stop({
|
|
231
|
+
serverId: match.serverId,
|
|
232
|
+
force: true
|
|
233
|
+
});
|
|
234
|
+
} catch {
|
|
235
|
+
await runtimeStateService.remove(match.serverId);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
219
238
|
async function prestartHttpRuntime(options) {
|
|
220
239
|
const serverId = options.id || generateServerId();
|
|
221
240
|
const timeoutMs = parseTimeoutMs(options.timeoutMs);
|
|
222
241
|
const registryPath = options.registryPath || options.registryDir;
|
|
223
242
|
const workspaceRoot = resolveWorkspaceRoot();
|
|
243
|
+
await stopExistingRuntime(new RuntimeStateService(), options.id, options.host, options.port);
|
|
224
244
|
const childEnv = {
|
|
225
245
|
...process.env,
|
|
226
246
|
...registryPath ? {
|
|
@@ -671,7 +691,24 @@ async function startStdioTransport(serverOptions) {
|
|
|
671
691
|
}
|
|
672
692
|
async function startSseTransport(serverOptions, config) {
|
|
673
693
|
try {
|
|
674
|
-
|
|
694
|
+
const requestedPort = config.port;
|
|
695
|
+
const portRange = requestedPort !== void 0 ? {
|
|
696
|
+
min: requestedPort,
|
|
697
|
+
max: requestedPort
|
|
698
|
+
} : DEFAULT_PORT_RANGE;
|
|
699
|
+
const portLease = await createPortRegistryLease("mcp-proxy-sse", config.host ?? DEFAULT_HOST, requestedPort, serverOptions.serverId ?? generateServerId(), TRANSPORT_TYPE_SSE, void 0, portRange);
|
|
700
|
+
const resolvedConfig = {
|
|
701
|
+
...config,
|
|
702
|
+
port: portLease.port
|
|
703
|
+
};
|
|
704
|
+
const handler = new SseTransportHandler(await createServer(serverOptions), resolvedConfig);
|
|
705
|
+
const shutdown = async () => {
|
|
706
|
+
await handler.stop();
|
|
707
|
+
await portLease.release();
|
|
708
|
+
};
|
|
709
|
+
process.on("SIGINT", shutdown);
|
|
710
|
+
process.on("SIGTERM", shutdown);
|
|
711
|
+
await startServer(handler);
|
|
675
712
|
} catch (error) {
|
|
676
713
|
throw new Error(`Failed to start SSE transport: ${toErrorMessage$9(error)}`);
|
|
677
714
|
}
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -50,7 +50,7 @@ type TransportMode = (typeof TRANSPORT_MODE)[keyof typeof TRANSPORT_MODE];
|
|
|
50
50
|
*/
|
|
51
51
|
interface TransportConfig {
|
|
52
52
|
mode: TransportMode;
|
|
53
|
-
port
|
|
53
|
+
port: number;
|
|
54
54
|
host?: string;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -1125,7 +1125,7 @@ declare class HttpTransportHandler implements HttpTransportHandler$1 {
|
|
|
1125
1125
|
private adminOptions?;
|
|
1126
1126
|
private adminRateLimiter;
|
|
1127
1127
|
private logger;
|
|
1128
|
-
constructor(serverFactory: (
|
|
1128
|
+
constructor(serverFactory: () => Server | Promise<Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions, logger?: LoggerLike);
|
|
1129
1129
|
private setupMiddleware;
|
|
1130
1130
|
private setupRoutes;
|
|
1131
1131
|
private isAuthorizedShutdownRequest;
|
package/dist/index.d.mts
CHANGED
|
@@ -51,7 +51,7 @@ type TransportMode = (typeof TRANSPORT_MODE)[keyof typeof TRANSPORT_MODE];
|
|
|
51
51
|
*/
|
|
52
52
|
interface TransportConfig {
|
|
53
53
|
mode: TransportMode;
|
|
54
|
-
port
|
|
54
|
+
port: number;
|
|
55
55
|
host?: string;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -1126,7 +1126,7 @@ declare class HttpTransportHandler implements HttpTransportHandler$1 {
|
|
|
1126
1126
|
private adminOptions?;
|
|
1127
1127
|
private adminRateLimiter;
|
|
1128
1128
|
private logger;
|
|
1129
|
-
constructor(serverFactory: (
|
|
1129
|
+
constructor(serverFactory: () => Server | Promise<Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions, logger?: LoggerLike);
|
|
1130
1130
|
private setupMiddleware;
|
|
1131
1131
|
private setupRoutes;
|
|
1132
1132
|
private isAuthorizedShutdownRequest;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as SearchListToolsTool, D as findConfigFile, E as generateServerId, S as UseToolTool, T as DefinitionsCacheService, _ as StopServerService, a as createProxyContainer, b as createProxyLogger, c as createStdioHttpTransportHandler, f as StdioHttpTransportHandler, g as SkillService, h as HttpTransportHandler, i as createHttpTransportHandler, l as createStdioTransportHandler, m as SseTransportHandler, n as createServer, p as StdioTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as RuntimeStateService, w as DescribeToolsTool, x as ConfigFetcherService, y as McpClientManagerService } from "./src-
|
|
1
|
+
import { C as SearchListToolsTool, D as findConfigFile, E as generateServerId, S as UseToolTool, T as DefinitionsCacheService, _ as StopServerService, a as createProxyContainer, b as createProxyLogger, c as createStdioHttpTransportHandler, f as StdioHttpTransportHandler, g as SkillService, h as HttpTransportHandler, i as createHttpTransportHandler, l as createStdioTransportHandler, m as SseTransportHandler, n as createServer, p as StdioTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as RuntimeStateService, w as DescribeToolsTool, x as ConfigFetcherService, y as McpClientManagerService } from "./src-BErGW2ax.mjs";
|
|
2
2
|
|
|
3
3
|
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 };
|
|
@@ -3778,7 +3778,7 @@ var HttpTransportHandler = class {
|
|
|
3778
3778
|
this.sessionManager = new HttpFullSessionManager();
|
|
3779
3779
|
this.config = {
|
|
3780
3780
|
mode: config.mode,
|
|
3781
|
-
port: config.port
|
|
3781
|
+
port: config.port,
|
|
3782
3782
|
host: config.host ?? "localhost"
|
|
3783
3783
|
};
|
|
3784
3784
|
this.adminOptions = adminOptions;
|
|
@@ -4063,7 +4063,7 @@ var SseTransportHandler = class {
|
|
|
4063
4063
|
this.sessionManager = new SseSessionManager();
|
|
4064
4064
|
this.config = {
|
|
4065
4065
|
mode: config.mode,
|
|
4066
|
-
port: config.port
|
|
4066
|
+
port: config.port,
|
|
4067
4067
|
host: config.host ?? "localhost"
|
|
4068
4068
|
};
|
|
4069
4069
|
this.logger = logger;
|
|
@@ -4342,7 +4342,7 @@ var StdioHttpTransportHandler = class {
|
|
|
4342
4342
|
|
|
4343
4343
|
//#endregion
|
|
4344
4344
|
//#region package.json
|
|
4345
|
-
var version = "0.4.
|
|
4345
|
+
var version = "0.4.9";
|
|
4346
4346
|
|
|
4347
4347
|
//#endregion
|
|
4348
4348
|
//#region src/container/index.ts
|
|
@@ -3749,7 +3749,7 @@ var HttpTransportHandler = class {
|
|
|
3749
3749
|
this.sessionManager = new HttpFullSessionManager();
|
|
3750
3750
|
this.config = {
|
|
3751
3751
|
mode: config.mode,
|
|
3752
|
-
port: config.port
|
|
3752
|
+
port: config.port,
|
|
3753
3753
|
host: config.host ?? "localhost"
|
|
3754
3754
|
};
|
|
3755
3755
|
this.adminOptions = adminOptions;
|
|
@@ -4034,7 +4034,7 @@ var SseTransportHandler = class {
|
|
|
4034
4034
|
this.sessionManager = new SseSessionManager();
|
|
4035
4035
|
this.config = {
|
|
4036
4036
|
mode: config.mode,
|
|
4037
|
-
port: config.port
|
|
4037
|
+
port: config.port,
|
|
4038
4038
|
host: config.host ?? "localhost"
|
|
4039
4039
|
};
|
|
4040
4040
|
this.logger = logger;
|
|
@@ -4313,7 +4313,7 @@ var StdioHttpTransportHandler = class {
|
|
|
4313
4313
|
|
|
4314
4314
|
//#endregion
|
|
4315
4315
|
//#region package.json
|
|
4316
|
-
var version = "0.4.
|
|
4316
|
+
var version = "0.4.9";
|
|
4317
4317
|
|
|
4318
4318
|
//#endregion
|
|
4319
4319
|
//#region src/container/index.ts
|
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.4.
|
|
4
|
+
"version": "0.4.9",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"js-yaml": "^4.1.0",
|
|
28
28
|
"liquidjs": "^10.21.0",
|
|
29
29
|
"zod": "^3.24.1",
|
|
30
|
-
"@agimon-ai/foundation-process-registry": "0.2.
|
|
31
|
-
"@agimon-ai/
|
|
32
|
-
"@agimon-ai/
|
|
30
|
+
"@agimon-ai/foundation-process-registry": "0.2.7",
|
|
31
|
+
"@agimon-ai/foundation-port-registry": "0.2.11",
|
|
32
|
+
"@agimon-ai/log-sink-mcp": "0.2.11"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/express": "^5.0.0",
|