KDnuggets ★ 72 4 min

MCP Explained in 5 Minutes

🔗 https://www.kdnuggets.com/mcp-explained-in-5-minutes

📌 MCP 新規格轉 Stateless,遠端伺服器更好擴充

TL;DR:MCP 2026-07-28 規格把協定核心改為 stateless,同時一次看懂如何用 Claude Code 串接 Tavily、GitHub、Playwright。

幾乎每個人都聽過 MCP,也知道它跟 AI 代理、程式助理、工具呼叫脫不了關係,但真正說得清楚「它到底怎麼運作」的人卻少很多。一旦搞懂基本流程,整套系統其實比想像中簡單。

🤔 沒有標準介面之前,每個服務都要客製串接

MCP 的核心概念是給 AI 應用一套與外部工具、資料源溝通的標準語言。沒有 MCP 時,每個 API、資料庫、程式庫或瀏覽器都可能需要各自的客製整合;有了 MCP,AI 應用可以透過同一套標準介面連接不同的 MCP 伺服器。MCP 不會取代既有 API,MCP 伺服器通常仍是代表 AI 應用去呼叫底層 API 或服務,MCP 標準化的是這些能力「如何被呈現、發現與呼叫」。一個 MCP 伺服器可以暴露三種能力:Tools(模型可執行的動作,例如搜尋網頁、建立 issue、執行查詢)、Resources(應用可讀取的資訊,例如檔案、文件、資料庫紀錄)、Prompts(伺服器提供的可重複使用提示樣板或工作流程)。對多數 AI 代理工作流而言,Tools 是最關鍵的一環,因為它讓模型不只是產生文字,還能真正與外部系統互動。

🧩 host → client → server 的呼叫流程

MCP 採用 client-server 架構:host 是 AI 應用本身(例如 Claude Code),host 內的 MCP client 連上一個或多個 MCP server,這些 server 再暴露 tools、resources 或 prompts 給外部服務。例如問「搜尋最新的 PyTorch 版本並摘要主要變更」,Claude 會先判斷這需要即時資訊,接著檢視可用的 MCP 工具、選擇一個網頁搜尋工具,透過 MCP 伺服器送出請求並取回搜尋結果。重點是 MCP 本身不做推理,是模型決定何時該用工具、該拿結果做什麼,MCP 只提供讓工具可被呼叫的標準連線。

文中實際示範了三種串接:用 claude mcp add --transport http tavily https://mcp.tavily.com/mcp 接上 Tavily 做網頁搜尋;用帶有 GitHub PAT 的 header 接上官方 GitHub 遠端 MCP 伺服器來讀取儲存庫、審查 PR 或查看 issue;以及用 claude mcp add playwright npx @playwright/mcp@latest 接上 Playwright 做瀏覽器自動化,Playwright MCP 主要透過結構化的無障礙(accessibility)快照,讓模型取得頁面元素的結構化表示以進行互動。

📊 最新規格的重點:協定核心變成 stateless

MCP 2026-07-28 規格帶來一個架構層級的改變:協定核心變成 stateless,不再需要維護與特定伺服器的持續 session,每個請求都自帶處理所需的資訊,讓遠端 MCP 伺服器更容易在標準雲端基礎設施上水平擴展。這次更新還包括:無需持續協定 session 的 stateless 請求、更好的伺服器與 gateway 路由辨識、可重複使用而不必每次重新抓取的 tool/resource/prompt 清單快取、支援工具先詢問更多資訊再繼續執行的多步互動、針對長時間執行任務的 Tasks 支援,以及更強的遠端伺服器身分驗證,並允許以擴充方式加入新能力而不需更動協定核心。

🎯 給工程團隊的啟示

一旦掌握「模型 → MCP → 工具 → 結果」這個基本流程,MCP 就不再是抽象名詞,而是一套可以直接拿來串生產環境代理的標準管線。新規格的 stateless 化尤其值得留意:如果你正在規劃遠端 MCP 伺服器的部署方式,這代表未來的擴展策略可以更貼近一般無狀態 API 服務的做法,而不必額外處理 session 親和性的問題。

🔗 來源

#MCP #ClaudeCode #AIAgents #ModelContextProtocol #Tavily #GitHub #Playwright #ToolUse #AgenticAI #DeveloperTools

原始資料 KDnuggets · 收集於 2026-09-25
來源原標題
MCP Explained in 5 Minutes
作者
Abid Ali Awan
原始連結
https://www.kdnuggets.com/mcp-explained-in-5-minutes

摘要原文

MCP Explained in 5 Minutes A visual guide to MCP that explains how it works, how to use it with Claude Code, Tavily, GitHub, and Playwright, and what is new through simple diagrams that make the whole concept easy for anyone to understand. By Abid Ali Awan , KDnuggets Assistant Editor on September 24, 2026 in Artificial Intelligence Everyone has heard of MCP by now. It is constantly mentioned alongside AI agents, coding assistants, and tool use. But while most people know what MCP is supposed to do, far fewer understand how it actually works or how to use it effectively. At a high level, MCP gives AI applications a standard way to connect with external tools and data sources. Instead of building a custom integration for every API, database, repository, or browser, an AI application can connect to an MCP server and discover the capabilities it provides. That sounds simple, but concepts like hosts, clients, servers, tools, resources, and transports can quickly make MCP feel more complicated than it really is. Once you understand the basic flow, however, the whole system becomes much easier to reason about. In this guide, we will break down how MCP works in about five minutes and then put it into practice by connecting Claude Code to Tavily for web search, GitHub for repository workflows, and Playwright for browser automation. What Is MCP? The simplest way to think about MCP is as a common language between an AI application and the tools it wants to use. Without MCP, every external service may require its own custom integration. With MCP, the AI application can connect to different MCP servers through the same standard interface. MCP does not replace APIs . An MCP server usually talks to the underlying API or service on behalf of the AI application. What MCP standardizes is how those capabilities are presented, discovered, and called by the AI. An MCP server can expose three main capabilities: Tools: Actions the model can perform, such as searching the web, creating an issue, or running a query. Resources: Information the application can read, such as files, documents, or database records. Prompts: Reusable prompt templates or workflows exposed by the server. For most AI agent workflows, tools are where MCP becomes especially useful , because they allow the model to move beyond generating text and actually interact with external systems. How MCP Works MCP follows a client-server architecture , but the flow is easier to understand when you see the pieces together. The host is an AI application, such as Claude Code. Inside the host, an MCP client connects to one or more MCP servers . Those servers expose tools, resources, or prompts connected to external services. For example, imagine asking: Search for the latest PyTorch release and summarize the major changes. Claude first determines that the task requires current information . It can then inspect the available MCP tools, select a web-search tool, send the request through the MCP server, and receive the search results. The important point is that MCP does not perform the reasoning . The model decides when a tool is needed and what to do with the result , while MCP provides the standardized connection that makes the tool available. Getting Started With MCP in Claude Code Now that we understand how MCP works, let us actually use it. Claude Code has built-in support for managing MCP servers. To see the servers currently configured on your machine, run: claude mcp list You can also manage and inspect MCP connections directly inside Claude Code with: /mcp Think of the setup like this: We will connect three MCP servers that cover some of the most useful agent workflows: searching the web, working with repositories, and controlling a browser . 1. Tavily for Web Search Language models do not always have access to current information. Tavily solves that by giving Claude Code tools for live web search, extraction, crawling, mapping, and research . Add the remote Tavily MCP server: claude mcp add --transport http tavily https://mcp.tavily.com/mcp Then open Claude Code and run: /mcp Select Tavily and complete the authentication flow if required. Tavily also supports passing an API key directly when configuring the server. Now try: Search the web for the latest vLLM release and summarize the main changes. The workflow becomes: Claude does not need to know how Tavily's underlying API works. It simply discovers the tools exposed by the MCP server and uses the appropriate one. 2. GitHub for Repository Workflows The official GitHub MCP server turns GitHub into a set of tools Claude can work with directly. Depending on your permissions, Claude can read repositories, search code, inspect commits, work with issues and pull requests, analyze workflows, and perform repository operations . Add GitHub's remote MCP server using a Personal Access Token (PAT): claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \ --header "Authorization: Bearer YOUR_GITHUB_PAT" Replace YOUR_GITHUB_PAT with a GitHub PAT that has only the permissions you actually need. You can now ask Claude Code things such as: Review pull request #42 and identify potential bugs and missing tests. Or: Show me the most important open issues in this repository. Conceptually: Instead of manually copying code, issues, and pull requests into the conversation, Claude can retrieve the required context through MCP and act on it when permissions allow. 3. Playwright for Browser Automation Some tasks require more than APIs. The agent may need to open a website, click buttons, fill forms, navigate pages, or test an application . That is where Playwright MCP becomes useful. Add Microsoft's Playwright MCP server: claude mcp add playwright npx @playwright/mcp@latest Then try: Open my local application and test the signup flow. The workflow now looks like this: Playwright MCP works primarily with structured accessibility snapshots of the page, giving the model a structured representation it can use to interact with browser elements. What Is New in MCP? MCP has evolved quickly since its first release. The latest MCP 2026-07-28 specification introduces a major architectural change: the protocol core is now stateless . Instead of maintaining a session with a specific server, each request contains the information needed to process it. This makes remote MCP servers much easier to scale across standard cloud infrastructure. The new specification also adds: Stateless requests: No ongoing protocol session is required. Better routing: Servers and gateways can more easily identify and route requests. Caching: Tool, resource, and prompt lists can be reused instead of fetched repeatedly. Multi-step interactions: A tool can ask for more information and then continue the same task. Tasks: Better support for long-running operations. Improved authentication: Stronger support for secure remote MCP servers. Extensions: New capabilities can be added without changing the core protocol. In simple terms, MCP is becoming easier to scale, more secure, and better suited for production AI agents . Final Thoughts MCP may sound technical at first, but the idea is simple: it gives AI applications a standard way to connect to external tools. In this guide, we saw how Claude Code can use MCP to search the web with Tavily, work with GitHub repositories, and control a browser with Playwright. We also looked at how the latest MCP updates make these connections easier to scale and better suited for production. Once you understand the basic flow of model — MCP — tool — result , it becomes much easier to build more capable AI agents without creating a custom integration for every service. Abid Ali Awan ( @1abidaliawan ) is a certified data scientist professional who loves building machine learning models. Currently, he is focusing on content creation and writing technical blogs on machine learning and data science technologies.

由 claude-code/sonnet 自動生成