@deotio/mcp-sigv4-proxy 0.2.1 → 0.3.0
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/README.md +2 -1
- package/dist/proxy.js +23 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,12 +14,13 @@ Add to your `.mcp.json`:
|
|
|
14
14
|
"args": ["-y", "@deotio/mcp-sigv4-proxy"],
|
|
15
15
|
"env": {
|
|
16
16
|
"AWS_PROFILE": "dot-finops",
|
|
17
|
+
"AWS_REGION": "us-east-1",
|
|
17
18
|
"MCP_SERVER_URL": "https://bedrock-agentcore.us-east-1.amazonaws.com/runtimes/.../invocations?qualifier=DEFAULT"
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Always set `AWS_REGION` explicitly — the proxy can infer it from standard AWS hostnames, but `AWS_REGION` from your shell environment takes precedence and may point to a different region. `AWS_SERVICE` is inferred automatically and only needs to be set for non-standard endpoints.
|
|
23
24
|
|
|
24
25
|
## How it works
|
|
25
26
|
|
package/dist/proxy.js
CHANGED
|
@@ -5,8 +5,9 @@ import { Sha256 } from '@aws-crypto/sha256-js';
|
|
|
5
5
|
import readline from 'readline';
|
|
6
6
|
export const MAX_SSE_BUFFER_BYTES = 1_048_576; // 1 MB
|
|
7
7
|
const DEFAULT_TIMEOUT_MS = 180_000; // 180s, matches AWS proxy
|
|
8
|
-
const DEFAULT_RETRIES =
|
|
8
|
+
const DEFAULT_RETRIES = 2;
|
|
9
9
|
const RETRY_BASE_MS = 1000;
|
|
10
|
+
const COLD_START_RETRY_MS = 5000;
|
|
10
11
|
const LOG_LEVEL_ORDER = {
|
|
11
12
|
DEBUG: 0,
|
|
12
13
|
INFO: 1,
|
|
@@ -145,10 +146,14 @@ async function fetchWithRetry(url, init, timeoutMs, retries) {
|
|
|
145
146
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
146
147
|
try {
|
|
147
148
|
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
// Retry on 5xx server errors and 424 (AgentCore cold-start timeout)
|
|
150
|
+
const retryable = response.status >= 500 || response.status === 424;
|
|
151
|
+
if (retryable && attempt < retries) {
|
|
152
|
+
const delay = response.status === 424
|
|
153
|
+
? COLD_START_RETRY_MS * Math.pow(2, attempt)
|
|
154
|
+
: RETRY_BASE_MS * Math.pow(2, attempt);
|
|
155
|
+
log('WARNING', `HTTP ${response.status}, retrying in ${delay}ms (${attempt + 1}/${retries})`);
|
|
156
|
+
await sleep(delay);
|
|
152
157
|
continue;
|
|
153
158
|
}
|
|
154
159
|
return response;
|
|
@@ -172,10 +177,22 @@ export async function handleResponse(response, requestId) {
|
|
|
172
177
|
if (!response.ok) {
|
|
173
178
|
const text = await response.text();
|
|
174
179
|
log('ERROR', `HTTP ${response.status}: ${text}`);
|
|
180
|
+
// Extract the upstream message for the JSON-RPC error (if JSON, use .message; otherwise trim)
|
|
181
|
+
let detail = '';
|
|
182
|
+
try {
|
|
183
|
+
const parsed = JSON.parse(text);
|
|
184
|
+
if (typeof parsed.message === 'string')
|
|
185
|
+
detail = `: ${parsed.message}`;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
const trimmed = text.trim();
|
|
189
|
+
if (trimmed.length > 0 && trimmed.length <= 200)
|
|
190
|
+
detail = `: ${trimmed}`;
|
|
191
|
+
}
|
|
175
192
|
process.stdout.write(JSON.stringify({
|
|
176
193
|
jsonrpc: '2.0',
|
|
177
194
|
id: requestId,
|
|
178
|
-
error: { code: -32000, message: `HTTP ${response.status}` },
|
|
195
|
+
error: { code: -32000, message: `HTTP ${response.status}${detail}` },
|
|
179
196
|
}) + '\n');
|
|
180
197
|
return;
|
|
181
198
|
}
|
package/package.json
CHANGED