feat(mcp): expose /mcp as clean public endpoint (#2411)

Adds a /mcp rewrite in vercel.json pointing to /api/mcp, so MCP clients
(Claude Desktop, etc.) can connect to https://api.worldmonitor.app/mcp
instead of /api/mcp.

Benefits: cleaner URL for docs/config, CF bot-blocking rules target /api/*
only so /mcp bypasses them without needing extra CF rule exceptions.

Also adds CORS headers for /mcp and excludes it from the SPA rewrite and
no-cache catch-all patterns. Updates deploy-config test to match new pattern.
This commit is contained in:
Elie Habib
2026-03-28 12:06:18 +04:00
committed by GitHub
parent e6a85f0a36
commit 1635ad3898
2 changed files with 12 additions and 3 deletions

View File

@@ -7,7 +7,8 @@
"rewrites": [
{ "source": "/docs/:match*", "destination": "https://worldmonitor.mintlify.dev/docs/:match*" },
{ "source": "/pro", "destination": "/pro/index.html" },
{ "source": "/((?!api|assets|blog|docs|favico|map-styles|data|textures|pro|sw\\.js|workbox-[a-f0-9]+\\.js|manifest\\.webmanifest|offline\\.html|robots\\.txt|sitemap\\.xml|llms\\.txt|llms-full\\.txt|\\.well-known|wm-widget-sandbox\\.html).*)", "destination": "/index.html" }
{ "source": "/mcp", "destination": "/api/mcp" },
{ "source": "/((?!api|mcp|assets|blog|docs|favico|map-styles|data|textures|pro|sw\\.js|workbox-[a-f0-9]+\\.js|manifest\\.webmanifest|offline\\.html|robots\\.txt|sitemap\\.xml|llms\\.txt|llms-full\\.txt|\\.well-known|wm-widget-sandbox\\.html).*)", "destination": "/index.html" }
],
"headers": [
{
@@ -18,6 +19,14 @@
{ "key": "Access-Control-Allow-Headers", "value": "Content-Type, Authorization, X-WorldMonitor-Key, X-Widget-Key, X-Pro-Key" }
]
},
{
"source": "/mcp",
"headers": [
{ "key": "Access-Control-Allow-Origin", "value": "*" },
{ "key": "Access-Control-Allow-Methods", "value": "GET, POST, OPTIONS" },
{ "key": "Access-Control-Allow-Headers", "value": "Content-Type, Authorization, X-WorldMonitor-Key" }
]
},
{
"source": "/docs/:path*",
"headers": [
@@ -50,7 +59,7 @@
]
},
{
"source": "/((?!api|assets|blog|docs|favico|map-styles|data|textures|pro|sw\\.js|workbox-[a-f0-9]+\\.js|manifest\\.webmanifest|offline\\.html|robots\\.txt|sitemap\\.xml|llms\\.txt|llms-full\\.txt|\\.well-known|wm-widget-sandbox\\.html).*)",
"source": "/((?!api|mcp|assets|blog|docs|favico|map-styles|data|textures|pro|sw\\.js|workbox-[a-f0-9]+\\.js|manifest\\.webmanifest|offline\\.html|robots\\.txt|sitemap\\.xml|llms\\.txt|llms-full\\.txt|\\.well-known|wm-widget-sandbox\\.html).*)",
"headers": [
{ "key": "Cache-Control", "value": "no-cache, no-store, must-revalidate" }
]