webcake-landing-mcp 1.17.0 → 1.17.1
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 -2
- package/README.vi.md +1 -1
- package/dist/auth/oauth-server.js +30 -3
- package/dist/changelog.json +7 -7
- package/dist/http.js +45 -8
- package/dist/mcp/params.js +1 -1
- package/dist/smoke.js +3 -1
- package/dist/tools/api-gateway.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ Two ways to get the link:
|
|
|
149
149
|
- **Easiest** — open **<https://webcake.io/mcp-remote>** in your Webcake dashboard → it builds & copies the link for you.
|
|
150
150
|
- **By hand** — see the step-by-step guide: **[docs/connect-mcp.md](docs/connect-mcp.md)**.
|
|
151
151
|
|
|
152
|
-
Optional extras: `&env=prod`, `&org_id
|
|
152
|
+
Optional extras: `&env=prod`, `&org_id=…`. Hand each teammate a link with their own `jwt` →
|
|
153
153
|
per-user, no OAuth. Clients that support headers should send the token as **`x-webcake-jwt`** instead of
|
|
154
154
|
putting it in the URL — the full header ↔ env mapping is in **[docs/configuration.md](docs/configuration.md#per-request-headers-hosted--remote-server)**.
|
|
155
155
|
|
|
@@ -171,7 +171,7 @@ npx -y webcake-landing-mcp login # opens the browser once, saves the token to
|
|
|
171
171
|
For `publish_page` to actually put a page **live**, a build host is needed (it renders the
|
|
172
172
|
`app`/`app_css` that the live `publish_html` route requires):
|
|
173
173
|
- `prod` preset auto-configures `https://build.webcake.io` — no extra setup (the preset applies when the env resolves to `prod`: `WEBCAKE_ENV=prod`, `--env prod`, or `x-webcake-env: prod`).
|
|
174
|
-
- For staging/local, set `WEBCAKE_BUILD_BASE=<url>`
|
|
174
|
+
- For staging/local, set `WEBCAKE_BUILD_BASE=<url>` on the server (per-request `x-webcake-*-base` headers are ignored over HTTP).
|
|
175
175
|
- Without it, `publish_page` falls back to a legacy source-only save with `rendered:false, live:false` + a warning — nothing goes live.
|
|
176
176
|
- A page is only **permanently** live with a `custom_domain`; without one the returned `/preview/<page_id>` link expires ~10 minutes after the publish.
|
|
177
177
|
|
package/README.vi.md
CHANGED
|
@@ -148,7 +148,7 @@ Hai cách lấy link:
|
|
|
148
148
|
- **Dễ nhất** — mở **<https://webcake.io/mcp-remote>** trong dashboard Webcake → nó tự tạo & copy link cho bạn.
|
|
149
149
|
- **Thủ công** — xem hướng dẫn từng bước: **[docs/ket-noi-mcp.md](docs/ket-noi-mcp.md)**.
|
|
150
150
|
|
|
151
|
-
Tham số thêm: `&env=prod`, `&org_id
|
|
151
|
+
Tham số thêm: `&env=prod`, `&org_id=…`. Mỗi đồng đội một link với `jwt` riêng → mỗi người một
|
|
152
152
|
tài khoản, không cần OAuth. Client nào set được header thì nên gửi token qua header **`x-webcake-jwt`** thay vì
|
|
153
153
|
nhét vào URL — bảng header ↔ env đầy đủ ở **[docs/configuration.vi.md](docs/configuration.vi.md#header-mỗi-request-server-hosted--remote)**.
|
|
154
154
|
|
|
@@ -327,10 +327,10 @@ export function verifyPkce(verifier, challenge) {
|
|
|
327
327
|
}
|
|
328
328
|
export async function registerClient(body) {
|
|
329
329
|
const uris = Array.isArray(body?.redirect_uris)
|
|
330
|
-
? body.redirect_uris.filter((u) => typeof u === "string" &&
|
|
330
|
+
? body.redirect_uris.filter((u) => typeof u === "string" && isAllowedRedirect(u))
|
|
331
331
|
: [];
|
|
332
332
|
if (uris.length === 0) {
|
|
333
|
-
return { ok: false, error: "invalid_redirect_uri", error_description: "redirect_uris must
|
|
333
|
+
return { ok: false, error: "invalid_redirect_uri", error_description: "redirect_uris must be a known MCP client callback (claude.ai, chatgpt.com, …) or an http loopback URI." };
|
|
334
334
|
}
|
|
335
335
|
const client = {
|
|
336
336
|
client_id: token(16),
|
|
@@ -347,6 +347,33 @@ export async function getClient(clientId) {
|
|
|
347
347
|
return (await getStore()).getClient(clientId);
|
|
348
348
|
}
|
|
349
349
|
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
350
|
+
// An open redirect target would let anyone register a client and phish a code for a victim's
|
|
351
|
+
// account, so DCR only accepts known MCP clients + loopback. Add hosts via WEBCAKE_OAUTH_REDIRECT_HOSTS.
|
|
352
|
+
const REDIRECT_HOSTS = new Set([
|
|
353
|
+
"claude.ai",
|
|
354
|
+
"claude.com",
|
|
355
|
+
"chatgpt.com",
|
|
356
|
+
"platform.openai.com",
|
|
357
|
+
"vscode.dev",
|
|
358
|
+
"insiders.vscode.dev",
|
|
359
|
+
...(process.env.WEBCAKE_OAUTH_REDIRECT_HOSTS ?? "").split(",").map((h) => h.trim().toLowerCase()).filter(Boolean),
|
|
360
|
+
]);
|
|
361
|
+
export function isAllowedRedirect(uri) {
|
|
362
|
+
let u;
|
|
363
|
+
try {
|
|
364
|
+
u = new URL(uri);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
if (u.protocol === "http:")
|
|
370
|
+
return LOOPBACK_HOSTS.has(u.hostname);
|
|
371
|
+
return u.protocol === "https:" && REDIRECT_HOSTS.has(u.hostname);
|
|
372
|
+
}
|
|
373
|
+
/** Cookie set at /authorize and required at the callback: ties a pending request to the browser that started it. */
|
|
374
|
+
export function pendingCookieName(internalState) {
|
|
375
|
+
return `wc_oauth_${s256(internalState).slice(0, 16)}`;
|
|
376
|
+
}
|
|
350
377
|
/**
|
|
351
378
|
* Exact match, except an http loopback redirect ignores the port (RFC 8252 §7.3):
|
|
352
379
|
* native clients like Claude Code register `http://localhost/callback` and then
|
|
@@ -379,7 +406,7 @@ export async function startAuthorize(p) {
|
|
|
379
406
|
if (!client) {
|
|
380
407
|
return { ok: false, error: "invalid_client", error_description: "Unknown client_id. Register first via /register.", redirectable: false };
|
|
381
408
|
}
|
|
382
|
-
if (!p.redirect_uri || !client.redirect_uris.some((r) => redirectMatches(r, p.redirect_uri))) {
|
|
409
|
+
if (!p.redirect_uri || !isAllowedRedirect(p.redirect_uri) || !client.redirect_uris.some((r) => redirectMatches(r, p.redirect_uri))) {
|
|
383
410
|
return { ok: false, error: "invalid_request", error_description: "redirect_uri does not match a registered URI.", redirectable: false };
|
|
384
411
|
}
|
|
385
412
|
// From here errors CAN go back to the client's redirect_uri.
|
package/dist/changelog.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "1.17.1",
|
|
4
|
+
"d": "01/12/2026",
|
|
5
|
+
"type": "Fixed",
|
|
6
|
+
"en": "The hosted remote-connector OAuth flow now rejects Dynamic Client Registration and /authorize requests whose redirect_uri is not a known MCP client…",
|
|
7
|
+
"vi": "Luồng OAuth của remote connector đã hosted nay từ chối các yêu cầu Dynamic Client Registration và /authorize có redirect_uri không phải callback của…"
|
|
8
|
+
},
|
|
2
9
|
{
|
|
3
10
|
"v": "1.17.0",
|
|
4
11
|
"d": "28/11/2026",
|
|
@@ -33,12 +40,5 @@
|
|
|
33
40
|
"type": "Added",
|
|
34
41
|
"en": "api_find/api_get/api_call's route catalog now includes get:/api/v1/pages/options, a slim, filterable page list endpoint on the Webcake backend.",
|
|
35
42
|
"vi": "Danh mục route của api_find/api_get/api_call nay có thêm get:/api/v1/pages/options, một endpoint lấy danh sách trang dạng gọn, lọc được, trên…"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"v": "1.14.0",
|
|
39
|
-
"d": "23/11/2026",
|
|
40
|
-
"type": "Added",
|
|
41
|
-
"en": "ingest_html and ingest_url with intent:'clone' now measure a page that is not an absolute-canvas export in a real browser, the same way clone_page…",
|
|
42
|
-
"vi": "ingest_html và ingest_url với intent:'clone' nay đo trang không phải export dạng canvas tuyệt đối bằng một trình duyệt thật, giống cách clone_page…"
|
|
43
43
|
}
|
|
44
44
|
]
|
package/dist/http.js
CHANGED
|
@@ -24,7 +24,7 @@ import { searchPexels, resolvePexelsKey } from "./persistence/pexels-client.js";
|
|
|
24
24
|
import { captureWithPlaywright, captureTilesWithPlaywright, isAllowedScreenshotUrl } from "./persistence/screenshot-playwright.js";
|
|
25
25
|
import { resolveEnv, ENVIRONMENTS, stripTrailingSlash } from "./persistence/config.js";
|
|
26
26
|
import { buildConnectUrl } from "./auth/login.js";
|
|
27
|
-
import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, isDeadJwt, revokeToken, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
|
|
27
|
+
import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, isDeadJwt, revokeToken, pendingCookieName, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
|
|
28
28
|
const MCP_PATH = "/mcp";
|
|
29
29
|
const IMAGES_PATH = "/api/images/search";
|
|
30
30
|
const RENDER_SCREENSHOT_PATH = "/api/render/screenshot";
|
|
@@ -112,11 +112,39 @@ const QUERY_AUTH = {
|
|
|
112
112
|
wsid: "x-webcake-session-id",
|
|
113
113
|
session_id: "x-webcake-session-id",
|
|
114
114
|
env: "x-webcake-env",
|
|
115
|
-
api_base: "x-webcake-api-base",
|
|
116
115
|
org_id: "x-webcake-org-id",
|
|
117
|
-
app_base: "x-webcake-app-base",
|
|
118
|
-
builder_base: "x-webcake-builder-base",
|
|
119
116
|
};
|
|
117
|
+
// The backend host receives the caller's JWT, so a remote caller must not pick it: drop
|
|
118
|
+
// every x-webcake-*-base header and keep the env presets / server env. Both views of the
|
|
119
|
+
// headers are cleaned because the transport rebuilds its Request from rawHeaders.
|
|
120
|
+
const BASE_HEADER = /^x-webcake-[a-z]+-base$/i;
|
|
121
|
+
export function stripBaseOverrides(req) {
|
|
122
|
+
for (const h of Object.keys(req.headers))
|
|
123
|
+
if (BASE_HEADER.test(h))
|
|
124
|
+
delete req.headers[h];
|
|
125
|
+
const raw = req.rawHeaders;
|
|
126
|
+
for (let i = raw.length - 2; i >= 0; i -= 2)
|
|
127
|
+
if (BASE_HEADER.test(raw[i]))
|
|
128
|
+
raw.splice(i, 2);
|
|
129
|
+
// `local` points at this server's own loopback — only when the server itself runs local.
|
|
130
|
+
if (/^local$/i.test(String(req.headers["x-webcake-env"] ?? "")) && !/^local$/i.test(process.env.WEBCAKE_ENV ?? "")) {
|
|
131
|
+
delete req.headers["x-webcake-env"];
|
|
132
|
+
for (let i = raw.length - 2; i >= 0; i -= 2)
|
|
133
|
+
if (/^x-webcake-env$/i.test(raw[i]))
|
|
134
|
+
raw.splice(i, 2);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// __Host- (https only) stops a sibling subdomain from planting the cookie for a known state.
|
|
138
|
+
function pendingCookie(issuer, state) {
|
|
139
|
+
const https = issuer.startsWith("https:");
|
|
140
|
+
return {
|
|
141
|
+
name: `${https ? "__Host-" : ""}${pendingCookieName(state)}`,
|
|
142
|
+
attrs: `; HttpOnly; SameSite=Lax${https ? "; Path=/; Secure" : `; Path=${OAUTH_CALLBACK}`}`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function hasCookie(req, name) {
|
|
146
|
+
return String(req.headers.cookie ?? "").split(/;\s*/).includes(`${name}=1`);
|
|
147
|
+
}
|
|
120
148
|
export function applyQueryAuth(req) {
|
|
121
149
|
const q = (req.url ?? "").indexOf("?");
|
|
122
150
|
if (q === -1)
|
|
@@ -257,12 +285,20 @@ async function handleOAuth(req, res, path) {
|
|
|
257
285
|
// Send the user to the SPA login; it returns here with ?token=<ljwt>[&wsid=<lwsid>]&state=<internalState>.
|
|
258
286
|
const callback = `${issuer}${OAUTH_CALLBACK}`;
|
|
259
287
|
const loginUrl = buildConnectUrl(connectPageUrl(), callback, result.internalState);
|
|
260
|
-
|
|
288
|
+
const c = pendingCookie(issuer, result.internalState);
|
|
289
|
+
res.writeHead(302, { location: loginUrl, "set-cookie": `${c.name}=1; Max-Age=600${c.attrs}` });
|
|
261
290
|
return res.end(), true;
|
|
262
291
|
}
|
|
263
292
|
// ---- Login callback: the SPA handed back the user's ljwt → mint a code ----
|
|
264
293
|
if (req.method === "GET" && path === OAUTH_CALLBACK) {
|
|
265
294
|
const sp = new URL(req.url ?? "/", "http://x").searchParams;
|
|
295
|
+
// Only the browser that opened /authorize may complete it — otherwise a link carrying
|
|
296
|
+
// someone else's state binds the victim's login to the attacker's client.
|
|
297
|
+
const state = sp.get("state");
|
|
298
|
+
const c = state ? pendingCookie(issuer, state) : undefined;
|
|
299
|
+
if (!c || !hasCookie(req, c.name)) {
|
|
300
|
+
return htmlError(res, 400, "This connection was not started in this browser — restart it from your AI app."), true;
|
|
301
|
+
}
|
|
266
302
|
const done = await completeAuthorize(sp.get("state"), sp.get("token"), sp.get("wsid") || sp.get("session_id"));
|
|
267
303
|
if (!done.ok)
|
|
268
304
|
return htmlError(res, 400, done.error_description), true;
|
|
@@ -270,7 +306,7 @@ async function handleOAuth(req, res, path) {
|
|
|
270
306
|
r.searchParams.set("code", done.code);
|
|
271
307
|
if (done.state)
|
|
272
308
|
r.searchParams.set("state", done.state);
|
|
273
|
-
res.writeHead(302, { location: r.toString() });
|
|
309
|
+
res.writeHead(302, { location: r.toString(), "set-cookie": `${c.name}=; Max-Age=0${c.attrs}` });
|
|
274
310
|
return res.end(), true;
|
|
275
311
|
}
|
|
276
312
|
// ---- Token ----
|
|
@@ -473,8 +509,9 @@ export async function startHttpServer(port) {
|
|
|
473
509
|
return;
|
|
474
510
|
if (path !== MCP_PATH)
|
|
475
511
|
return rpcError(res, 404, `Not found. Send MCP requests to ${MCP_PATH}.`);
|
|
476
|
-
// Accept credentials via ?jwt=/?
|
|
512
|
+
// Accept credentials via ?jwt=/?env=/... (for clients that can't set headers).
|
|
477
513
|
applyQueryAuth(req);
|
|
514
|
+
stripBaseOverrides(req);
|
|
478
515
|
// OAuth access token → resolve to the user's landing JWT and inject it as the
|
|
479
516
|
// normal x-webcake-jwt header, so persistence/config.ts is unchanged. It WINS over a
|
|
480
517
|
// ?jwt= / x-webcake-jwt: a Bearer from our OAuth flow is what the last Connect issued,
|
|
@@ -495,7 +532,7 @@ export async function startHttpServer(port) {
|
|
|
495
532
|
// for OAuth access tokens.
|
|
496
533
|
const given = req.headers["x-webcake-jwt"];
|
|
497
534
|
const dead = await isDeadJwt(Array.isArray(given) ? given[0] : given);
|
|
498
|
-
if (OAUTH_ENFORCED && (given
|
|
535
|
+
if (OAUTH_ENFORCED && (!given || dead)) {
|
|
499
536
|
res.writeHead(401, {
|
|
500
537
|
"www-authenticate": `Bearer error="invalid_token", resource_metadata="${publicBase(req)}${WELL_KNOWN_PR}"`,
|
|
501
538
|
"content-type": "application/json",
|
package/dist/mcp/params.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
// Typed stand-ins for z.any(): directory reviewers (and some clients) reject
|
|
3
3
|
// params whose JSON Schema has no `type`. Handlers still parse JSON strings.
|
|
4
4
|
// Fresh instance per use: a shared one makes zod-to-json-schema emit a `$ref`.
|
|
5
|
-
const jsonObject = () => z.record(z.any());
|
|
5
|
+
const jsonObject = () => z.record(z.string(), z.any());
|
|
6
6
|
/** A JSON object, or a JSON string of one. */
|
|
7
7
|
export const objectOrJson = () => z.union([jsonObject(), z.string()]);
|
|
8
8
|
/** A JSON object, an array of them, or a JSON string of either. */
|
package/dist/smoke.js
CHANGED
|
@@ -19,7 +19,7 @@ import { matchAccountDomain, normalizeDomain } from "./persistence/domain-match.
|
|
|
19
19
|
import { normalizePhoto, resolvePexelsKey, pexelsKeyFromHeaders, resolvePexelsProxyBase, buildSearchQuery, PEXELS_PROXY_DEFAULT, variantPixels, annotateVariantSizes } from "./persistence/pexels-client.js";
|
|
20
20
|
import { putDraft, getDraft, updateDraft, deleteDraft } from "./persistence/draft-cache.js";
|
|
21
21
|
import { buildConnectUrl, parseCallback } from "./auth/login.js";
|
|
22
|
-
import { redirectMatches, isDeadJwt, markJwtDead } from "./auth/oauth-server.js";
|
|
22
|
+
import { redirectMatches, isDeadJwt, markJwtDead, isAllowedRedirect } from "./auth/oauth-server.js";
|
|
23
23
|
import { isUnauthorized, renewAuthOnExpiry } from "./auth/renew.js";
|
|
24
24
|
import { jwtExpired } from "./persistence/config.js";
|
|
25
25
|
import { isLocalPath, resolveLocalPath, sniffMime, localContentType } from "./tools/media.js";
|
|
@@ -130,6 +130,8 @@ check("good page valid", r1.valid, r1.errors);
|
|
|
130
130
|
check("oauth redirect: exact claude.ai match", redirectMatches("https://claude.ai/api/mcp/auth_callback", "https://claude.ai/api/mcp/auth_callback"));
|
|
131
131
|
check("oauth redirect: loopback any port (Claude Code)", redirectMatches("http://localhost/callback", "http://localhost:3118/callback") && redirectMatches("http://127.0.0.1/callback", "http://127.0.0.1:51234/callback"));
|
|
132
132
|
check("oauth redirect: rejects other path/host/https port drift", !redirectMatches("http://localhost/callback", "http://localhost:3118/evil") && !redirectMatches("http://localhost/callback", "http://127.0.0.1:3118/callback") && !redirectMatches("https://claude.ai/api/mcp/auth_callback", "https://claude.ai:8443/api/mcp/auth_callback") && !redirectMatches("http://evil.com/callback", "http://evil.com:1/callback"));
|
|
133
|
+
check("oauth DCR: allows known clients + loopback", isAllowedRedirect("https://claude.ai/api/mcp/auth_callback") && isAllowedRedirect("https://chatgpt.com/connector_platform_oauth_redirect") && isAllowedRedirect("http://localhost:3118/callback") && isAllowedRedirect("http://[::1]/cb"));
|
|
134
|
+
check("oauth DCR: rejects foreign hosts / http non-loopback / other schemes", !isAllowedRedirect("https://evil.tld/cb") && !isAllowedRedirect("https://claude.ai.evil.tld/cb") && !isAllowedRedirect("http://claude.ai/cb") && !isAllowedRedirect("javascript:alert(1)") && !isAllowedRedirect("nope"));
|
|
133
135
|
check("good page has no dangling-target warnings", r1.warnings.length === 0, r1.warnings);
|
|
134
136
|
check("good page stats", r1.stats.sections === 2 && r1.stats.ids === 3, r1.stats);
|
|
135
137
|
console.log("== validate: catches problems ==");
|
|
@@ -239,8 +239,8 @@ export function registerApiGatewayTools(server) {
|
|
|
239
239
|
id: z.string().optional().describe("Operation id from api_find (preferred)"),
|
|
240
240
|
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).optional().describe("With path, when id is not given"),
|
|
241
241
|
path: z.string().optional().describe("Catalog path with :params, e.g. /api/datasets/records"),
|
|
242
|
-
path_params: z.record(z.string()).optional().describe("Values for :params in the path (page_id, org_id…); org_id defaults to the selected organization"),
|
|
243
|
-
query: z.record(z.any()).optional().describe("Query-string values"),
|
|
242
|
+
path_params: z.record(z.string(), z.string()).optional().describe("Values for :params in the path (page_id, org_id…); org_id defaults to the selected organization"),
|
|
243
|
+
query: z.record(z.string(), z.any()).optional().describe("Query-string values"),
|
|
244
244
|
org_id: z.string().optional().describe("Organization sent as x-org-id ('personal' = none); default: the configured org. Many routes need it."),
|
|
245
245
|
pick: z.array(z.string()).optional().describe("Keep only these fields on each item of a list result (or on a single object)"),
|
|
246
246
|
max_items: z.number().int().min(1).max(500).optional().describe("Cap list results (default 50)"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-landing-mcp",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "MCP server exposing Webcake landing-page element schemas + AI usage hints, and persisting LLM-generated page sources to a Webcake backend.",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/webcake-landing-mcp",
|
|
6
6
|
"type": "module",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
51
51
|
"ajv": "^8.17.1",
|
|
52
52
|
"node-html-parser": "^7.1.0",
|
|
53
|
-
"zod": "^
|
|
53
|
+
"zod": "^4.6.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^22.0.0",
|