Skip to content

Rewrite mcp.longbridge.com to .cn for CN region build#1102

Merged
hold-baby merged 1 commit into
mainfrom
feat/cn_region_rewrite_mcp_hostname
Jun 18, 2026
Merged

Rewrite mcp.longbridge.com to .cn for CN region build#1102
hold-baby merged 1 commit into
mainfrom
feat/cn_region_rewrite_mcp_hostname

Conversation

@hold-baby

Copy link
Copy Markdown
Collaborator

Merge Verdict

[APPROVE] — Small, mechanical extension of the existing region rewrite to cover a third root domain (mcp.longbridge.com).

3 files · +8 / -1 · region.config.ts docs/.vitepress/


Summary

  • region.config.ts: RegionConfig interface gains a new required field mcpHostname; CN region sets it to https://mcp.longbridge.cn.
  • docs/.vitepress/region-utils.ts: buildRegionUrlReplacements() emits a third pair of rules (URL + bare-text) for the MCP hostname — same shape as the existing siteHostname / apiBaseUrl blocks.
  • docs/.vitepress/config.mts: MCP_TOOLS_URL (used by the fetch-mcp-tools build-time plugin) now resolves to ${regionCfg?.mcpHostname || 'https://mcp.longbridge.com'}/mcp/tools.json — CN builds source the tool catalogue from the regional endpoint instead of .com.

Risk Analysis

Risk Level Mitigation
mcp.longbridge.cn/mcp/tools.json endpoint not yet live 🟡 Reviewer to confirm before merge — fetch-mcp-tools will hard-fail the CN build if the URL 404s
Global build (build:release) regression Verified: with no VITE_REGION, regionCfg is undefined → helper returns [] for MCP rules; MCP_TOOLS_URL falls back to mcp.longbridge.com; mcp.html keeps 7 .com + 1 .cn (original "China mainland" section) identical to source
Order-dependent rewriting between mcp / open / openapi All three hostnames are mutually non-substring (different 5th char or different prefix), so the three protocol-prefixed + three bare-text rules are independent regardless of order
Mainland users on global .cn site getting wrong fallback This PR only adds a CN-only rule; nothing about the global path changes

Design Decisions

  • Add mcpHostname to RegionConfig rather than hardcoding inside the helper — keeps the regional URL list in one declarative file (region.config.ts) instead of scattering string constants across region-utils.ts. Matches the pattern already set by siteHostname / apiBaseUrl.
  • Switch the build-time fetch source, not just the displayed URL — chosen so the CN build's mcp-tools.json actually reflects the catalogue served by the CN MCP endpoint (potentially region-specific tools), instead of CN docs displaying .cn while embedded data was scraped from .com.
  • Field is required, not optional — every region must declare its MCP hostname explicitly; prevents silent fallback to .com when a new region is added.

Code Notes

  1. [Needs review] Confirm https://mcp.longbridge.cn/mcp/tools.json is live and returns the same JSON shape as the global endpoint before merge. If not yet deployed, the CN build will fail at fetch-mcp-tools buildStart with an HTTP error.

Verification

  • bun run build:cn succeeds; rg -l '(open|openapi|mcp)\.longbridge\.com' docs/.vitepress/dist → zero residual .com across HTML / MD / JS / install scripts / mcp-tools.json.
  • bun run build:release succeeds; dist/docs/mcp.md per-file domain distribution (1× mcp.longbridge.cn + 7× mcp.longbridge.com) matches source 1:1.
  • ✅ Source install.ps1 is byte-identical to global build output (no accidental rewrite).

Extend the region rewrite mechanism to cover the third root domain
(`mcp.longbridge.com`), which was previously untouched.

- region.config: add `mcpHostname` field to `RegionConfig` interface;
  CN region sets it to `https://mcp.longbridge.cn`.
- region-utils: `buildRegionUrlReplacements()` now emits the third
  pair of rules (URL form + bare-text form) for the MCP hostname.
- config.mts: `MCP_TOOLS_URL` resolves from `regionCfg?.mcpHostname`,
  so CN builds fetch tools.json from `mcp.longbridge.cn` instead of
  `.com` — keeps build-time data sourced from the regional endpoint.

Global build is unaffected: with no VITE_REGION the helper still
returns no rules for mcp.* (same no-op contract as the other two
hostnames).
@hold-baby hold-baby merged commit 7571ffc into main Jun 18, 2026
2 checks passed
@hold-baby hold-baby deleted the feat/cn_region_rewrite_mcp_hostname branch June 18, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant