MCP 與 API 有什麼不同?理解 Function Calling、RAG 與 AI Agent 的真正分工
MCP 入門與實戰 02|2026 年 12 月 1 日
企業已有 REST API,為什麼還需要 MCP?答案不是把 API 全部重寫,而是讓 AI 應用能以較一致的方式發現工具、理解工具的參數、呼叫服務,並取得結果。API 與 MCP 大多數時候是互補關係。
01|四種容易被混淆的技術
| 技術 | 解決的問題 | 實際例子 |
|---|---|---|
| REST API | 軟體如何存取服務 | GET /articles/123 |
| Function Calling | 模型如何表達工具呼叫意圖 | 模型輸出 search_articles 的參數 |
| MCP | AI 宿主如何與外部能力互通 | 取得工具清單並呼叫指定工具 |
| RAG | 模型如何取得相關知識 | 從文件檢索段落後回答問題 |
Function Calling 通常是模型介面的一部分,讓模型產出函式名稱與結構化參數。應用程式還需要執行該函式、處理錯誤並把結果送回模型。
MCP 則是應用與服務間的通訊協定。宿主可以把 MCP 工具轉成模型可使用的函式,也可以以其他方式呈現。兩者不互斥。
RAG(檢索增強生成)著重知識檢索,MCP Server 可以提供搜尋知識庫的工具,但接上 MCP 不代表自動完成文件切分、索引、檢索或來源驗證。
02|以網站的文章管理為例
原本的後端可能已經有三個 API:查詢文章、建立草稿與發布。MCP Server 可以保留這些 API,在上層提供三個清楚的工具名稱:
search_articles(query, limit):回傳文章 ID、標題和摘要。create_draft(title, body):建立私人草稿並回傳草稿 ID。publish_article(draft_id, revision):通過身分驗證及版本檢查後發布。
這不是為了把 HTTP 隱藏起來,而是把原本需要程式設計師理解的服務介面,轉成 AI 可以辨認的業務能力。
03|為什麼不直接把所有 API 都交給 AI?
假如系統有 200 個 API,一次全部暴露給模型,可能造成工具選擇困難、上下文過長及不必要的權限風險。例如「新增一篇文章」不應該要求 AI 自己選資料庫、建立索引、更新快取,再修改網站配置。
更好的做法是依業務目標整合既有流程。讓一個工具完成一件清楚的事,內部交易、驗證、快取失效與錯誤處理仍交給後端。
04|MCP 與 AI Agent 的關係
Agent 是負責決定下一步、呼叫能力、處理結果及檢查完成條件的應用模式。MCP 是它可以使用的連接協定之一。
一個可靠的 Agent 需要任務狀態、工具使用策略、重試上限、權限控管與成功驗證。MCP 不會替你完成這些設計,也不保證模型能正確理解每一項工具。
05|該選哪種架構?
如果只有一個前端和一個後端,既有 API 可能就足夠。如果服務預期給多種 AI 宿主使用,或公司希望把多套系統整合進同一個 Agent 工作流程,才更值得建立 MCP 介面。前提仍然是宿主支援相關版本與能力。
從一個常用、低風險、可以量化成效的工作流程開始。完成搜尋、讀取及草稿建立,再開放正式寫入。先驗證真實需求,比為所有 API 建立 MCP 包裝更有價值。
延伸閱讀
MCP Introduction and Practice 02 | December 1, 2026
Companies already have REST API, why do they still need MCP? The answer is not to rewrite all APIs, but to allow AI applications to discover tools, understand tool parameters, call services, and get results in a more consistent way. API and MCP are complementary most of the time.
01 | Four easily confused technologies
| Technology | Solving problems | Actual examples |
|---|---|---|
| REST API | How software accesses services | GET /articles/123 |
| Function Calling | How models express tool call intentions | Model output search_articles parameters |
| MCP | How AI hosts communicate with external capabilities | Get tool list and call specified tool |
| RAG | How models obtain relevant knowledge | Answer questions after retrieving paragraphs from documents |
Function Calling is usually part of the model interface, allowing the model to produce function names and structured parameters. The application still needs to execute the function, handle errors, and send the results back to the model.
MCP, on the other hand, is a communication protocol between applications and services. The host can convert MCP tools into functions that the model can use, or present them in other ways. The two are not mutually exclusive.
RAG (Retrieval-Augmented Generation) focuses on knowledge retrieval, and MCP Server can provide tools for searching knowledge bases, but connecting to MCP does not automatically complete file splitting, indexing, retrieval, or source verification.
02 | Taking website article management as an example
The original backend may already have three APIs: querying articles, creating drafts, and publishing. The MCP Server can retain these APIs and provide three clear tool names on top:
search_articles(query, limit)Article Query: returns article ID, title, and summary.create_draft(title, body)Draft Creation: creates a private draft and returns the draft ID.publish_article(draft_id, revision)Publish: publishes after authentication and version checking.
This is not to hide HTTP, but to convert the service interface that originally required programmers to understand into business capabilities that AI can recognize.
03 | Why not directly expose all APIs to AI?
If the system has 200 APIs, exposing them all to the model at once may cause tool selection difficulties, overly long context, and unnecessary permission risks. For example, "creating a new article" should not require AI to select a database, create an index, update the cache, and modify the website configuration.
A better approach is to integrate existing processes based on business goals. Let one tool complete one clear task, and let the backend handle internal transactions, validation, cache invalidation, and error handling.
04 | Relationship between MCP and AI Agent
The Agent is an application mode responsible for deciding the next step, calling capabilities, handling results, and checking completion conditions. MCP is one of the connection protocols it can use.
A reliable Agent needs task status, tool usage strategy, retry limit, permission control, and success verification. MCP will not complete these designs for you, nor does it guarantee that the model can correctly understand each tool.
05 | Which architecture to choose?
If there is only one frontend and one backend, the existing API may be sufficient. If the service is expected to be used by multiple AI hosts or the company wants to integrate multiple systems into the same Agent workflow, it is more worthwhile to establish an MCP interface. The premise is that the host supports related versions and capabilities.
Start with a commonly used, low-risk, and quantifiable workflow. Complete search, read, and draft creation, and then open formal writing. Verify real needs first, rather than creating MCP packaging for all APIs.