Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(probe): record a compact error summary instead of the whole 402 envelope
nirholase3009e6d3e2f
diff --git a/scripts/mcp-client-probe.mjs b/scripts/mcp-client-probe.mjsindex 7ff6a82f5..76f0db05d 100644--- a/scripts/mcp-client-probe.mjs+++ b/scripts/mcp-client-probe.mjs@@ -312,6 +312,31 @@ function errorStatus(err) {return m ? Number(m[1]) : null;}+// The SDK folds the whole response body into its error message, and a 402+// body is several kilobytes of x402 requirements and bazaar schema. Keep the+// SDK's own prefix and the body's error fields; the evidence file records what+// went wrong, not a copy of the server's discovery metadata.+export function summarizeError(message, max = 400) {+ const text = String(message ?? '');+ const brace = text.indexOf('{');+ if (brace !== -1) {+ try {+ const body = JSON.parse(text.slice(brace));+ if (body && typeof body === 'object') {+ const fields = ['error', 'error_description', 'message', 'code']+ .filter((k) => typeof body[k] === 'string' || typeof body[k] === 'number')+ .map((k) => `${k}=${JSON.stringify(body[k])}`);+ if (body.x402Version !== undefined) fields.unshift(`x402Version=${body.x402Version}`);+ if (Array.isArray(body.accepts)) fields.push(`accepts=${body.accepts.length}`);+ return `${text.slice(0, brace).trimEnd()} {${fields.join(', ')}}`.slice(0, max);+ }+ } catch {+ // Not a JSON body after all; fall through to the plain cut.+ }+ }+ return text.slice(0, max);+}+function isAuthError(err) {return err?.name === 'UnauthorizedError' || errorStatus(err) === 401 || /unauthori[sz]ed/i.test(String(err?.message));}@@ -322,7 +347,7 @@ async function runSdk(url, { headers = {}, transport: kind, timeout }) {let closing = false;// Closing aborts the open GET stream; that abort is the probe's own doing.client.onerror = (e) => {- if (!closing) warnings.push(String(e?.message || e));+ if (!closing) warnings.push(summarizeError(e?.message || e));};const requestInit = { headers };const transport =@@ -359,7 +384,7 @@ async function runSdk(url, { headers = {}, transport: kind, timeout }) {}out.ok = !out.call || out.call.ok;} catch (err) {- out.error = String(err?.message || err).slice(0, 400);+ out.error = summarizeError(err?.message || err);out.status = errorStatus(err);out.authRequired = isAuthError(err);} finally {diff --git a/tests/mcp-client-probe.test.js b/tests/mcp-client-probe.test.jsindex 24e5b01e0..108c93bf7 100644--- a/tests/mcp-client-probe.test.js+++ b/tests/mcp-client-probe.test.js@@ -8,6 +8,7 @@ import {parseRpcBody,judgeGetStream,judgeServer,+ summarizeError,} from '../scripts/mcp-client-probe.mjs';describe('authExpectations', () => {@@ -100,3 +101,34 @@ describe('judgeServer', () => {expect(judgeServer(r)[0]).toMatch(/1999-01-01/);});});++describe('summarizeError', () => {+ it('keeps the SDK prefix and the error fields of a JSON body, not the whole 402 envelope', () => {+ const body = {+ x402Version: 2,+ error: 'X-PAYMENT header is required',+ resource: { url: 'https://three.ws/api/mcp-3d', description: 'x'.repeat(2000) },+ accepts: [{ scheme: 'exact' }, { scheme: 'exact' }],+ extensions: { bazaar: { discoverable: true } },+ };+ const out = summarizeError(`Streamable HTTP error: Error POSTing to endpoint: ${JSON.stringify(body)}`);+ expect(out).toBe(+ 'Streamable HTTP error: Error POSTing to endpoint: {x402Version=2, error="X-PAYMENT header is required", accepts=2}',+ );+ });++ it('carries an OAuth-style error description through', () => {+ const out = summarizeError(+ 'Streamable HTTP error: Error POSTing to endpoint: {"error":"service_unavailable","error_description":"database temporarily unavailable, retry shortly","ref":"48946bcef07d256a"}',+ );+ expect(out).toContain('error="service_unavailable"');+ expect(out).toContain('error_description="database temporarily unavailable, retry shortly"');+ expect(out).not.toContain('48946bcef07d256a');+ });++ it('cuts a plain message at the limit', () => {+ expect(summarizeError('fetch failed')).toBe('fetch failed');+ expect(summarizeError('a'.repeat(500)).length).toBe(400);+ expect(summarizeError('SSE error: Non-200 status code (405) {not json')).toBe('SSE error: Non-200 status code (405) {not json');+ });+});