@tokenoftrust/cli 2.2.2 → 2.2.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/package.json +1 -1
- package/src/mcp.mjs +8 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Token of Trust",
|
package/src/mcp.mjs
CHANGED
|
@@ -12,6 +12,10 @@ import { randomUUID } from "node:crypto";
|
|
|
12
12
|
import os from "node:os";
|
|
13
13
|
import { CliDiagnosticError, recordDiagnostic, sanitizeDiagnosticText } from "./diagnostics.mjs";
|
|
14
14
|
|
|
15
|
+
// A server's refusal is written for the person reading it and usually ends with what to do,
|
|
16
|
+
// so it is shown whole. The cap only bounds a runaway body; sanitizing still applies.
|
|
17
|
+
export const MAX_SERVER_MESSAGE = 4000;
|
|
18
|
+
|
|
15
19
|
const TRACE_HEADER = "X-Trace-Id";
|
|
16
20
|
const REQUEST_ID_HEADERS = ["x-request-id", "x-amzn-trace-id", "x-correlation-id"];
|
|
17
21
|
const DEFAULT_REQUEST_TIMEOUT_MS = 120_000;
|
|
@@ -188,7 +192,7 @@ export function createMcpClient(baseUrl, opts = {}) {
|
|
|
188
192
|
const category = signal.aborted ? "timeout" : "network";
|
|
189
193
|
const message = signal.aborted
|
|
190
194
|
? `${method} timed out after ${timeoutMs}ms`
|
|
191
|
-
: `${method} failed before a response arrived: ${sanitizeDiagnosticText(cause?.message || cause,
|
|
195
|
+
: `${method} failed before a response arrived: ${sanitizeDiagnosticText(cause?.message || cause, MAX_SERVER_MESSAGE)}`;
|
|
192
196
|
throw diagnosticError(message, { operation: method, category, message, traceId }, cause);
|
|
193
197
|
}
|
|
194
198
|
const sid = res.headers.get("Mcp-Session-Id");
|
|
@@ -229,7 +233,7 @@ export function createMcpClient(baseUrl, opts = {}) {
|
|
|
229
233
|
const category = oauth ? "oauth" : res.status === 413 ? "http_413" : `http_${res.status}`;
|
|
230
234
|
const message = sanitizeDiagnosticText(
|
|
231
235
|
failure.message || parsed?.error_description || `${res.status} ${res.statusText}`,
|
|
232
|
-
|
|
236
|
+
MAX_SERVER_MESSAGE,
|
|
233
237
|
);
|
|
234
238
|
throw diagnosticError(`${method} failed: HTTP ${res.status}${message ? ` — ${message}` : ""}`, {
|
|
235
239
|
operation: method, category, httpStatus: res.status, statusText: res.statusText,
|
|
@@ -249,7 +253,7 @@ export function createMcpClient(baseUrl, opts = {}) {
|
|
|
249
253
|
|
|
250
254
|
if (parsed?.error) {
|
|
251
255
|
const failure = safeServerFailure(parsed);
|
|
252
|
-
const message = sanitizeDiagnosticText(failure.message || "JSON-RPC error",
|
|
256
|
+
const message = sanitizeDiagnosticText(failure.message || "JSON-RPC error", MAX_SERVER_MESSAGE);
|
|
253
257
|
throw diagnosticError(`${method} failed: ${message}`, {
|
|
254
258
|
operation: method, category: "json_rpc", httpStatus: res.status,
|
|
255
259
|
statusText: res.statusText, serverCode: failure.serverCode, message,
|
|
@@ -310,7 +314,7 @@ export function createMcpClient(baseUrl, opts = {}) {
|
|
|
310
314
|
}
|
|
311
315
|
const message = sanitizeDiagnosticText(
|
|
312
316
|
payload?.message || payload?.error?.message || tb?.text || `${name} failed`,
|
|
313
|
-
|
|
317
|
+
MAX_SERVER_MESSAGE,
|
|
314
318
|
);
|
|
315
319
|
throw diagnosticError(`${name} failed: ${message}`, {
|
|
316
320
|
operation: name, category: "tool_error",
|