Skip to content
←INDEX / 提示詞庫
TUTORIAL/Claude Code/進階

Claude Code 接 MCP:把外部資料庫/API/SaaS 安全接進你的開發代理

讓 Claude Code 幫你把一個 MCP server(資料庫、Notion、GitHub、自家 API…)接上,選對 transport 與 scope、用 .mcp.json 或 claude mcp add、安全處理金鑰與 OAuth,最後示範用 mcp__server__tool 工具與 @resource 把外部資料拉進工作流。

SakuyaPromptCraft 主筆 · 寫於 2026-06-08
AI 教學 / 腳本Claude Code進階預期輸出說明≈ 928 tokens · 實際用量依工具與輸入而異
Last reviewed2026-06-08Read~14 MIN

01PROMPT

You are setting up a Model Context Protocol (MCP) server connection for Claude Code so I can stop copy-pasting data from an external system into chat. Use real Claude Code MCP commands and config formats only.

## The external system I want to connect
{{TARGET_SYSTEM}}

## What I want Claude to be able to do once connected
{{DESIRED_CAPABILITIES}}

## Phase 1 — Decide the setup (explain your choices)
Ask me anything you genuinely need, then recommend ONE concrete setup and justify it:
1. **Transport**: HTTP (recommended for remote cloud services, supports OAuth) vs stdio (a local process for tools needing direct system access / custom scripts) vs SSE (deprecated — avoid). Pick one for my system and say why.
2. **Scope** of the config:
   - `local` (default): only me, only this project.
   - `project`: shared with my team via a `.mcp.json` committed to the repo root.
   - `user`: just me, across all my projects.
   Recommend one based on whether this is a team tool or personal, and whether secrets are involved.
3. **Auth**: static header token, OAuth 2.0 (handled interactively via `/mcp`), or env-injected key for a stdio server. Tell me which my system uses.
4. **Secret safety**: a real plan so no API key ends up committed. For project scope, use environment variable expansion in `.mcp.json` (e.g. values like `${MY_API_KEY}`) and keep the actual secret out of git; for local/user scope, pass via `--env` or `--header`.

## Phase 2 — Give me the exact setup
Output, ready to run:

### A) The command or config
- If a CLI add is cleanest, give the exact `claude mcp add` command. Remember real syntax: all flags (`--transport`, `--scope`, `--env`, `--header`) come BEFORE the server name; for stdio, put `--` before the actual command, e.g.
  `claude mcp add --transport http <name> <url> --header "Authorization: Bearer <token>"`
  `claude mcp add --env KEY=value --transport stdio <name> -- npx -y <server-package>`
- If project/team scope, instead give me the `.mcp.json` snippet to place at the repo root, using `${ENV_VAR}` expansion for any secret, and remind me Claude Code prompts for approval before using project-scoped servers.

### B) Verify the connection
- `claude mcp list` to see all servers, `claude mcp get <name>` for one, and the in-session `/mcp` panel to check status, tool count, and run OAuth login if the server needs it.
- Tell me what a healthy vs pending/failed state looks like.

### C) Use it in a real task
Give me 2-3 concrete natural-language prompts that exercise my desired capabilities, and note how MCP surfaces them:
- Tools are namespaced `mcp__<server>__<tool>` — I don't call these by hand, I just ask in plain language and Claude routes to them.
- If the server exposes **resources**, I can pull them in by typing `@` in my prompt to pick from the autocomplete (resources appear alongside files).
- If it exposes **prompts**, they appear as `/mcp__<server>__<promptname>` slash commands.

### D) Safety + teardown
- Note least-privilege: only connect servers I trust; project `.mcp.json` servers require my approval before first use.
- Give me `claude mcp remove <name>` to disconnect, and where the config is stored for each scope.

## Rules
- Use only commands, flags, and config keys that actually exist in Claude Code. If unsure whether something exists, say so rather than guessing.
- Never put a real secret inline in a committed file; always route it through env expansion or `--env`/`--header`.
- Be specific to MY system in {{TARGET_SYSTEM}} — pick real, named transport/scope/auth, don't hand me a generic menu.
- End with a checklist: transport chosen ✅, scope chosen ✅, secret-safe ✅, verified via `/mcp` ✅, one working example prompt ✅.

把方括號 [ ] 內的變數換成你的內容,丟進 Claude Code。

◆ 直接開到工具Claude(記得貼)
RUN站內試跑 / TRY IT
▶ 站內試跑

不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。

SKILL安裝成 SKILL / INSTALL
安裝成 SKILLClaude Code Agent Skill

不只複製貼上 — 下載後放到 ~/.claude/skills/mcp-connect-external-tools/SKILL.md,之後每個 session 自動可用(觸發時自動載入)。

macOS / Linux
mkdir -p ~/.claude/skills/mcp-connect-external-tools && mv ~/Downloads/SKILL.md ~/.claude/skills/mcp-connect-external-tools/SKILL.md
Windows PowerShell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\mcp-connect-external-tools" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\SKILL.md" "$env:USERPROFILE\.claude\skills\mcp-connect-external-tools\SKILL.md"

02CONTEXT / 使用情境

何時用:你一直把外部系統的東西(Notion 頁面、Postgres 查詢、GitHub/Jira ticket、自家 API 回應)手動複製進 Claude Code。為何有效:MCP 是 Claude Code 2026 真正支援的標準外部整合機制;這支提示詞逼 Claude 在動手前先把三個最容易搞砸的決策講清楚——transport(遠端雲服務用 http、本地工具用 stdio、SSE 已棄用)、scope(local 自己/project 進 .mcp.json 給團隊/user 跨專案)、以及金鑰安全(project scope 一定用 ${ENV} 展開、絕不把 token 寫進進版控的檔案)。技巧:① 接好後你不用記 mcp__server__tool,直接用白話講需求、Claude 自己路由;② 外部「資源」用 @ 在輸入框挑、像挑檔案一樣;③ 遠端服務要登入就用 /mcp 跑 OAuth,狀態也在那面板看。

03SAMPLE / 期待成果

Phase 1 決策: - 你的目標是 Notion 官方遠端服務 → transport 選 HTTP(雲服務、支援 OAuth)。 - 這是你個人跨專案要用、且 Notion 走 OAuth 不需手動塞 token → scope 選 user。 - Auth:OAuth 2.0,連上後用 /mcp 登入,不需在任何檔案放金鑰(最安全)。 Phase 2 指令: claude mcp add --transport http --scope user notion https://mcp.notion.com/mcp 驗證: claude mcp list # 看到 notion 在 Claude Code 內打 /mcp # 對 notion 點 Authenticate 完成 OAuth;健康時顯示已連線 + 工具數 實際使用(白話即可,Claude 自動路由到 mcp__notion__* 工具): 「把我『Q2 上線清單』Notion 資料庫裡狀態還是 Todo 的項目列出來」 「在輸入框打 @ 選那個 Notion 頁面,照它更新我們的 email 範本」 移除:claude mcp remove notion ✅ HTTP ✅ user scope ✅ OAuth 無明文金鑰 ✅ /mcp 已驗證 ✅ 範例可跑

這是預期成果的文字說明。請查看本文實測說明,並以自己的輸入素材小規模試用。

04VARIABLES / 變數說明

01[TARGET_SYSTEM]

你要接的外部系統,含名稱與型態(例:『Notion,官方遠端 MCP https://mcp.notion.com/mcp』『本地 Postgres 資料庫』『公司內部 REST API,需 Bearer token』)

02[DESIRED_CAPABILITIES]

接上後想讓 Claude 能做的事(例:『讀某個 Notion 資料庫並更新狀態』『查使用者表撈 email』『讀 Jira ticket 並開 PR』)

05RESOLVER · 變數代入器0 / 2

填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。

修飾
Assembled · 填剩餘變數…
You are setting up a Model Context Protocol (MCP) server connection for Claude Code so I can stop copy-pasting data from an external system into chat. Use real Claude Code MCP commands and config formats only.

## The external system I want to connect
{{TARGET_SYSTEM}}

## What I want Claude to be able to do once connected
{{DESIRED_CAPABILITIES}}

## Phase 1 — Decide the setup (explain your choices)
Ask me anything you genuinely need, then recommend ONE concrete setup and justify it:
1. **Transport**: HTTP (recommended for remote cloud services, supports OAuth) vs stdio (a local process for tools needing direct system access / custom scripts) vs SSE (deprecated — avoid). Pick one for my system and say why.
2. **Scope** of the config:
   - `local` (default): only me, only this project.
   - `project`: shared with my team via a `.mcp.json` committed to the repo root.
   - `user`: just me, across all my projects.
   Recommend one based on whether this is a team tool or personal, and whether secrets are involved.
3. **Auth**: static header token, OAuth 2.0 (handled interactively via `/mcp`), or env-injected key for a stdio server. Tell me which my system uses.
4. **Secret safety**: a real plan so no API key ends up committed. For project scope, use environment variable expansion in `.mcp.json` (e.g. values like `${MY_API_KEY}`) and keep the actual secret out of git; for local/user scope, pass via `--env` or `--header`.

## Phase 2 — Give me the exact setup
Output, ready to run:

### A) The command or config
- If a CLI add is cleanest, give the exact `claude mcp add` command. Remember real syntax: all flags (`--transport`, `--scope`, `--env`, `--header`) come BEFORE the server name; for stdio, put `--` before the actual command, e.g.
  `claude mcp add --transport http <name> <url> --header "Authorization: Bearer <token>"`
  `claude mcp add --env KEY=value --transport stdio <name> -- npx -y <server-package>`
- If project/team scope, instead give me the `.mcp.json` snippet to place at the repo root, using `${ENV_VAR}` expansion for any secret, and remind me Claude Code prompts for approval before using project-scoped servers.

### B) Verify the connection
- `claude mcp list` to see all servers, `claude mcp get <name>` for one, and the in-session `/mcp` panel to check status, tool count, and run OAuth login if the server needs it.
- Tell me what a healthy vs pending/failed state looks like.

### C) Use it in a real task
Give me 2-3 concrete natural-language prompts that exercise my desired capabilities, and note how MCP surfaces them:
- Tools are namespaced `mcp__<server>__<tool>` — I don't call these by hand, I just ask in plain language and Claude routes to them.
- If the server exposes **resources**, I can pull them in by typing `@` in my prompt to pick from the autocomplete (resources appear alongside files).
- If it exposes **prompts**, they appear as `/mcp__<server>__<promptname>` slash commands.

### D) Safety + teardown
- Note least-privilege: only connect servers I trust; project `.mcp.json` servers require my approval before first use.
- Give me `claude mcp remove <name>` to disconnect, and where the config is stored for each scope.

## Rules
- Use only commands, flags, and config keys that actually exist in Claude Code. If unsure whether something exists, say so rather than guessing.
- Never put a real secret inline in a committed file; always route it through env expansion or `--env`/`--header`.
- Be specific to MY system in {{TARGET_SYSTEM}} — pick real, named transport/scope/auth, don't hand me a generic menu.
- End with a checklist: transport chosen ✅, scope chosen ✅, secret-safe ✅, verified via `/mcp` ✅, one working example prompt ✅.
FAQ · 常見問題

「Claude Code 接 MCP:把外部資料庫/API/SaaS 安全接進你的開發代理」這組提示詞要怎麼用?

這組 prompt 專為 Claude Code 設計。把 prompt 內 2 個方括號 [變數] 換成你自己的內容,貼進 Claude Code 執行即可。難度中等,照變數說明填好後即可上手。

「Claude Code 接 MCP:把外部資料庫/API/SaaS 安全接進你的開發代理」是免費的嗎?

完整 prompt 免費開放閱讀,不用註冊;可保存瀏覽器收藏,登入後可一鍵複製與留言。

用 Claude Code 依這組 prompt 生成的成果可以商用嗎?

prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 Claude Code 使用的方案與其官方服務條款,請以該工具的授權規範為準。

RELATED你可能也需要

PRO01
TUTORIALSuno v5.5FEATURED
r/SunoAI (anonymous studio engineer)2026-06-12

Suno 工程師思維:4 步驟做出不像 AI 的歌

5.0(1)

Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt

高階
Read

免費02
TUTORIALClaude 4.5 SonnetFEATURED
r/ClaudeAI2026-05-14

5 個 6 月 stuck 下來的 Claude 每週 workflow

提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。

進階
Read

PRO03
TUTORIALClaude 4.5 SonnetFEATURED
r/PromptEngineering2026-05-14

7 個跨 model A/B 測過的 prompt 技巧(不是 vibes)

六個月在 Claude / GPT-4 / Gemini 上用人工 rater A/B 測 200+ prompt 後寫的。包含 persona+constraint stacking / anti-example / role reversal QA / cognitive scaffold / emotional priming / uncertainty CoT / steelman first。

高階
Read

免費04
TUTORIALChatGPTFEATURED
r/ChatGPTPromptGenius2026-05-14

5 個信任檢查單行 prompt(沒有 role-play)

一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。

入門
Read

免費 · 全文開放閱讀

完整 prompt 已經開放.

免登入閱讀全文、保存瀏覽器收藏;登入後可一鍵複製與留言討論。不用信用卡。

不想註冊?

留個 email,下次有新 prompt 會寄一封簡短摘要給你。退訂一鍵、不轉賣。

每週一期,新上架提示詞 + 模型測試心得。每封信底部都有一鍵取消訂閱。

或訂 RSS feed(30 秒一次的人味選擇)

COMMENTS · 討論區0 則
登入 後可留言。還沒帳號?註冊
目前沒有留言。第一個說說你的經驗。
EMBED · 嵌入 blog / Note一行 iframe HTML、貼進文章即顯示此 prompt 卡片+

適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。

<iframe src="https://prompt.luvai.net/embed/claude-code-mcp-connect-external-tools" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
預覽 embed →380px tall · responsive width
發現這個 prompt 過時 / 跑不動 / 有錯字? 回報給我們 →