分析脈絡
對應提問
如何在 Claude Code 中設定 Tableau MCP Server?
拆解方式
- 在 Tableau 建立 Personal Access Token
- 下載 TWCA 中間憑證解決 SSL 問題
- 使用 claude mcp add CLI 指令新增 MCP server
- 驗證連線狀態
資料來源與欄位
- KKday Tableau Server (https://tableau.kkday.com)
資料區間
2026-03-20
Claude Code vs Claude Desktop
本文件針對 Claude Code(CLI 版本)。如果你使用的是 Claude Desktop(桌面 App),請參考另一份指南。
兩者最大的差異在於 MCP 設定方式:Claude Desktop 編輯 JSON 設定檔;Claude Code 使用 claude mcp add CLI 指令。
前置需求
| 項目 | 說明 |
|---|---|
| Node.js | v22.7.5 以上(終端機執行 node --version 確認) |
| Claude Code | 已安裝 CLI 並登入(claude --version 確認) |
| Tableau 帳號 | 需有 KKday Tableau Server 的存取權限 |
| PAT 權限 | Tableau 管理員需已啟用 Personal Access Token 功能 |
設定步驟
依序完成以下 4 個步驟即可完成連線。
Step 1:在 Tableau 建立 Personal Access Token
- 登入 https://tableau.kkday.com
- 點右上角個人頭像 → My Account Settings
- 滾到 Personal Access Tokens 區塊
- 點 Create Token
- 輸入名稱(例如
claude-mcp),這就是你的 PAT_NAME - 建立後會顯示一組 secret,立即複製存好,這就是你的 PAT_VALUE
Secret 只顯示一次
關掉對話框就看不到了。PAT 15 天沒使用會自動過期,需要重新建立。
關掉對話框就看不到了。PAT 15 天沒使用會自動過期,需要重新建立。
Step 2:下載 TWCA 中間憑證
KKday 的 Tableau Server 使用 TWCA(台灣網路認證中心)簽發的 SSL 憑證,但伺服器沒有附上完整的憑證鏈,Node.js 預設無法驗證信任。需要手動下載中間憑證。
在終端機執行:
# 建立存放目錄
mkdir -p ~/.ssl
# 從 TWCA 下載中間憑證並轉換格式
curl -s "http://sslserver.twca.com.tw/cacert/secure_sha2_2023G3.crt" \
-o /tmp/twca-intermediate.crt \
&& openssl x509 -in /tmp/twca-intermediate.crt -inform DER \
-out ~/.ssl/twca-intermediate.pem -outform PEM
# 驗證憑證是否正確
openssl x509 -in ~/.ssl/twca-intermediate.pem -subject -issuer -noout
應該會看到:
subject=C=TW, O=TAIWAN-CA, CN=TWCA Secure SSL Certification Authority
issuer=C=TW, O=TAIWAN-CA, OU=Root CA, CN=TWCA Global Root CA
Step 3:用 CLI 指令新增 Tableau MCP
Claude Code ≠ Claude Desktop
Claude Desktop 是編輯
不要手動編輯
Claude Desktop 是編輯
claude_desktop_config.json;Claude Code 則使用 claude mcp add CLI 指令來管理 MCP server,設定會寫入 ~/.claude.json。不要手動編輯
settings.json 的 mcpServers 區塊,那樣不會生效。在終端機執行:
claude mcp add tableau \
--transport stdio \
-e SERVER=https://tableau.kkday.com \
-e PAT_NAME=你的PAT名稱 \
-e "PAT_VALUE=你的PAT密碼" \
-e NODE_EXTRA_CA_CERTS=/Users/你的使用者名稱/.ssl/twca-intermediate.pem \
-s user \
-- npx -y @tableau/mcp-server@latest
參數說明:
| 參數 | 說明 |
|---|---|
--transport stdio | 使用 stdio 傳輸協定 |
-e KEY=VALUE | 設定環境變數(SERVER、PAT_NAME、PAT_VALUE、NODE_EXTRA_CA_CERTS) |
-s user | 安裝到 user 層(所有專案共用) |
-- npx -y ... | MCP server 的啟動指令(-- 後面是實際執行的命令) |
Scope 選擇
-s user(全域,所有專案共用)vs -s project(僅當前專案)。一般建議用 user。Step 4:驗證連線
在終端機執行:
claude mcp list
預期看到:
tableau: npx -y @tableau/mcp-server@latest - ✓ Connected
如果顯示 ✓ Connected 就代表設定成功。重新啟動 Claude Code 對話即可使用 Tableau 工具。
常用 MCP 管理指令
| 指令 | 用途 |
|---|---|
claude mcp list | 列出所有已設定的 MCP server 及連線狀態 |
claude mcp remove tableau | 移除 Tableau MCP server |
claude mcp add ... -s user | 新增到 user 層(全域) |
claude mcp add ... -s project | 新增到 project 層(僅當前專案) |
已知問題與排除方式
問題 1:npm cache 損壞
症狀:
npm error code EEXIST
npm error syscall rename
npm error errno EEXIST
解法:
npm cache clean --force
如果出現權限錯誤(EACCES),先修正權限再清 cache:
sudo chown -R $(whoami):staff ~/.npm
npm cache clean --force
為什麼需要 chown?
之前某次用
之前某次用
sudo 跑過 npm,導致 cache 檔案被 root 佔用。chown 只是把 ~/.npm(個人 cache 資料夾)的所有權改回自己,安全無虞。問題 2:SSL 憑證驗證失敗
症狀:
Fatal error when starting the server: Failed to get server version:
unable to verify the first certificate
原因:KKday Tableau Server 的 SSL 憑證鏈不完整(缺少 TWCA 中間憑證)。
解法:確認已完成 Step 2,並確認 NODE_EXTRA_CA_CERTS 路徑正確(必須是絕對路徑,不能用 ~)。
問題 3:PAT 過期
症狀:認證失敗(401 Unauthorized)。
解法:
- 到 Tableau → My Account Settings → Personal Access Tokens,刪除舊的 token
- 重新建立一組 PAT
- 先移除舊設定:
claude mcp remove tableau - 重新執行 Step 3 的
claude mcp add指令
安全注意事項
PAT_VALUE等同你的 Tableau 帳號密碼,不要分享給他人或 commit 到 git~/.claude.json包含敏感資訊,確認不會被同步到雲端或版本控制- 如果懷疑 PAT 洩漏,立即到 Tableau 刪除該 token 並重新建立
可用的 Tableau MCP Tools
連線成功後,Claude Code 可以使用以下 Tableau 工具:
| Tool | 用途 |
|---|---|
list-datasources | 列出所有已發布的資料源 |
list-workbooks | 列出所有工作簿 |
list-views | 列出所有視圖 |
query-datasource | 查詢資料源的數據 |
get-datasource-metadata | 取得資料源的欄位定義 |
get-workbook | 取得工作簿詳細資訊 |
get-view-data | 取得視圖的數據 |
get-view-image | 取得視圖的截圖 |
search-content | 搜尋 Tableau 內容 |
使用方式
在 Claude Code 對話中直接用自然語言請求即可,例如:「列出 Tableau 上的所有工作簿」、「搜尋跟營收相關的報表」。
在 Claude Code 對話中直接用自然語言請求即可,例如:「列出 Tableau 上的所有工作簿」、「搜尋跟營收相關的報表」。