Slima MCP

進階:Debug OAuth 流程

閱讀約 6 分鐘

Web OAuth client 連不上 + 沒看到 reauth 跳出 → 多半是某一步靜默失敗。這篇教你 trace。

Slima Authorized Apps:OAuth 流程成功後 client 會出現在此頁

OAuth 9 步全流程

1. Client → POST /register (DCR — Dynamic Client Registration)
   ← 200 + client_id

2. Client → GET /.well-known/oauth-authorization-server
   ← 200 + OAuth metadata

3. Client → 開啟 /authorize?client_id=...&code_challenge=...
   ← Slima 顯示登入頁 / 授權頁

4. User → 點「授權」
   ← Slima 跳轉到 client 設的 redirect_uri + code=xxx

5. Client → POST /token (with code + code_verifier)
   ← 200 + access_token + refresh_token

6. Client → GET /mcp (Authorization: Bearer access_token)
   ← 200 + MCP capabilities

7-9. 後續每次 tool call:
     Client → POST /mcp/tools/call (+ Authorization)
     ← 200 + result

Self-host:wrangler tail

如果你 self-host

wrangler tail my-slima-mcp

即時看 worker logs、能看到每一步哪邊失敗。

Production:報告事件

如果用 Slima 官方 server 連不上:

  1. 看 client 的 logs(Claude Desktop / Cursor / ChatGPT)找最後一步成功的 + 失敗的 step
  2. 截圖 + 從 Report a bug / Contact support 回報
  3. 附上:用什麼 client、什麼版本、撞到的 error code

用 curl 手動測

測 DCR

curl -X POST https://mcp.slima.ai/register \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "test",
    "redirect_uris": ["http://localhost:8901/callback"]
  }'

預期 200 + { client_id: "...", ... }

測 well-known

curl https://mcp.slima.ai/.well-known/oauth-authorization-server

預期 OAuth metadata JSON

用 access token call /mcp

curl https://mcp.slima.ai/mcp \
  -H "Authorization: Bearer your_access_token"

預期 200 + MCP capabilities

常見失敗點

失敗 處理
1 (DCR) 400 invalid_redirect_uri 確認 client 設的 redirect_uri 是 https 或 http://localhost
2 (well-known) 404 server URL 錯了
3 (authorize) 跳轉沒進 Slima 網路 / DNS / proxy 問題
4 (callback) redirect_uri mismatch DCR 註冊的 redirect_uri 跟 callback 不一致
5 (token exchange) invalid_grant code 過期(30 秒),重來
6 (mcp) 401 token 沒帶 Authorization header

相關

這篇有幫助嗎?