brilliant-directories-mcp 6.40.21 → 6.40.22
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/index.js +105 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1335,9 +1335,42 @@ function validatePathParamIds(toolPath, args) {
|
|
|
1335
1335
|
// rgb()/rgba(), all-digit sizes like 16) before validateHeroEnumsInArgs
|
|
1336
1336
|
// rejects anything still invalid. Only applies to createWebPage / updateWebPage.
|
|
1337
1337
|
// Mirrored in Worker's `src/index.ts`. Keep in sync.
|
|
1338
|
-
|
|
1339
|
-
|
|
1338
|
+
// Hero/h1/h2 enum table — every enum-typed field on createWebPage /
|
|
1339
|
+
// updateWebPage that BD persists verbatim to users_meta and renders into CSS
|
|
1340
|
+
// classes or template logic. BD does NOT validate any of these server-side.
|
|
1341
|
+
// An invalid value (e.g. hero_alignment="flex-start", h1_font_weight="bold",
|
|
1342
|
+
// hero_column_width="13") gets stored as-is and breaks rendering — sometimes
|
|
1343
|
+
// silently, sometimes with broken CSS classes that look right but don't match
|
|
1344
|
+
// BD's stylesheet selectors. Fix: validate against the enum set BEFORE
|
|
1345
|
+
// forwarding to BD. Same lists as the spec — keep in sync if BD adds values.
|
|
1346
|
+
// Discrete-range fields from BD's admin UI dropdowns. Generated programmatically
|
|
1347
|
+
// to keep the table readable. Source of truth: BD admin form `<select>` options
|
|
1348
|
+
// for each field (verified live 2026-04-25).
|
|
1349
|
+
const HERO_PADDING_STEPS = Array.from({ length: 21 }, (_, i) => String(i * 10)); // 0..200 step 10
|
|
1350
|
+
const H1_FONT_SIZE_STEPS = Array.from({ length: 51 }, (_, i) => String(30 + i)); // 30..80 step 1
|
|
1351
|
+
const H2_FONT_SIZE_STEPS = Array.from({ length: 41 }, (_, i) => String(20 + i)); // 20..60 step 1
|
|
1352
|
+
const HERO_CONTENT_FONT_SIZE_STEPS = Array.from({ length: 21 }, (_, i) => String(10 + i)); // 10..30 step 1
|
|
1353
|
+
const HERO_ENUM_FIELDS = {
|
|
1354
|
+
hero_link_color: ["primary", "info", "success", "warning", "danger", "default", "secondary"],
|
|
1355
|
+
hero_link_size: ["", "btn-lg", "btn-xl"],
|
|
1356
|
+
hero_link_target_blank: ["0", "1"],
|
|
1357
|
+
hero_alignment: ["left", "center", "right"],
|
|
1358
|
+
hero_column_width: ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
1359
|
+
hero_background_image_size: ["mobile-ready", "standard"],
|
|
1360
|
+
hero_hide_banner_ad: ["0", "1"],
|
|
1361
|
+
hero_content_overlay_opacity: ["0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1"],
|
|
1362
|
+
hero_top_padding: HERO_PADDING_STEPS,
|
|
1363
|
+
hero_bottom_padding: HERO_PADDING_STEPS,
|
|
1364
|
+
h1_font_size: H1_FONT_SIZE_STEPS,
|
|
1365
|
+
h2_font_size: H2_FONT_SIZE_STEPS,
|
|
1366
|
+
hero_content_font_size: HERO_CONTENT_FONT_SIZE_STEPS,
|
|
1367
|
+
h1_font_weight: ["300", "400", "600", "800"],
|
|
1368
|
+
h2_font_weight: ["300", "400", "600", "800"],
|
|
1369
|
+
};
|
|
1370
|
+
const HERO_LINK_COLOR_VALUES = new Set(HERO_ENUM_FIELDS.hero_link_color);
|
|
1371
|
+
const HERO_LINK_SIZE_VALUES = new Set(HERO_ENUM_FIELDS.hero_link_size);
|
|
1340
1372
|
const HERO_ENUM_TOOLS = new Set(["createWebPage", "updateWebPage"]);
|
|
1373
|
+
|
|
1341
1374
|
/** Coerce common agent mistakes before validate — BD builds `btn-${color}` + size class verbatim. */
|
|
1342
1375
|
function sanitizeHeroCtaEnumsInArgs(toolName, args) {
|
|
1343
1376
|
if (!HERO_ENUM_TOOLS.has(toolName) || !args || typeof args !== "object") return;
|
|
@@ -1365,16 +1398,17 @@ function sanitizeHeroCtaEnumsInArgs(toolName, args) {
|
|
|
1365
1398
|
}
|
|
1366
1399
|
}
|
|
1367
1400
|
}
|
|
1401
|
+
|
|
1368
1402
|
function validateHeroEnumsInArgs(toolName, args) {
|
|
1369
1403
|
if (!HERO_ENUM_TOOLS.has(toolName) || !args || typeof args !== "object") return null;
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
if (!
|
|
1377
|
-
return
|
|
1404
|
+
for (const [field, allowed] of Object.entries(HERO_ENUM_FIELDS)) {
|
|
1405
|
+
const v = args[field];
|
|
1406
|
+
if (v === undefined || v === null) continue;
|
|
1407
|
+
// Empty string is allowed only if "" is in the enum (e.g. hero_link_size).
|
|
1408
|
+
if (v === "" && !allowed.includes("")) continue;
|
|
1409
|
+
const s = String(v);
|
|
1410
|
+
if (!allowed.includes(s)) {
|
|
1411
|
+
return `${field} must be one of: ${allowed.map((x) => `"${x}"`).join(", ")} (you sent: "${s}"). Invalid values are persisted verbatim — BD does not validate server-side, so the value renders as a broken CSS class or breaks the hero layout.`;
|
|
1378
1412
|
}
|
|
1379
1413
|
}
|
|
1380
1414
|
return null;
|
|
@@ -2001,22 +2035,38 @@ async function main() {
|
|
|
2001
2035
|
}
|
|
2002
2036
|
}
|
|
2003
2037
|
|
|
2004
|
-
// TRANSPORT STABILITY GUARD — auto-throttle heavy reads
|
|
2005
|
-
//
|
|
2006
|
-
//
|
|
2007
|
-
//
|
|
2008
|
-
//
|
|
2009
|
-
//
|
|
2010
|
-
//
|
|
2011
|
-
//
|
|
2038
|
+
// TRANSPORT STABILITY GUARD — auto-throttle heavy reads.
|
|
2039
|
+
//
|
|
2040
|
+
// When ANY include_* flag is true, each row balloons (users: ~5-10KB
|
|
2041
|
+
// with subscription/services/photos/transactions schemas; web pages:
|
|
2042
|
+
// 14-41KB with content+code blobs). At limit=50 a single response can
|
|
2043
|
+
// exceed 300KB-2MB, which the MCP transport (stdio buffer, Streamable
|
|
2044
|
+
// HTTP, SSE) intermittently truncates without a clean error — agents
|
|
2045
|
+
// see silent timeouts. Cap progressively and add a `_throttled` warning.
|
|
2046
|
+
// Adjustment, not rejection: agent always gets results; the warning
|
|
2047
|
+
// teaches them to paginate or drop heavy includes.
|
|
2048
|
+
//
|
|
2049
|
+
// Throttle tiers:
|
|
2050
|
+
// USER_READ_TOOLS + any include_* flag → cap limit at 25
|
|
2051
|
+
// listWebPages + any include_* flag → cap limit at 25
|
|
2052
|
+
// listWebPages + include_content AND include_code → cap limit at 10 (worst case — both heavy buckets)
|
|
2012
2053
|
let _throttleWarning = null;
|
|
2013
|
-
if (
|
|
2054
|
+
if (args && typeof args === "object") {
|
|
2014
2055
|
const heavyActive = Object.values(includeFlags).some((v) => v === true || v === "1" || v === 1);
|
|
2015
2056
|
const requested = Number(args.limit);
|
|
2016
|
-
if (heavyActive && Number.isFinite(requested) && requested > 25) {
|
|
2057
|
+
if (isUserReadTool && heavyActive && Number.isFinite(requested) && requested > 25) {
|
|
2017
2058
|
_throttleWarning = `limit reduced from ${requested} to 25 because heavy include_* flag is set. To get more rows: (1) paginate with next_page, (2) drop include_* for a lean enumeration first then call getUser per-record for the few you need enriched, or (3) call without include_* and re-query specific user_ids individually.`;
|
|
2018
2059
|
args.limit = 25;
|
|
2019
2060
|
console.error(`[throttle] ${name}: ${_throttleWarning}`);
|
|
2061
|
+
} else if (name === "listWebPages" && heavyActive && Number.isFinite(requested)) {
|
|
2062
|
+
const bothHeavy = (includeFlags.include_content === true || includeFlags.include_content === "1" || includeFlags.include_content === 1) &&
|
|
2063
|
+
(includeFlags.include_code === true || includeFlags.include_code === "1" || includeFlags.include_code === 1);
|
|
2064
|
+
const cap = bothHeavy ? 10 : 25;
|
|
2065
|
+
if (requested > cap) {
|
|
2066
|
+
_throttleWarning = `limit reduced from ${requested} to ${cap} because ${bothHeavy ? "BOTH include_content AND include_code are set (heaviest combo — pages can be 30-40KB each)" : "a heavy include_* flag is set"}. To get more rows: (1) paginate with next_page, (2) drop include_* for a lean enumeration first then call getWebPage per-record for the few you need enriched, or (3) split the read — separate calls with include_content=true and include_code=true.`;
|
|
2067
|
+
args.limit = cap;
|
|
2068
|
+
console.error(`[throttle] ${name}: ${_throttleWarning}`);
|
|
2069
|
+
}
|
|
2020
2070
|
}
|
|
2021
2071
|
}
|
|
2022
2072
|
|
|
@@ -2167,6 +2217,41 @@ async function main() {
|
|
|
2167
2217
|
};
|
|
2168
2218
|
}
|
|
2169
2219
|
|
|
2220
|
+
// Duplicate-filename guard for createWebPage. BD does NOT enforce
|
|
2221
|
+
// unique `filename` on `list_seo` — two creates with the same slug
|
|
2222
|
+
// both succeed and the public URL renders one of them non-deterministically
|
|
2223
|
+
// (silent destructive: agent thinks the new page is live but it may
|
|
2224
|
+
// be the OLD one shadowing it). Pre-check via listWebPages — one
|
|
2225
|
+
// small filtered query — and reject if a row exists. Bypass with
|
|
2226
|
+
// `force_duplicate_filename=true` for the rare legitimate case
|
|
2227
|
+
// (e.g. intentional shadow page, internal fork).
|
|
2228
|
+
if (name === "createWebPage" && args && typeof args === "object" && args.filename) {
|
|
2229
|
+
const force = args.force_duplicate_filename === true || args.force_duplicate_filename === "1" || args.force_duplicate_filename === 1;
|
|
2230
|
+
if (force) {
|
|
2231
|
+
delete args.force_duplicate_filename; // never forward to BD
|
|
2232
|
+
} else {
|
|
2233
|
+
try {
|
|
2234
|
+
const dupCheck = await makeRequest(
|
|
2235
|
+
config,
|
|
2236
|
+
"GET",
|
|
2237
|
+
"/api/v2/list_seo/get",
|
|
2238
|
+
{ property: "filename", property_value: String(args.filename), property_operator: "=", limit: 1 },
|
|
2239
|
+
null
|
|
2240
|
+
);
|
|
2241
|
+
const rows = dupCheck && dupCheck.body && Array.isArray(dupCheck.body.message) ? dupCheck.body.message : [];
|
|
2242
|
+
const existing = rows.find((r) => r && String(r.filename) === String(args.filename));
|
|
2243
|
+
if (existing) {
|
|
2244
|
+
return {
|
|
2245
|
+
content: [{ type: "text", text: `filename '${args.filename}' already exists at seo_id=${existing.seo_id}. Use updateWebPage(seo_id=${existing.seo_id}, ...) to modify, or pick a unique slug. Bypass with force_duplicate_filename=true if you genuinely need a duplicate (rare).` }],
|
|
2246
|
+
isError: true,
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
} catch (err) {
|
|
2250
|
+
console.error(`[createWebPage] duplicate-filename pre-check failed (${err && err.message ? err.message : "unknown"}); proceeding with create — caller should manually verify uniqueness post-create.`);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2170
2255
|
// EAV split: peel hero/EAV fields off updateWebPage args before the
|
|
2171
2256
|
// parent update. Flushed via users_meta after the parent succeeds.
|
|
2172
2257
|
const { direct: eavDirect, eav: eavQueued, route: eavRoute } = splitEavParams(name, args || {});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brilliant-directories-mcp",
|
|
3
3
|
"mcpName": "io.github.brilliantdirectories/brilliant-directories-mcp",
|
|
4
|
-
"version": "6.40.
|
|
4
|
+
"version": "6.40.22",
|
|
5
5
|
"description": "Official MCP server for Brilliant Directories — manage members, posts, leads, reviews, and more.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"bin": {
|