diff --git a/mcp/src/index.ts b/mcp/src/index.ts index 4a5974c..7dcc0a2 100644 --- a/mcp/src/index.ts +++ b/mcp/src/index.ts @@ -14,6 +14,22 @@ const _app = new Hono<{ Bindings: Env; Variables: { org_namespace: string; partn // 安全模型見 mcp/OAUTH.md。註冊在 basePath 之前,落在同一份共享 router。 registerOAuthRoutes(_app); +// ── GET /health — 一條 curl 看出「這台是哪一代 MCP」──────────────────────────────── +// 為什麼要有:判斷一台實例的 MCP 是新舊世代,原本只能打 /authorize 去剖 HTML 有幾個 +// 欄位(ops-facts 2026-08-10 的土法)。那個判準脆弱又難教。改成誠實的版本面: +// • 回 200 且 auth="portal-login" = 新世代(同意頁用 Portal email+password) +// • 回 404 = 舊世代(b8ca98c 之前,同意頁要 MCP_OWNER_SECRET, +// 而那把祕密沒有人拿得到 ⇒ 等於接不上) +// AUTH_GENERATION 跟著認證機制改才動;MCP_BUILD 是部署標記(deploy 時由 toml var 帶入)。 +// 對齊 cypher-executor /health 的形狀(ok + 版本 + 能力探針),不需認證、不吐任何機密。 +_app.get("/health", (c) => c.json({ + ok: true, + service: "arcrun-mcp", + auth: "portal-login", + build: c.env.MCP_BUILD ?? "unknown", + oauth_kv: c.env.OAUTH_KV ? "present" : "missing", +})); + const app = _app.basePath('/mcp'); app.use("*", cors({ diff --git a/mcp/src/types.ts b/mcp/src/types.ts index bd27223..fa3d968 100644 --- a/mcp/src/types.ts +++ b/mcp/src/types.ts @@ -38,6 +38,9 @@ export interface Env { // 允許的 redirect_uri host 白名單(逗號分隔)。DCR 無狀態故靠此擋 open-redirect/釣魚。 // 未設 → 預設只允許 claude.ai / claude.com / anthropic.com(含子網域)+ localhost。 MCP_ALLOWED_REDIRECT_HOSTS?: string; + // 部署標記(非機密):GET /health 原樣回報,讓「這台跑的是哪一版」用一條 curl 看得到。 + // 由各實例的 wrangler toml [vars] 帶入;沒帶 → /health 回 build:"unknown"(誠實,不假裝)。 + MCP_BUILD?: string; } export interface ToolContext {