Skip to content

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.

fix(okx-forge): answer MCP clients with a 402, refuse HD before settlement, and hand buyers the model page

nirholas4f5337b09b7d
diff --git a/api/_okx3d/README.md b/api/_okx3d/README.md
index 49efc6ec6..e0eed7bd2 100644
--- a/api/_okx3d/README.md
+++ b/api/_okx3d/README.md
@@ -22,7 +22,7 @@ Every GPU and render stage is driven over the deployed three.ws HTTP surfaces (t
| File | Role |
| --- | --- |
-| [`forge.js`](./forge.js) | The listed line-up: per-endpoint MCP tool catalogs, dispatchers, x402 price hooks, the bazaar discovery metadata in each 402, and the age-13+ content gate that runs before any generation starts. One surface is built per catalog row and memoized. |
+| [`forge.js`](./forge.js) | The listed line-up: per-endpoint MCP tool catalogs, dispatchers, x402 price hooks, the bazaar discovery metadata in each 402, the age-13+ content gate that runs before any generation starts, and the strict HD lane (refuses before settlement rather than serving a lower tier). Done responses carry the public model page (`/m/<creation id>`) and every link is repeated in the text content. One surface is built per catalog row and memoized. |
| [`identity.js`](./identity.js) | The pipeline engine: prompt shaping, forge/rig/render orchestration, sharp compositing (PFP head crop, 4:5 full-body frames), and the R2-persisted job state machine. |
| [`tools.js`](./tools.js) | The A2MCP face of the pipeline for `/api/okx/3d/identity-studio`: MCP tool catalog (`create_identity` paid, `identity_status` and `getting_started` free), dispatcher, x402 pricing hook, and the 402 challenge metadata indexers see. |
| [`rest-services.js`](./rest-services.js) | Engine adapters for the decomposed paid REST services (`text-to-3d`, `text-to-3d-pro`, `image-to-3d`, `rig`, `avatar`, `retarget`, `pose-seed`, `fbx-export`). Thin wrappers over engines the platform already runs, no duplicated pipeline logic. |
diff --git a/api/_okx3d/forge.js b/api/_okx3d/forge.js
index 82b12e3f7..a8a00ad8a 100644
--- a/api/_okx3d/forge.js
+++ b/api/_okx3d/forge.js
@@ -39,7 +39,7 @@ import { buildBazaarSchema } from '../_lib/x402-spec.js';
import { withService } from '../_lib/x402/bazaar-helpers.js';
import { catalogEntry, FORGE_TOOL, FORGE_STATUS_TOOL } from '../_lib/okx-catalog.js';
import { startForge, pollOnce, originFromReq } from '../_mcp-studio/gpt-forge-client.js';
-import { shapeSubmit, shapePoll } from '../_mcp-studio/studio-shape.js';
+import { shapeSubmit, shapePoll, tierOf } from '../_mcp-studio/studio-shape.js';
import { checkPromptSafety } from '../_mcp-studio/safety.js';
export { PROTOCOL_VERSION, FORGE_TOOL, FORGE_STATUS_TOOL };
@@ -90,6 +90,10 @@ function laneError(err) {
});
case 'unknown_job':
return toolError('unknown_job', err.message || 'That job id is not recognized.');
+ case 'tier_unavailable':
+ // The paid HD row refuses rather than quietly serving a lower tier.
+ // This error answers BEFORE settlement, so the buyer is not charged.
+ return toolError('tier_unavailable', err.message, { retry_after: err.retryAfter || 60, charged: false });
default:
return toolError('generation_failed', err?.message || 'The generator could not start this job.');
}
@@ -100,15 +104,52 @@ function laneError(err) {
// there. Both, because buyers in this marketplace read either.
const POLL_OPTS = { pollPath: STATUS_ENDPOINT };
-function withPollTool(shaped) {
- return shaped.status === 'pending' ? { ...shaped, poll_tool: FORGE_STATUS_TOOL, poll_endpoint: STATUS_ENDPOINT } : shaped;
+// Every finished creation has a public page at /m/<creation id>: the model
+// spinning in a viewer, AR and fullscreen, download, embed and share, comments
+// and likes. It is the one link an agent can hand a human that does everything.
+// The forge lane records the creation id on submit and on every poll frame, so
+// the page link is available the moment the job is done.
+const CREATION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+function pageUrlOf(base, data) {
+ const id = data?.creation_id;
+ return typeof id === 'string' && CREATION_ID_RE.test(id) ? `${base}/m/${id}` : null;
}
+function withPollTool(shaped, { base, data, title }) {
+ if (shaped.status === 'pending') {
+ return {
+ ...shaped,
+ poll_tool: FORGE_STATUS_TOOL,
+ poll_endpoint: STATUS_ENDPOINT,
+ // Copy these verbatim into the next forge_status call.
+ poll_arguments: { job_id: shaped.job, ...(title ? { title } : {}) },
+ };
+ }
+ if (shaped.status === 'done') {
+ const pageUrl = pageUrlOf(base, data);
+ return pageUrl ? { ...shaped, pageUrl } : shaped;
+ }
+ return shaped;
+}
+
+// The text content is what most buying agents relay to their human verbatim,
+// so it carries every link, not just the file. An agent that never reads
+// structuredContent still hands over the viewer, the AR launch and the page.
function summarize(shaped) {
- if (shaped.status === 'done') return `Model ready. GLB: ${shaped.glbUrl}`;
+ if (shaped.status === 'done') {
+ return [
+ 'Model ready.',
+ `Download (GLB): ${shaped.glbUrl}`,
+ `View in browser: ${shaped.viewerUrl}`,
+ `See it in your room (AR): ${shaped.arUrl}`,
+ ...(shaped.pageUrl ? [`Model page (share, embed, download): ${shaped.pageUrl}`] : []),
+ ...(shaped.previewImageUrl ? [`Concept image: ${shaped.previewImageUrl}`] : []),
+ ].join('\n');
+ }
if (shaped.status === 'error') return shaped.error;
const eta = shaped.etaSeconds ? ` ETA ~${shaped.etaSeconds}s.` : '';
- return `Job accepted.${eta} Call ${FORGE_STATUS_TOOL} with job_id ${shaped.job} until status is "done".`;
+ const preview = shaped.previewImageUrl ? ` Concept image so far: ${shaped.previewImageUrl}` : '';
+ return `Job accepted.${eta} Poll ${FORGE_STATUS_TOOL} with job_id "${shaped.job}" every 5s until status is "done".${preview}`;
}
function buildForgeTool(entry) {
@@ -119,9 +160,10 @@ function buildForgeTool(entry) {
title: `Forge a 3D model (paid, $${entry.priceUsd})`,
description:
`${priceLine} ${entry.describes.capability} ` +
- `Async: returns a job_id immediately, then poll ${FORGE_STATUS_TOOL} (free) every few ` +
- 'seconds until status is "done". Invalid input fails before settlement, so a rejected ' +
- 'call costs nothing.',
+ `Async: returns a job id immediately, then poll ${FORGE_STATUS_TOOL} (free) every few ` +
+ 'seconds until status is "done". You receive the GLB file, a browser viewer link, an ' +
+ 'augmented-reality link that places the model in a real room, a shareable model page, and ' +
+ 'the concept image. Invalid input fails before settlement, so a rejected call costs nothing.',
annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: true },
inputSchema: entry.inputSchema,
async handler(args, _auth, req) {
@@ -138,6 +180,12 @@ function buildForgeTool(entry) {
return toolError('invalid_input', 'prompt is required: describe one subject in 3 to 1000 characters.');
}
+ // The high tier is hold-gated on the generator; the buyer has already
+ // paid this row's price, so the job runs operator-funded (internal seed),
+ // the same way the custom GPT runs it. strictTier keeps the promise: if
+ // the HD lane will not take the job, refuse before settlement instead of
+ // charging HD money for a standard mesh.
+ const high = entry.lane?.tier === 'high';
let job;
try {
job = await startForge(base, {
@@ -146,12 +194,21 @@ function buildForgeTool(entry) {
aspect: isImageLane ? '1:1' : args.aspect_ratio,
...(entry.lane?.tier ? { tier: entry.lane.tier } : {}),
...(entry.lane?.path ? { path: entry.lane.path } : {}),
+ ...(high ? { internal: true, strictTier: true } : {}),
});
} catch (err) {
return laneError(err);
}
+ // Belt and braces: a lane that answered with a tier it was not asked
+ // for is refused the same way, still before settlement.
+ if (high && tierOf(job) && tierOf(job) !== 'high') {
+ return toolError('tier_unavailable', 'the high-detail lane is not available right now; try again shortly', {
+ retry_after: 60,
+ charged: false,
+ });
+ }
- const shaped = withPollTool(shapeSubmit(job, base, prompt, POLL_OPTS));
+ const shaped = withPollTool(shapeSubmit(job, base, prompt, POLL_OPTS), { base, data: job, title: prompt });
return toolOk(summarize(shaped), { ok: true, service: entry.id, ...shaped });
},
};
@@ -164,21 +221,28 @@ function buildStatusTool() {
title: 'Check a forge job (free)',
description:
'FREE. Reports the live state of a three.ws forge job and returns the finished GLB, the ' +
- 'concept image, a browser viewer link and an augmented-reality link once it is done. ' +
- 'Poll every few seconds. No payment, account, or key required.',
+ 'concept image, a browser viewer link, an augmented-reality link and a shareable model ' +
+ 'page once it is done. Poll every 5 seconds. No payment, account, or key required.',
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
inputSchema: entry.inputSchema,
async handler(args, _auth, req) {
const base = originFromReq(req);
const jobId = String(args.job_id || '').trim();
- const title = typeof args.title === 'string' ? args.title : '';
let data;
try {
data = await pollOnce(base, jobId);
} catch (err) {
return laneError(err);
}
- const shaped = withPollTool(shapePoll(data, base, jobId, title, POLL_OPTS));
+ // The poll frame carries the job's own prompt, so the viewer and AR
+ // pages get a title even when the buyer never passed one.
+ const title =
+ typeof args.title === 'string' && args.title.trim()
+ ? args.title
+ : typeof data?.prompt === 'string'
+ ? data.prompt
+ : '';
+ const shaped = withPollTool(shapePoll(data, base, jobId, title, POLL_OPTS), { base, data, title });
const body = { ok: shaped.status !== 'error', ...shaped };
return shaped.status === 'error'
? { isError: true, content: [{ type: 'text', text: shaped.error }], structuredContent: body }
@@ -305,7 +369,13 @@ function buildSurface(id) {
'Free: no payment, account, or key. Poll any three.ws forge job here.',
'Full service index (free): https://three.ws/api/okx/3d/catalog',
],
- links: { docs: DOCS_URL, catalog: `${BASE}/api/okx/3d/catalog`, health: `${BASE}/api/okx/3d/health` },
+ links: {
+ docs: DOCS_URL,
+ catalog: `${BASE}/api/okx/3d/catalog`,
+ health: `${BASE}/api/okx/3d/health`,
+ try_it_in_a_browser: `${BASE}/forge`,
+ example_model_page: `${BASE}/creations`,
+ },
});
const toolDefs = [gettingStarted, ...(paidTool ? [paidTool] : []), statusTool];
diff --git a/docs/okx-marketplace.md b/docs/okx-marketplace.md
index b84e7c402..e59309608 100644
--- a/docs/okx-marketplace.md
+++ b/docs/okx-marketplace.md
@@ -112,10 +112,14 @@ A queued job returns:
"ok": true, "service": "forge-standard", "status": "pending",
"job": "f1.…", "poll_tool": "forge_status",
"poll_endpoint": "https://three.ws/api/okx/3d/forge-status",
+ "poll_arguments": { "job_id": "f1.…", "title": "a low-poly orange fox sitting down" },
"watchUrl": "https://three.ws/watch?job=…", "format": "glb", "etaSeconds": 45
}
```
+Copy `poll_arguments` verbatim into the next `forge_status` call. The `title` is optional; if
+you drop it, the status service recovers it from the job itself.
+
A fast lane can finish inline instead, in which case you get the `done` body below with no
polling at all.
@@ -138,17 +142,25 @@ Poll every few seconds. When `status` is `"done"`:
"glbUrl": "https://…/model.glb",
"viewerUrl": "https://three.ws/viewer?src=…",
"arUrl": "https://three.ws/api/ar?src=…",
+ "pageUrl": "https://three.ws/m/0b6d2a9e-…",
"previewImageUrl": "https://…/concept.png",
"format": "glb", "tier": "standard"
}
```
+The text content of the same response lists every one of those links on its own line, so an
+agent that relays tool text to a human without reading `structuredContent` still hands over
+the viewer, the AR launch and the page.
+
- `glbUrl` is the model itself, a real glTF binary you can download, open in any glTF
runtime, or embed.
- `viewerUrl` opens it in a browser, spinning, on any device.
- `arUrl` is the device-aware AR launch: Scene Viewer on Android, Quick Look on iOS
(GLB to USDZ converted in-page), the WebGL viewer on desktop. This is the link that puts
the model in a human's actual room, which is usually what an agent's user wanted.
+- `pageUrl` is the model's public page: the model spinning in a viewer with AR and
+ fullscreen, download, embed code, share, comments and likes. It is the one link to hand a
+ human when they should get everything.
- `previewImageUrl` is the painted concept view the forge produces before the mesh, so you
can show something the moment it exists.
@@ -164,6 +176,14 @@ unit tests in [`tests/api/okx-forge.test.js`](../tests/api/okx-forge.test.js).
- **You pay only when the job is accepted.** Input validation and the age-13+ content gate
run before settlement; a rejected prompt or a malformed argument fails the call and
**no payment settles**.
+- **HD means HD.** If the high-detail lane will not take a job, `forge-hd` answers
+ `tier_unavailable` (with `charged: false` and a `retry_after`) instead of quietly serving
+ a standard mesh at the HD price. That refusal is also before settlement.
+- **A real MCP client gets a 402.** The shared three.ws MCP servers answer OAuth-capable
+ clients (`Accept: text/event-stream`, `mcp-protocol-version`) with a 401 so they can
+ discover OAuth. The OKX.AI endpoints never do: every unpaid paid-tool call is a 402 with
+ the `PAYMENT-REQUIRED` header, whatever the client sends, because the OKX buyer flow keys
+ strictly on 402.
- **Polling is free and unlimited**, on every endpoint and on the standalone status
service.
- **One payment, one job.** The payment proof is single-use across dispatch and settlement
diff --git a/prompts/okx-ai/PROGRESS.md b/prompts/okx-ai/PROGRESS.md
index 05a7025ad..3c9a24cd8 100644
--- a/prompts/okx-ai/PROGRESS.md
+++ b/prompts/okx-ai/PROGRESS.md
@@ -71,6 +71,44 @@ now keeps the first occurrence and drops later twins; Identity Studio inherited
`tests/multiplayer-server-boot.test.js`, is a Colyseus boot test with no path to any file
touched here.
+### Audit pass, same day (owner: "audit it and improve it as much as possible")
+
+Four real defects found and fixed, each with a regression test in `tests/api/okx-forge.test.js`:
+
+1. **MCP clients got a 401, not a 402, on every OKX endpoint.** The shared auth answers an
+ OAuth-capable client (`Accept: text/event-stream` or `mcp-protocol-version`) with 401 +
+ `WWW-Authenticate: Bearer` so claude.ai can discover OAuth. A spec-compliant MCP client
+ sends exactly those headers. The OKX buyer flow is explicit: "if it is not 402, return the
+ body directly." So a real A2MCP client calling a paid tool unpaid was handed a status it
+ could not pay, and a reviewer probing with one saw no payment integration at all. **This
+ is a strong candidate for the actual 2026-07-04 rejection cause**: every prior
+ verification used curl, which never sends those headers. `paymentStatus: 402` is now
+ forced on every OKX A2MCP service (forge rows AND Identity Studio), and the
+ `WWW-Authenticate` hint is dropped there.
+2. **`forge-hd` overcharged.** The generator hold-gates its high tier; the lane client
+ silently degraded a refused high job to standard. A buyer paid $0.25 for HD and got a
+ standard mesh. The HD row now submits operator-funded (internal seed, same as the custom
+ GPT) with `strictTier: true`, and refuses with `tier_unavailable` BEFORE settlement if the
+ HD lane will not take the job. `charged: false` is stated in the error.
+3. **No shareable link.** The lane records a `forge_creations` row on submit and every poll
+ frame carries `creation_id`; nothing surfaced it. Done responses now carry `pageUrl`
+ (`https://three.ws/m/<id>`: viewer, AR, download, embed, share, comments).
+4. **Text content only named the GLB.** Most buying agents relay tool text verbatim, so the
+ viewer, AR and page links were invisible to their humans. Every link is now on its own
+ line in the text; pending frames carry `poll_arguments` to copy into `forge_status`, and
+ the status tool recovers the title from the job's own prompt when none is passed.
+
+Also fixed in passing: the GET discovery challenge quoted the shared default price beside the
+real one (two amounts for one rail). `handleSse` now takes the list price.
+
+**Production observation, not fixed here:** a real draft submit to `/api/gpt-forge` on
+2026-08-22 took 156 s to answer `429 busy` while `/api/okx/3d/health` read all-green in
+0.8 s. The health probe reads the generator's static tier matrix, not its acceptance
+latency, so it cannot see a saturated lane. From inside `forge_3d` that call would have hit
+the 90 s client timeout and surfaced as `timeout` with `retry_after`, which is honest but
+slow. Worth a follow-up: an acceptance-latency reading in the health probe, and a shorter
+submit budget on the OKX surface.
+
### Still owner-gated (unchanged, and unchanged by this rebuild)
Funding. Relayer `0x1F4a753c61b54Bdec7AE0AF338A887E63Cdbbb74` needs native OKB on X Layer
diff --git a/tests/api/okx-forge.test.js b/tests/api/okx-forge.test.js
index 1c941c99b..4cc347121 100644
--- a/tests/api/okx-forge.test.js
+++ b/tests/api/okx-forge.test.js
@@ -225,6 +225,27 @@ describe('402 challenge: the OKX Agent Payments Protocol integration', () => {
expect(new Set(rails).size).toBe(rails.length);
});
+ // The OKX buyer flow: "if it is not 402, return the body directly". A
+ // spec-compliant MCP client sends Accept: application/json, text/event-stream
+ // and mcp-protocol-version, which the shared servers answer with an OAuth 401.
+ // That is a 401 no OKX buyer can pay and no reviewer reads as integrated.
+ it('a real MCP client gets 402 with the OKX header, never an OAuth 401', async () => {
+ for (const headers of [
+ { accept: 'application/json, text/event-stream' },
+ { 'mcp-protocol-version': '2025-06-18' },
+ ]) {
+ const res = makeRes();
+ await handler(makeReq({ service: 'forge-standard', headers, body: rpc(FORGE_TOOL, { prompt: 'a fox' }) }), res);
+ expect(res.statusCode).toBe(402);
+ expect(res.headers['www-authenticate']).toBeUndefined();
+ expect(res.headers['payment-required']).toBeTruthy();
+ expect(JSON.parse(res.body).accepts[0].network).toBe('eip155:196');
+ }
+ const sse = makeRes();
+ await handler(makeReq({ method: 'GET', service: 'forge-standard', headers: { accept: 'text/event-stream' } }), sse);
+ expect(sse.statusCode).toBe(402);
+ });
+
it('free tools need no payment on a paid endpoint', async () => {
const res = await post('forge-draft', rpc('getting_started', {}));
expect(res.statusCode).toBe(200);
@@ -249,10 +270,11 @@ describe('what a buying agent actually receives', () => {
expect(out.structuredContent.etaSeconds).toBe(45);
});
- it('a finished job carries the GLB, the browser viewer and the AR link, same as the custom GPT', async () => {
+ it('a finished job carries the GLB, the browser viewer, the AR link and the model page', async () => {
lane.poll = () =>
jsonResponse(200, {
status: 'done',
+ creation_id: '0b6d2a9e-6f0f-4b1e-9a2c-3d4e5f607182',
glb_url: 'https://cdn.test/fox.glb',
preview_image_url: 'https://cdn.test/fox.png',
tier: 'draft',
@@ -263,8 +285,26 @@ describe('what a buying agent actually receives', () => {
expect(body.glbUrl).toBe('https://cdn.test/fox.glb');
expect(body.viewerUrl).toContain('/viewer?src=');
expect(body.arUrl).toContain('/api/ar?src=');
+ expect(body.pageUrl).toBe('https://three.ws/m/0b6d2a9e-6f0f-4b1e-9a2c-3d4e5f607182');
expect(body.previewImageUrl).toBe('https://cdn.test/fox.png');
expect(body.format).toBe('glb');
+ // The text content is what most agents relay verbatim: every link is in it.
+ const text = out.content[0].text;
+ for (const link of [body.glbUrl, body.viewerUrl, body.arUrl, body.pageUrl]) expect(text).toContain(link);
+ });
+
+ it('titles the viewer and AR pages from the job itself when the buyer passes no title', async () => {
+ lane.poll = () =>
+ jsonResponse(200, { status: 'done', glb_url: 'https://cdn.test/fox.glb', prompt: 'a low-poly fox' });
+ const out = await callTool('forge-status', FORGE_STATUS_TOOL, { job_id: 'f1.job.abc' });
+ expect(out.structuredContent.arUrl).toContain('title=a%20low-poly%20fox');
+ });
+
+ it('a pending job tells the buyer exactly what to call next', async () => {
+ const out = await callTool('forge-standard', FORGE_TOOL, { prompt: 'a low-poly fox' });
+ expect(out.structuredContent.poll_arguments).toEqual({ job_id: 'f1.job.abc', title: 'a low-poly fox' });
+ expect(out.content[0].text).toContain(FORGE_STATUS_TOOL);
+ expect(out.content[0].text).toContain('f1.job.abc');
});
it('a failed job is an error the buyer can act on, not a silent pending', async () => {
@@ -296,6 +336,43 @@ describe('each row drives its own lane', () => {
expect(submitted.at(-1).tier).toBeUndefined();
});
+ // The generator hold-gates its high tier. A buyer of the HD row has already
+ // paid, so the job runs operator-funded, exactly like the custom GPT runs it.
+ it('runs the HD row operator-funded on the generator', async () => {
+ process.env.CRON_SECRET = 'seed-for-test';
+ let seen;
+ globalThis.fetch.mockImplementationOnce(async (input, init) => {
+ seen = init.headers;
+ submitted.push(JSON.parse(init.body));
+ return jsonResponse(200, { job_id: 'f1.job.hd', tier: 'high', eta_seconds: 240 });
+ });
+ const out = await callTool('forge-hd', FORGE_TOOL, { prompt: 'a fox' });
+ expect(seen['x-forge-seed']).toBe('seed-for-test');
+ expect(out.structuredContent.status).toBe('pending');
+ expect(out.structuredContent.tier).toBe('high');
+ });
+
+ // Without this the lane client degraded a refused high job to standard on
+ // its own, and the buyer paid the HD price for a standard mesh. The refusal
+ // answers before settlement, so nothing is charged.
+ it('refuses the HD row BEFORE settlement when the high lane will not take the job', async () => {
+ lane.submit = () => jsonResponse(402, { error: 'three_hold_required' });
+ const out = await callTool('forge-hd', FORGE_TOOL, { prompt: 'a fox' });
+ expect(out.isError).toBe(true);
+ expect(out.structuredContent.error).toBe('tier_unavailable');
+ expect(out.structuredContent.charged).toBe(false);
+ // Exactly one submit, no silent second attempt at a lower tier.
+ expect(submitted).toHaveLength(1);
+ expect(submitted[0].tier).toBe('high');
+ });
+
+ it('refuses the HD row if the lane answers with a lower tier than it was asked for', async () => {
+ lane.submit = () => jsonResponse(200, { job_id: 'f1.job.x', tier: 'standard' });
+ const out = await callTool('forge-hd', FORGE_TOOL, { prompt: 'a fox' });
+ expect(out.isError).toBe(true);
+ expect(out.structuredContent.error).toBe('tier_unavailable');
+ });
+
it('rejects an unsafe prompt BEFORE any generation runs, so it can never settle', async () => {
const out = await callTool('forge-draft', FORGE_TOOL, { prompt: 'a nude child' });
expect(out.isError).toBe(true);
diff --git a/tests/api/okx-identity-studio.test.js b/tests/api/okx-identity-studio.test.js
index 9200dc2ee..843bcf223 100644
--- a/tests/api/okx-identity-studio.test.js
+++ b/tests/api/okx-identity-studio.test.js
@@ -485,7 +485,13 @@ describe('402 challenge and pricing', () => {
}),
res,
);
- expect(res.statusCode).toBe(401); // MCP protocol client: 401 + www-authenticate, same envelope
+ // An MCP protocol client still gets 402 here, never the OAuth 401 the
+ // shared servers issue: the OKX buyer flow keys strictly on 402, and a
+ // spec-compliant MCP client (Accept: text/event-stream) is exactly the
+ // caller a marketplace reviewer uses.
+ expect(res.statusCode).toBe(402);
+ expect(res.headers['www-authenticate']).toBeUndefined();
+ expect(res.headers['payment-required']).toBeTruthy();
const challenge = JSON.parse(res.body);
expect(challenge.accepts[0].network).toBe('eip155:196');
expect(challenge.accepts[0].amount).toBe('1500000');