brilliant-directories-mcp 6.40.76 → 6.40.78

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 CHANGED
@@ -2018,6 +2018,91 @@ function _validateSlugFormat(slug, fieldLabel, allowSlash) {
2018
2018
  return null;
2019
2019
  }
2020
2020
 
2021
+ // profile_search_results segment-binding validator. BD's dynamic router
2022
+ // resolves /seo_type=profile_search_results URLs only when each slug segment
2023
+ // maps to a real BD record at a position-valid hierarchy slot
2024
+ // (country/state/city/top/sub, strict order, any subset valid as long as
2025
+ // relative order is preserved). Without this guard the wrapper accepts
2026
+ // arbitrary slugs and BD silent-404s the public URL — agent gets `success`
2027
+ // but the page renders no member results. Walk segments left-to-right;
2028
+ // each segment must match a slot at-or-after the previously locked floor.
2029
+ // Falls open with a soft warning on transient probe failure (same fail-open
2030
+ // pattern as slug-uniqueness probes per v6.40.63).
2031
+ async function _validateProfileSearchResultsSegments(config, args) {
2032
+ if (String(args.seo_type || "").toLowerCase() !== "profile_search_results") return null;
2033
+ if (typeof args.filename !== "string" || args.filename === "") return null;
2034
+
2035
+ const segments = args.filename.split("/").filter(Boolean);
2036
+ if (segments.length === 0) return null;
2037
+
2038
+ // Pre-fetch countries once (no country_filename column — derive slug from name)
2039
+ let countries = null;
2040
+ let countryProbeFailed = false;
2041
+ const tryCountry = async (seg) => {
2042
+ if (countries === null && !countryProbeFailed) {
2043
+ try {
2044
+ const r = await makeRequest(config, "GET", "/api/v2/list_countries/get", { limit: 250 }, null);
2045
+ countries = (r && r.body && Array.isArray(r.body.message))
2046
+ ? r.body.message.map((c) => String(c.country_name || "").toLowerCase().replace(/\s+/g, "-"))
2047
+ : [];
2048
+ } catch {
2049
+ countryProbeFailed = true;
2050
+ countries = [];
2051
+ }
2052
+ }
2053
+ return countries.includes(seg.toLowerCase());
2054
+ };
2055
+
2056
+ const slots = ["country", "state", "city", "top", "sub"];
2057
+ let floor = 0;
2058
+ const validated = [];
2059
+
2060
+ for (let i = 0; i < segments.length; i++) {
2061
+ const seg = segments[i];
2062
+ let matched = -1;
2063
+ let segProbeFailures = 0;
2064
+ let segProbeAttempts = 0;
2065
+ for (let s = floor; s < slots.length; s++) {
2066
+ let hit = false;
2067
+ let probeFailed = false;
2068
+ segProbeAttempts++;
2069
+ try {
2070
+ if (slots[s] === "country") {
2071
+ hit = await tryCountry(seg);
2072
+ if (countryProbeFailed) probeFailed = true;
2073
+ } else {
2074
+ let table, field;
2075
+ if (slots[s] === "state") { table = "location_states"; field = "state_filename"; }
2076
+ else if (slots[s] === "city") { table = "location_cities"; field = "city_filename"; }
2077
+ else if (slots[s] === "top") { table = "list_professions"; field = "filename"; }
2078
+ else if (slots[s] === "sub") { table = "list_services"; field = "filename"; }
2079
+ const rows = await _slugProbeTable(config, table, field, seg, 1);
2080
+ if (rows === null) probeFailed = true;
2081
+ else hit = rows.length > 0;
2082
+ }
2083
+ } catch {
2084
+ probeFailed = true;
2085
+ }
2086
+ if (probeFailed) segProbeFailures++;
2087
+ if (hit) { matched = s; break; }
2088
+ }
2089
+ if (matched < 0) {
2090
+ // Fall open only if EVERY probe attempt for THIS segment failed
2091
+ // transiently (BD outage / per-key permission gating). Per-segment
2092
+ // counters — accumulating across segments would mask real rejects.
2093
+ if (segProbeAttempts > 0 && segProbeFailures === segProbeAttempts) {
2094
+ return { ok: true, segment_warning: `profile_search_results segment validation could not run on '${args.filename}' — BD probes failed transiently. Page write allowed; verify the slug renders publicly post-write.` };
2095
+ }
2096
+ return {
2097
+ error: `profile_search_results filename '${args.filename}' segment ${i + 1} ('${seg}') doesn't match any valid country/state/city/top-category/sub-category slug at this position. Slug segments must come from live BD lookups (listCountries / listStates / listCities / listTopCategories / listSubCategories) and follow the order country/state/city/top/sub. For arbitrary URL static pages, use seo_type=content instead.`,
2098
+ };
2099
+ }
2100
+ validated.push({ slot: slots[matched], value: seg });
2101
+ floor = matched + 1;
2102
+ }
2103
+ return { ok: true, segments_validated: validated };
2104
+ }
2105
+
2021
2106
  /** Look up rows in one BD table whose `field` equals the slug. */
2022
2107
  async function _slugProbeTable(config, table, field, slug, limit) {
2023
2108
  try {
@@ -3236,8 +3321,22 @@ async function main() {
3236
3321
  }
3237
3322
  let _slugAdjusted = null;
3238
3323
  let _slugProbeWarning = null;
3324
+ let _segmentsValidated = null;
3325
+ let _segmentWarning = null;
3239
3326
  if (slugGuard && slugGuard.adjusted) _slugAdjusted = slugGuard.adjusted;
3240
3327
  if (slugGuard && slugGuard.probe_warning) _slugProbeWarning = slugGuard.probe_warning;
3328
+
3329
+ // profile_search_results segment-binding guard. Catches silent-404
3330
+ // slugs (segments don't map to real BD records). Only fires on
3331
+ // createWebPage / updateWebPage with seo_type=profile_search_results.
3332
+ if ((name === "createWebPage" || name === "updateWebPage") && args && typeof args === "object") {
3333
+ const segGuard = await _validateProfileSearchResultsSegments(config, args);
3334
+ if (segGuard && segGuard.error) {
3335
+ return { content: [{ type: "text", text: segGuard.error }], isError: true };
3336
+ }
3337
+ if (segGuard && segGuard.segments_validated) _segmentsValidated = segGuard.segments_validated;
3338
+ if (segGuard && segGuard.segment_warning) _segmentWarning = segGuard.segment_warning;
3339
+ }
3241
3340
  // Defensive: if any old client still sends the removed bypass flag.
3242
3341
  if (args && typeof args === "object" && "force_duplicate_filename" in args) delete args.force_duplicate_filename;
3243
3342
 
@@ -3548,6 +3647,14 @@ async function main() {
3548
3647
  if (_slugProbeWarning && result.body && typeof result.body === "object") {
3549
3648
  result.body._slug_probe_warning = _slugProbeWarning;
3550
3649
  }
3650
+ // profile_search_results segment-binding feedback — agent confirmation
3651
+ // that each slug segment mapped to a real BD record (or transient warning).
3652
+ if (_segmentsValidated && result.body && typeof result.body === "object") {
3653
+ result.body._segments_validated = _segmentsValidated;
3654
+ }
3655
+ if (_segmentWarning && result.body && typeof result.body === "object") {
3656
+ result.body._segment_warning = _segmentWarning;
3657
+ }
3551
3658
 
3552
3659
  // Auto-refresh site cache after successful cache-gated writes.
3553
3660
  // Lenient: annotation-only on failure; never fails the parent response.
@@ -527,9 +527,9 @@ Set the current time in every exposed timestamp field on every update. On create
527
527
 
528
528
  **Member Search Results SEO pages - thin-content remedy.** BD auto-generates dynamic search URLs for every location+category combo (e.g. `california/beverly-hills/plumbers`). Google penalizes thin pages (1-2 members). Convert to static via `createWebPage` with `seo_type="profile_search_results"` + `filename=<exact slug>` + custom SEO copy in `content`.
529
529
 
530
- Slug hierarchy (no leading slash, `/`-separated, any left-parent droppable): `country/state/city/top_cat/sub_cat`.
530
+ Slug hierarchy: `country/state/city/top/sub` — strict order, any subset valid (skip any segment from any position). Examples: `country/state/city/sub`, `top/sub`, `country/state/top`, `state/sub`, `top` alone, `city` alone, `united-states` alone. No leading slash; `/`-separated.
531
531
 
532
- **CRITICAL: `filename` MUST be a real location/category slug BD's dynamic router recognizes.** Arbitrary/made-up slugs (`my-cool-page`, `foo-bar`) return HTTP 404 publicly even though the `list_seo` record is created successfully - BD has no dynamic page to override. Bare category slugs (`/strength-training`) and full hierarchies (`/california/los-angeles/personal-trainer`) both work; country-only slug (`united-states` alone) does NOT render. For arbitrary-URL static pages with no underlying category/location route, use `seo_type=content` instead.
532
+ **CRITICAL: `filename` MUST be a real location/category slug BD's dynamic router recognizes** (wrapper validates this — see runtime guard). Arbitrary/made-up slugs (`my-cool-page`, `foo-bar`) return HTTP 404 publicly even though the `list_seo` record is created successfully - BD has no dynamic page to override. Bare category slugs (`/strength-training`) and full hierarchies (`/california/los-angeles/personal-trainer`) both work. For arbitrary-URL static pages with no underlying category/location route, use `seo_type=content` instead.
533
533
 
534
534
  Every slug segment must come from live lookups:
535
535
 
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.76",
4
+ "version": "6.40.78",
5
5
  "description": "Official MCP server for Brilliant Directories — manage members, posts, leads, reviews, and more.",
6
6
  "main": "index.js",
7
7
  "bin": {