You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-17Lines changed: 60 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,9 +182,17 @@ Example `config/tool_config.json`:
182
182
export LOGGING="debug"
183
183
```
184
184
185
-
- **`RETRY_SSE_TOOL_CALL_ON_DISCONNECT`**: (Optional) Controls whether to automatically reconnect and retry on SSE tool call failures. Set to `"true"` to enable, `"false"` to disable. Default: `true`. See the "Enhanced Reliability Features" section for details.
185
+
- **`RETRY_SSE_TOOL_CALL`**: (Optional) Controls whether to enable retries for SSE tool calls. Set to `"true"` to enable, `"false"` to disable. Default: `true`. See the "Enhanced Reliability Features" section for details.
186
186
```bash
187
-
export RETRY_SSE_TOOL_CALL_ON_DISCONNECT="true"
187
+
export RETRY_SSE_TOOL_CALL="true"
188
+
```
189
+
- **`SSE_TOOL_CALL_MAX_RETRIES`**: (Optional) Maximum number of retry attempts for SSE tool calls (after the initial failure). Default: `2`. See the "Enhanced Reliability Features" section for details.
190
+
```bash
191
+
export SSE_TOOL_CALL_MAX_RETRIES="2"
192
+
```
193
+
- **`SSE_TOOL_CALL_RETRY_DELAY_BASE_MS`**: (Optional) Base delay in milliseconds for SSE tool call retries, used in exponential backoff. Default: `300`. See the "Enhanced Reliability Features" section for details.
194
+
```bash
195
+
export SSE_TOOL_CALL_RETRY_DELAY_BASE_MS="300"
188
196
```
189
197
- **`RETRY_HTTP_TOOL_CALL`**: (Optional) Controls whether to retry on HTTP tool call connection errors. Set to `"true"` to enable, `"false"` to disable. Default: `true`. See the "Enhanced Reliability Features" section for details.
190
198
```bash
@@ -218,23 +226,33 @@ The MCP Proxy Server includes features to improve its resilience and the reliabi
218
226
### 1. Error Propagation
219
227
The proxy server ensures that errors originating from backend MCP services are consistently propagated to the requesting client. These errors are formatted as standard JSON-RPC error responses, making it easier for clients to handle them uniformly.
220
228
221
-
### 2. SSE Connection Retry for Tool Calls
222
-
When a `tools/call` operation is made to an SSE-based backend server, and the underlying connection is lost or experiences an error, the proxy server will automatically attempt to:
223
-
1. Re-establish the connection to the SSE backend.
224
-
2. If reconnection is successful, it will retry the original `tools/call` request **once**.
229
+
### 2. SSE Tool Call Retry
230
+
When a `tools/call` operation is made to an SSE-based backend server, and the underlying connection is lost or experiences an error (including timeouts), the proxy server implements a retry mechanism.
225
231
226
-
This behavior helps mitigate transient network issues that might temporarily disrupt SSE connections.
232
+
**Retry Mechanism:**
233
+
If an initial SSE tool call fails due to a connection error or timeout, the proxy will attempt to re-establish the connection to the SSE backend. If reconnection is successful, it will then retry the original `tools/call` request using an exponential backoff strategy, similar to HTTP and Stdio retries. This means the delay before each subsequent retry attempt increases exponentially, with a small amount of jitter (randomness) added.
227
234
228
235
**Configuration:**
229
-
This feature is primarily controlled by the **`RETRY_SSE_TOOL_CALL_ON_DISCONNECT`** environment variable.
- Set to `"true"` to enable the automatic reconnect and retry.
236
+
These settings are primarily controlled by environment variables. Values in `config/mcp_server.json` under the `proxy` object for these specific keys will be overridden by environment variables if set.
- Specifies the maximum number of retry attempts *after* the initial failed attempt. For example, if set to `"2"`, there will be one initial attempt and up to two retry attempts, totaling a maximum of three attempts.
245
+
- **Default Behavior:** `2` (if the environment variable is not set, is empty, or is not a valid integer).
- The base delay in milliseconds used in the exponential backoff calculation. The delay before the *n*-th retry (0-indexed) is roughly `SSE_TOOL_CALL_RETRY_DELAY_BASE_MS * (2^n) + jitter`.
249
+
- **Default Behavior:** `300` (milliseconds) (if the environment variable is not set, is empty, or is not a valid integer).
250
+
251
+
**Example (Environment Variables):**
236
252
```bash
237
-
export RETRY_SSE_TOOL_CALL_ON_DISCONNECT="true"
253
+
export RETRY_SSE_TOOL_CALL="true"
254
+
export SSE_TOOL_CALL_MAX_RETRIES="3"
255
+
export SSE_TOOL_CALL_RETRY_DELAY_BASE_MS="500"
238
256
```
239
257
240
258
### 3. HTTP Request Retry for Tool Calls
@@ -282,8 +300,8 @@ These settings are primarily controlled by environment variables.
282
300
- **Default Behavior:** `300` (milliseconds) (if the environment variable is not set, is empty, or is not a valid integer).
283
301
284
302
**General Notes on Environment Variable Parsing:**
285
-
- Boolean environment variables (`RETRY_SSE_TOOL_CALL_ON_DISCONNECT`, `RETRY_HTTP_TOOL_CALL`, `RETRY_STDIO_TOOL_CALL`) are considered `true` if their lowercase value is exactly `"true"`. Any other value (including empty or not set) results in the default being applied or `false` if the default is `false` (though for these specific variables, the default is `true`).
286
-
- Numeric environment variables (`HTTP_TOOL_CALL_MAX_RETRIES`, `HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS`, `STDIO_TOOL_CALL_MAX_RETRIES`, `STDIO_TOOL_CALL_RETRY_DELAY_BASE_MS`) are parsed as base-10 integers. If parsing fails (e.g., the value is not a number, or the variable is empty/not set), the default value is used.
303
+
- Boolean environment variables (`RETRY_SSE_TOOL_CALL`, `RETRY_HTTP_TOOL_CALL`, `RETRY_STDIO_TOOL_CALL`) are considered `true` if their lowercase value is exactly `"true"`. Any other value (including empty or not set) results in the default being applied or `false` if the default is `false` (though for these specific variables, the default is `true`)。
304
+
- Numeric environment variables (`SSE_TOOL_CALL_MAX_RETRIES`, `SSE_TOOL_CALL_RETRY_DELAY_BASE_MS`, `HTTP_TOOL_CALL_MAX_RETRIES`, `HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS`, `STDIO_TOOL_CALL_MAX_RETRIES`, `STDIO_TOOL_CALL_RETRY_DELAY_BASE_MS`) are parsed as base-10 integers. If parsing fails (e.g., the value is not a number, or the variable is empty/not set), the default value is used。
287
305
288
306
## Development
289
307
@@ -336,16 +354,41 @@ These settings are primarily controlled by environment variables. Values in `con
336
354
- **Default Behavior:** `300` (milliseconds) (if the environment variable is not set, is empty, or is not a valid integer).
337
355
338
356
**General Notes on Environment Variable Parsing:**
339
-
- Boolean environment variables (`RETRY_SSE_TOOL_CALL_ON_DISCONNECT`, `RETRY_HTTP_TOOL_CALL`) are considered `true` if their lowercase value is exactly `"true"`. Any other value (including empty or not set) results in the default being applied or `false` if the default is `false` (though for these specific variables, the default is `true`).
340
-
- Numeric environment variables (`HTTP_TOOL_CALL_MAX_RETRIES`, `HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS`) are parsed as base-10 integers. If parsing fails (e.g., the value is not a number, or the variable is empty/not set), the default value is used.
357
+
- Boolean environment variables (`RETRY_SSE_TOOL_CALL`, `RETRY_HTTP_TOOL_CALL`, `RETRY_STDIO_TOOL_CALL`) are considered `true` if their lowercase value is exactly `"true"`. Any other value (including empty or not set) results in the default being applied or `false` if the default is `false` (though for these specific variables, the default is `true`).
358
+
- Numeric environment variables (`SSE_TOOL_CALL_MAX_RETRIES`, `SSE_TOOL_CALL_RETRY_DELAY_BASE_MS`, `HTTP_TOOL_CALL_MAX_RETRIES`, `HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS`, `STDIO_TOOL_CALL_MAX_RETRIES`, `STDIO_TOOL_CALL_RETRY_DELAY_BASE_MS`) are parsed as base-10 integers. If parsing fails (e.g., the value is not a number, or the variable is empty/not set), the default value is used.
341
359
342
360
**Example (Environment Variables):**
343
361
```bash
344
362
export RETRY_HTTP_TOOL_CALL="true"
345
363
export HTTP_TOOL_CALL_MAX_RETRIES="3"
346
364
export HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS="500"
347
365
```
348
-
*(The JSON example for `mcp_server.json` under "Proxy Behavior Configuration" illustrates where other, non-environment-overrideable proxy settings might go.)*
366
+
367
+
### 4. Stdio Connection Retry for Tool Calls
368
+
For `tools/call` operations directed to Stdio-based backend servers, the proxy implements a retry mechanism for connection errors (e.g., process crash or unresponsiveness).
369
+
370
+
**Retry Mechanism:**
371
+
If an initial Stdio connection or tool call fails, the proxy will attempt to restart the Stdio process and retry the request. This mechanism follows an exponential backoff strategy similar to HTTP retries.
372
+
373
+
**Configuration:**
374
+
These settings are primarily controlled by environment variables.
- Specifies the maximum number of retry attempts *after* the initial failed attempt. For example, if set to `"2"`, there will be one initial attempt and up to two retry attempts, totaling a maximum of three attempts.
383
+
- **Default Behavior:** `2` (if the environment variable is not set, is empty, or is not a valid integer).
- The base delay in milliseconds used in the exponential backoff calculation. The delay before the *n*-th retry (0-indexed) is roughly `STDIO_TOOL_CALL_RETRY_DELAY_BASE_MS * (2^n) + jitter`.
387
+
- **Default Behavior:** `300` (milliseconds) (if the environment variable is not set, is empty, or is not a valid integer).
388
+
389
+
**General Notes on Environment Variable Parsing:**
390
+
- Boolean environment variables (`RETRY_SSE_TOOL_CALL`, `RETRY_HTTP_TOOL_CALL`, `RETRY_STDIO_TOOL_CALL`) are considered `true` if their lowercase value is exactly `"true"`. Any other value (including empty or not set) results in the default being applied or `false` if the default is `false` (though for these specific variables, the default is `true`)。
391
+
- Numeric environment variables (`SSE_TOOL_CALL_MAX_RETRIES`, `SSE_TOOL_CALL_RETRY_DELAY_BASE_MS`, `HTTP_TOOL_CALL_MAX_RETRIES`, `HTTP_TOOL_CALL_RETRY_DELAY_BASE_MS`, `STDIO_TOOL_CALL_MAX_RETRIES`, `STDIO_TOOL_CALL_RETRY_DELAY_BASE_MS`) are parsed as base-10 integers. If parsing fails (e.g., the value is not a number, or the variable is empty/not set), the default value is used.
0 commit comments