@agimon-ai/mcp-proxy 0.7.1 → 0.7.3

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
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-DyWwAp8e.cjs');
2
+ const require_src = require('./src-Dp2m9_I_.cjs');
3
3
  let node_fs = require("node:fs");
4
4
  let node_fs_promises = require("node:fs/promises");
5
5
  let js_yaml = require("js-yaml");
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, w as generateServerId, y as StopServerService } from "./src-NOWQwaRe.mjs";
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, w as generateServerId, y as StopServerService } from "./src-Y-cyyxaw.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,4 +1,4 @@
1
- const require_src = require('./src-DyWwAp8e.cjs');
1
+ const require_src = require('./src-Dp2m9_I_.cjs');
2
2
 
3
3
  exports.ConfigFetcherService = require_src.ConfigFetcherService;
4
4
  exports.DefinitionsCacheService = require_src.DefinitionsCacheService;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import { CallToolResult, GetPromptResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
4
+ import { z } from "zod";
4
5
  import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
5
6
 
6
7
  //#region src/types/index.d.ts
@@ -14,12 +15,7 @@ import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
14
15
  interface ToolDefinition {
15
16
  name: string;
16
17
  description: string;
17
- inputSchema: {
18
- type: string;
19
- properties: Record<string, unknown>;
20
- required?: string[];
21
- additionalProperties?: boolean;
22
- };
18
+ inputSchema: Record<string, unknown>;
23
19
  _meta?: Record<string, unknown>;
24
20
  }
25
21
  /**
@@ -28,6 +24,7 @@ interface ToolDefinition {
28
24
  */
29
25
  interface Tool<TInput = unknown> {
30
26
  getDefinition(): ToolDefinition | Promise<ToolDefinition>;
27
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
31
28
  execute(input: TInput): Promise<CallToolResult>;
32
29
  }
33
30
  /**
@@ -743,6 +740,7 @@ declare class DefinitionsCacheService {
743
740
  getDefinitions(): Promise<DefinitionsCacheFile>;
744
741
  getServerDefinitions(): Promise<CachedServerDefinition[]>;
745
742
  getServersForTool(toolName: string): Promise<string[]>;
743
+ getToolSchema(serverName: string, toolName: string): Promise<Record<string, unknown> | undefined>;
746
744
  getServersForResource(uri: string): Promise<string[]>;
747
745
  getPromptSkillByName(skillName: string): Promise<PromptSkillMatch | undefined>;
748
746
  getCachedFileSkills(): Promise<CachedFileSkillInfo[]>;
@@ -890,9 +888,10 @@ declare class StopServerService {
890
888
  * Input schema for the DescribeToolsTool
891
889
  * @property toolNames - Array of tool names to get detailed information about
892
890
  */
893
- interface DescribeToolsToolInput {
894
- toolNames: string[];
895
- }
891
+ declare const DescribeToolsToolInputSchema: z.ZodObject<{
892
+ toolNames: z.ZodArray<z.ZodString>;
893
+ }, z.core.$strip>;
894
+ type DescribeToolsToolInput = z.infer<typeof DescribeToolsToolInputSchema>;
896
895
  /**
897
896
  * DescribeToolsTool provides progressive disclosure of MCP tools and skills.
898
897
  *
@@ -998,6 +997,7 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
998
997
  *
999
998
  * @returns Tool definition with description and input schema
1000
999
  */
1000
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1001
1001
  getDefinition(): Promise<ToolDefinition>;
1002
1002
  /**
1003
1003
  * Executes tool description lookup for the requested tool and skill names.
@@ -1010,22 +1010,24 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
1010
1010
  * @param input - Object containing toolNames array
1011
1011
  * @returns CallToolResult with tool/skill descriptions or error
1012
1012
  */
1013
- execute(input: DescribeToolsToolInput): Promise<CallToolResult>;
1013
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1014
1014
  }
1015
1015
  //#endregion
1016
1016
  //#region src/tools/SearchListToolsTool.d.ts
1017
- interface SearchListToolsToolInput {
1018
- capability?: string;
1019
- serverName?: string;
1020
- }
1017
+ declare const SearchListToolsToolInputSchema: z.ZodObject<{
1018
+ capability: z.ZodOptional<z.ZodString>;
1019
+ serverName: z.ZodOptional<z.ZodString>;
1020
+ }, z.core.$strip>;
1021
+ type SearchListToolsToolInput = z.infer<typeof SearchListToolsToolInputSchema>;
1021
1022
  declare class SearchListToolsTool implements Tool<SearchListToolsToolInput> {
1022
1023
  private readonly _clientManager;
1023
1024
  private readonly definitionsCacheService;
1024
1025
  static readonly TOOL_NAME = "list_tools";
1025
1026
  constructor(_clientManager: unknown, definitionsCacheService: DefinitionsCacheService);
1026
1027
  private formatToolName;
1028
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1027
1029
  getDefinition(): Promise<ToolDefinition>;
1028
- execute(input: SearchListToolsToolInput): Promise<CallToolResult>;
1030
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1029
1031
  }
1030
1032
  //#endregion
1031
1033
  //#region src/tools/UseToolTool.d.ts
@@ -1034,10 +1036,11 @@ declare class SearchListToolsTool implements Tool<SearchListToolsToolInput> {
1034
1036
  * @property toolName - Name of the tool or skill to execute
1035
1037
  * @property toolArgs - Arguments to pass to the tool (from describe_tools schema)
1036
1038
  */
1037
- interface UseToolToolInput {
1038
- toolName: string;
1039
- toolArgs?: Record<string, unknown>;
1040
- }
1039
+ declare const UseToolToolInputSchema: z.ZodObject<{
1040
+ toolName: z.ZodString;
1041
+ toolArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1042
+ }, z.core.$strip>;
1043
+ type UseToolToolInput = z.infer<typeof UseToolToolInputSchema>;
1041
1044
  /**
1042
1045
  * UseToolTool executes MCP tools and skills with proper error handling.
1043
1046
  *
@@ -1073,6 +1076,7 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1073
1076
  *
1074
1077
  * @returns The tool definition conforming to MCP spec
1075
1078
  */
1079
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1076
1080
  getDefinition(): ToolDefinition;
1077
1081
  /**
1078
1082
  * Returns guidance message for skill invocation.
@@ -1084,6 +1088,12 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1084
1088
  * @param skill - The skill that was requested
1085
1089
  * @returns CallToolResult with guidance message
1086
1090
  */
1091
+ /**
1092
+ * Coerce toolArgs using the downstream tool's cached JSON Schema.
1093
+ * Converts the schema to Zod and runs coerceArgs so that string-encoded
1094
+ * objects/arrays are parsed before being forwarded to the downstream server.
1095
+ */
1096
+ private coerceToolArgs;
1087
1097
  private executeSkill;
1088
1098
  /**
1089
1099
  * Finds a prompt-based skill by name from all connected MCP servers.
@@ -1115,7 +1125,7 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1115
1125
  * @param input - The tool/skill name and optional arguments
1116
1126
  * @returns CallToolResult with execution output or error
1117
1127
  */
1118
- execute(input: UseToolToolInput): Promise<CallToolResult>;
1128
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1119
1129
  }
1120
1130
  //#endregion
1121
1131
  //#region src/transports/http.d.ts
@@ -1197,6 +1207,8 @@ interface StdioHttpProxyTransportConfig {
1197
1207
  }
1198
1208
  /**
1199
1209
  * Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
1210
+ * Automatically reconnects to the HTTP backend with exponential backoff when the
1211
+ * connection is lost (e.g. backend crash + restart).
1200
1212
  */
1201
1213
  declare class StdioHttpTransportHandler implements TransportHandler {
1202
1214
  private readonly endpoint;
@@ -1204,9 +1216,16 @@ declare class StdioHttpTransportHandler implements TransportHandler {
1204
1216
  private stdioTransport;
1205
1217
  private httpClient;
1206
1218
  private logger;
1219
+ private readonly MAX_RECONNECT_ATTEMPTS;
1220
+ private readonly RECONNECT_BASE_MS;
1221
+ private readonly RECONNECT_MAX_MS;
1207
1222
  constructor(config: StdioHttpProxyTransportConfig, logger?: LoggerLike);
1208
1223
  start(): Promise<void>;
1209
1224
  stop(): Promise<void>;
1225
+ private createAndConnectClient;
1226
+ private registerElicitationHandler;
1227
+ private reconnectWithBackoff;
1228
+ private withReconnect;
1210
1229
  private createProxyServer;
1211
1230
  }
1212
1231
  //#endregion
package/dist/index.d.mts CHANGED
@@ -15,12 +15,7 @@ import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
15
15
  interface ToolDefinition {
16
16
  name: string;
17
17
  description: string;
18
- inputSchema: {
19
- type: string;
20
- properties: Record<string, unknown>;
21
- required?: string[];
22
- additionalProperties?: boolean;
23
- };
18
+ inputSchema: Record<string, unknown>;
24
19
  _meta?: Record<string, unknown>;
25
20
  }
26
21
  /**
@@ -29,6 +24,7 @@ interface ToolDefinition {
29
24
  */
30
25
  interface Tool<TInput = unknown> {
31
26
  getDefinition(): ToolDefinition | Promise<ToolDefinition>;
27
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
32
28
  execute(input: TInput): Promise<CallToolResult>;
33
29
  }
34
30
  /**
@@ -744,6 +740,7 @@ declare class DefinitionsCacheService {
744
740
  getDefinitions(): Promise<DefinitionsCacheFile>;
745
741
  getServerDefinitions(): Promise<CachedServerDefinition[]>;
746
742
  getServersForTool(toolName: string): Promise<string[]>;
743
+ getToolSchema(serverName: string, toolName: string): Promise<Record<string, unknown> | undefined>;
747
744
  getServersForResource(uri: string): Promise<string[]>;
748
745
  getPromptSkillByName(skillName: string): Promise<PromptSkillMatch | undefined>;
749
746
  getCachedFileSkills(): Promise<CachedFileSkillInfo[]>;
@@ -891,9 +888,10 @@ declare class StopServerService {
891
888
  * Input schema for the DescribeToolsTool
892
889
  * @property toolNames - Array of tool names to get detailed information about
893
890
  */
894
- interface DescribeToolsToolInput {
895
- toolNames: string[];
896
- }
891
+ declare const DescribeToolsToolInputSchema: z.ZodObject<{
892
+ toolNames: z.ZodArray<z.ZodString>;
893
+ }, z.core.$strip>;
894
+ type DescribeToolsToolInput = z.infer<typeof DescribeToolsToolInputSchema>;
897
895
  /**
898
896
  * DescribeToolsTool provides progressive disclosure of MCP tools and skills.
899
897
  *
@@ -999,6 +997,7 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
999
997
  *
1000
998
  * @returns Tool definition with description and input schema
1001
999
  */
1000
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1002
1001
  getDefinition(): Promise<ToolDefinition>;
1003
1002
  /**
1004
1003
  * Executes tool description lookup for the requested tool and skill names.
@@ -1011,22 +1010,24 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
1011
1010
  * @param input - Object containing toolNames array
1012
1011
  * @returns CallToolResult with tool/skill descriptions or error
1013
1012
  */
1014
- execute(input: DescribeToolsToolInput): Promise<CallToolResult>;
1013
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1015
1014
  }
1016
1015
  //#endregion
1017
1016
  //#region src/tools/SearchListToolsTool.d.ts
1018
- interface SearchListToolsToolInput {
1019
- capability?: string;
1020
- serverName?: string;
1021
- }
1017
+ declare const SearchListToolsToolInputSchema: z.ZodObject<{
1018
+ capability: z.ZodOptional<z.ZodString>;
1019
+ serverName: z.ZodOptional<z.ZodString>;
1020
+ }, z.core.$strip>;
1021
+ type SearchListToolsToolInput = z.infer<typeof SearchListToolsToolInputSchema>;
1022
1022
  declare class SearchListToolsTool implements Tool<SearchListToolsToolInput> {
1023
1023
  private readonly _clientManager;
1024
1024
  private readonly definitionsCacheService;
1025
1025
  static readonly TOOL_NAME = "list_tools";
1026
1026
  constructor(_clientManager: unknown, definitionsCacheService: DefinitionsCacheService);
1027
1027
  private formatToolName;
1028
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1028
1029
  getDefinition(): Promise<ToolDefinition>;
1029
- execute(input: SearchListToolsToolInput): Promise<CallToolResult>;
1030
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1030
1031
  }
1031
1032
  //#endregion
1032
1033
  //#region src/tools/UseToolTool.d.ts
@@ -1035,10 +1036,11 @@ declare class SearchListToolsTool implements Tool<SearchListToolsToolInput> {
1035
1036
  * @property toolName - Name of the tool or skill to execute
1036
1037
  * @property toolArgs - Arguments to pass to the tool (from describe_tools schema)
1037
1038
  */
1038
- interface UseToolToolInput {
1039
- toolName: string;
1040
- toolArgs?: Record<string, unknown>;
1041
- }
1039
+ declare const UseToolToolInputSchema: z.ZodObject<{
1040
+ toolName: z.ZodString;
1041
+ toolArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1042
+ }, z.core.$strip>;
1043
+ type UseToolToolInput = z.infer<typeof UseToolToolInputSchema>;
1042
1044
  /**
1043
1045
  * UseToolTool executes MCP tools and skills with proper error handling.
1044
1046
  *
@@ -1074,6 +1076,7 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1074
1076
  *
1075
1077
  * @returns The tool definition conforming to MCP spec
1076
1078
  */
1079
+ getInputSchema(): z.ZodObject<z.ZodRawShape>;
1077
1080
  getDefinition(): ToolDefinition;
1078
1081
  /**
1079
1082
  * Returns guidance message for skill invocation.
@@ -1085,6 +1088,12 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1085
1088
  * @param skill - The skill that was requested
1086
1089
  * @returns CallToolResult with guidance message
1087
1090
  */
1091
+ /**
1092
+ * Coerce toolArgs using the downstream tool's cached JSON Schema.
1093
+ * Converts the schema to Zod and runs coerceArgs so that string-encoded
1094
+ * objects/arrays are parsed before being forwarded to the downstream server.
1095
+ */
1096
+ private coerceToolArgs;
1088
1097
  private executeSkill;
1089
1098
  /**
1090
1099
  * Finds a prompt-based skill by name from all connected MCP servers.
@@ -1116,7 +1125,7 @@ declare class UseToolTool implements Tool<UseToolToolInput> {
1116
1125
  * @param input - The tool/skill name and optional arguments
1117
1126
  * @returns CallToolResult with execution output or error
1118
1127
  */
1119
- execute(input: UseToolToolInput): Promise<CallToolResult>;
1128
+ execute(rawInput: Record<string, unknown>): Promise<CallToolResult>;
1120
1129
  }
1121
1130
  //#endregion
1122
1131
  //#region src/transports/http.d.ts
@@ -1198,6 +1207,8 @@ interface StdioHttpProxyTransportConfig {
1198
1207
  }
1199
1208
  /**
1200
1209
  * Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
1210
+ * Automatically reconnects to the HTTP backend with exponential backoff when the
1211
+ * connection is lost (e.g. backend crash + restart).
1201
1212
  */
1202
1213
  declare class StdioHttpTransportHandler implements TransportHandler {
1203
1214
  private readonly endpoint;
@@ -1205,9 +1216,16 @@ declare class StdioHttpTransportHandler implements TransportHandler {
1205
1216
  private stdioTransport;
1206
1217
  private httpClient;
1207
1218
  private logger;
1219
+ private readonly MAX_RECONNECT_ATTEMPTS;
1220
+ private readonly RECONNECT_BASE_MS;
1221
+ private readonly RECONNECT_MAX_MS;
1208
1222
  constructor(config: StdioHttpProxyTransportConfig, logger?: LoggerLike);
1209
1223
  start(): Promise<void>;
1210
1224
  stop(): Promise<void>;
1225
+ private createAndConnectClient;
1226
+ private registerElicitationHandler;
1227
+ private reconnectWithBackoff;
1228
+ private withReconnect;
1211
1229
  private createProxyServer;
1212
1230
  }
1213
1231
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
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 SkillService, w as generateServerId, x as McpClientManagerService, y as StopServerService } from "./src-NOWQwaRe.mjs";
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 SkillService, w as generateServerId, x as McpClientManagerService, y as StopServerService } from "./src-Y-cyyxaw.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 };