Series: Claude Code 自動化指南 (2/3)

← Dialogue as Documentation: Turning a Debug Session into an Article with Claude Code Is Claude Code's On-Demand Loading of Skills/Tools a Form of RAG? Unpacking Agentic Retrieval →
Table of Contents

Claude Code can use GitHub, query Postgres, search Slack channels — these aren’t Claude’s innate capabilities. They’re plugged in through MCP (Model Context Protocol).

MCP is an open protocol Anthropic released in November 2024. Its design goal is singular: let AI agents connect to any external tool without writing custom integration code for each one.

TL;DR

MCP (Model Context Protocol) is an open standard defining how AI agents and external tools communicate. Like USB unified the connection standard for peripherals, MCP unifies the protocol for “AI calling tools.” Claude Code natively supports MCP and can connect to GitHub, Postgres, Slack, Google Drive, and hundreds of other existing MCP servers — or you can implement your own with the official SDK. As of 2025, MCP has been adopted by Cursor, Windsurf, and 40+ AI editors, establishing itself as the industry de facto standard.

Design Philosophy

Before MCP, AI tool integration worked like this: write a function for each tool (OpenAI calls it function calling, Anthropic calls it tool use), define its parameter schema, then describe its purpose in the system prompt.

This approach has a fundamental problem: coupling. Your AI agent code directly knows “there’s a GitHub tool, there’s a Postgres tool” — tool definitions and agent logic are mixed together. Every time you add a new tool, you have to modify the agent’s core code.

MCP’s design approach is to externalize tool definitions: tools exist as independent MCP servers with standardized interfaces. The AI agent discovers which servers are available at startup, retrieves tool descriptions from the server, then calls them using the standard protocol. The agent doesn’t need to know about tools in advance — anything conforming to the MCP standard can be plugged in.

Core Concepts

MCP’s Three-Layer Architecture

MCP Host (Claude Code)
    ↕ MCP Protocol
MCP Client (built into Claude Code)
    ↕ Transport (stdio / SSE / HTTP Streamable)
MCP Server (GitHub, Postgres, Slack, custom tools...)

MCP Host: The application using Claude (Claude Code, Cursor, etc.)

MCP Client: The MCP protocol implementation built into the Host, responsible for connecting and managing multiple servers

MCP Server: An independent process encapsulating specific capabilities — can be a local process (stdio transport) or a remote service (HTTP/SSE transport)

What MCP Servers Can Expose

MCP servers can expose three types of resources:

  • Tools: Functions the AI can call (read a GitHub PR, execute a SQL query)
  • Resources: Static or dynamic data (currently open files, database schema)
  • Prompts: Preset prompt templates

Transport Modes

ModeUse Case
stdioLocal tools (most common, directly forks subprocess)
SSE (Server-Sent Events)Remote server, unidirectional streaming
HTTP StreamableRemote server, bidirectional, added in 2025

Claude Code’s MCP Implementation

Configuration

In ~/.claude/settings.json or the project’s .claude/settings.json:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres",
               "postgresql://localhost/mydb"]
    }
  }
}

Tool Search: Solving MCP’s Context Problem

Every MCP server carries its tool definitions (schemas), and connecting multiple servers simultaneously means those definitions alone consume significant context window. Claude Code introduced Tool Search: at session startup, only tool names and server descriptions are loaded; detailed tool schemas are loaded lazily on demand. This reduces context consumption by approximately 46.9%.

In practice: you can connect 20 MCP servers and the context window usage is only marginally more than connecting 5.

How It Differs from Alternatives

ApproachAdvantagesDisadvantages
MCPStandardized, cross-platform, rich tool ecosystemRequires MCP server to be running
Function Calling (direct definition)Simple and direct, no extra server neededTool definitions coupled into agent code, hard to reuse across platforms
LangChain ToolsComplete Python ecosystemFramework lock-in, not cross-language
Direct REST API callsMaximum flexibilityAI must understand each API’s format, no standardization

MCP’s core advantage is reusability: a GitHub MCP server can be shared by Claude Code, Cursor, Windsurf, and all MCP-compatible tools. Tool authors only need to maintain one implementation.

When to Use MCP (and When Not To)

Good fit for MCP:

  • You need your AI agent to connect to multiple external systems
  • You want the same toolset used across multiple AI applications
  • You’re building complex agent workflows that combine multiple tools

Poor fit:

  • One-off simple tool integrations (direct function calling is faster)
  • Tools that don’t need to be shared between AI applications
  • Latency-sensitive scenarios (MCP’s process startup has initial overhead)

Bottom Line

MCP is an important infrastructure standardization effort for AI agent tool integration, solving the “every AI tool has to re-implement the integration for every external service” repetition problem. Its rapid adoption in 2024-2025 (Cursor, Windsurf, 40+ editors) demonstrates industry alignment on this direction.

The most practical starting point for engineers: check whether your commonly used tools (GitHub, Slack, your database) have existing MCP servers (they usually do), try a few, feel how AI agents can integrate into your workflow, then decide whether you need to implement a custom server.

References

Ask this article

Answers come from this article only. Click any prompt below or open the chat at the bottom right.

🇺🇸 English

Claude Code can open a GitHub pull request, run a query against your Postgres database, search through your Slack channels. Here's the thing though — none of that is something Claude actually knows how to do on its own. Those abilities get plugged in from the outside, through something called MCP, the Model Context Protocol.

MCP is an open protocol that Anthropic released back in November of 2024. And it was built to solve one very specific problem: how do you let an AI agent connect to any external tool without hand-writing custom glue code for every single one?

Here's the analogy I keep coming back to. Think about what USB did for hardware. Before USB, every peripheral had its own weird connector — keyboards, mice, printers, all different. USB said, no, there's one standard port, and everything speaks it. MCP is doing exactly that, but for AI calling tools. One standard interface. Claude Code supports it natively, and it can connect to GitHub, Postgres, Slack, Google Drive, and hundreds of other MCP servers that already exist — or you can build your own with the official SDK. And by 2025, it wasn't just Anthropic. Cursor, Windsurf, more than forty other AI editors adopted it. It became the industry default.

So let's talk about why it's designed this way, because that's where it gets interesting.

Before MCP, wiring a tool into an AI worked like this: for every tool, you'd write a function — OpenAI calls this function calling, Anthropic calls it tool use — you'd define its parameters, and then you'd describe what it does in the system prompt. Fine for one or two tools. But it has a deep structural problem: coupling. Your agent's code has to directly *know* that a GitHub tool exists, that a Postgres tool exists. The tool definitions and the agent logic are all tangled together. Which means every time you add a new tool, you're going back in and editing the core of your agent. That doesn't scale.

MCP flips that around. It externalizes the tools. Each tool lives as its own independent MCP server with a standard interface. When the AI agent starts up, it discovers which servers are available, asks each one "what can you do?", and gets the descriptions back. Then it calls them over the standard protocol. The agent doesn't need to know anything about the tools ahead of time. If it speaks MCP, it can be plugged in. That's the whole philosophy.

Now, how is this actually structured? There are three layers, and it's worth getting these straight because the names sound similar.

At the top you've got the MCP Host — that's the application you're actually using. Claude Code, or Cursor, whatever. Inside that Host is the MCP Client, which is the protocol machinery built into the app; its job is to connect to and juggle multiple servers at once. And then out on the other end are the MCP Servers — each one an independent process that wraps up some specific capability. A server can run locally, right on your machine as a subprocess, or it can be a remote service you reach over the network. Host talks to Client, Client talks to the Servers. That's the chain.

And what can one of these servers actually offer up? Three kinds of things. First, Tools — functions the AI can call, like "read this GitHub PR" or "run this SQL query." Second, Resources — data, whether that's static or live, like the files you currently have open or your database schema. And third, Prompts — pre-built prompt templates the server hands over.

On the connection side, there are three transport modes, and the difference really comes down to local versus remote. The most common one is stdio — that's for local tools, where the client just forks off a subprocess and talks to it directly. Then there's SSE, Server-Sent Events, which is for a remote server streaming data back one direction. And newer, added in 2025, there's HTTP Streamable — also remote, but bidirectional, so data flows both ways.

Let me get concrete about Claude Code specifically. You configure your servers in a settings file — either globally in your home directory, or per-project. And the shape of it is pretty simple: you give each server a name, you tell it what command to run to launch it, and you pass in any environment variables it needs, like an access token for GitHub or a connection string for your database. So hooking up the GitHub server is basically: name it "github," tell it to run the GitHub server package, hand it your personal access token. Done.

But here's a problem that shows up once you get serious about this, and I love how Claude Code handles it. Every MCP server ships with its full tool definitions — the schemas describing every function and every parameter. Connect a bunch of servers at once, and just those definitions start eating up a real chunk of your context window before you've done anything. So Claude Code added something called Tool Search. When your session starts, it only loads the tool *names* and the server descriptions — the lightweight stuff. The detailed schemas? Those get loaded lazily, only when they're actually needed. And the payoff is significant: it cuts context consumption by roughly forty-seven percent. In practice, that means you can wire up twenty MCP servers and your context usage is only a hair more than if you'd connected five. That's the difference between MCP being a neat idea and MCP being something you'd actually run day to day.

Now, MCP isn't the only way to do this, so let's put it next to the alternatives honestly.

Plain function calling — defining tools directly in your code — is simple and direct, no extra server to run. But you're right back to that coupling problem: the definitions are baked into your agent and you can't reuse them across platforms. Then there's something like LangChain's tools — great, complete Python ecosystem, but you're locked into that framework and that language. And at the other extreme, you just call REST APIs directly — maximum flexibility, but now the AI has to understand every API's particular format, with zero standardization to lean on.

MCP's killer advantage over all of these is reusability. Write one GitHub MCP server, and Claude Code can use it, Cursor can use it, Windsurf can use it, every MCP-compatible tool can use it. The person maintaining that tool writes it *once*. That's the network effect that made this thing take off.

So when should you actually reach for MCP? It's a great fit when you need your agent talking to several external systems, when you want the same set of tools working across multiple AI apps, or when you're building complex workflows that stitch several tools together. It's a poorer fit for a quick one-off integration — direct function calling is just faster there — or for a tool that's never going to be shared between apps, or for latency-sensitive work, because spinning up an MCP process does carry some startup overhead.

Alright, let me leave you with the three things worth holding onto.

First: MCP is standardization for AI tool integration. It kills the endless repetition of every AI tool re-implementing the same connection to every external service. That's the core problem it solves, and the fact that Cursor, Windsurf, and forty-plus editors piled in over 2024 and 2025 tells you the industry agreed.

Second: the reason it's worth caring about is reusability. Tools become shared infrastructure — built once, used everywhere that speaks the protocol.

And third, the practical move for you as an engineer: don't overthink it. Go check whether the tools you already lean on — GitHub, Slack, your database — have existing MCP servers. They almost certainly do. Plug in a couple, get a feel for how an agent slots into your actual workflow, and *then* decide whether you ever need to write your own. Start by consuming before you start building. That's where the real understanding comes from.

🇹🇼 中文

Claude Code 開箱能做的其實只有兩件事:讀取檔案,還有執行 bash 指令。聽起來很基本,但這已經夠它在你的專案裡打轉了——看程式碼、跑測試、改檔案,都沒問題。

但問題是,工程師的世界不只有本機檔案,對吧?你的設計稿放在 Figma,討論串在 Slack,資料還散落在一堆外部服務裡。這些東西,Claude Code 預設是完全碰不到的。

那要怎麼把這些外部工具接進來?答案就是 MCP,全名叫 Model Context Protocol,模型上下文協定。

先講 MCP 到底是什麼。它是一個開放協定,讓任何人都能打造工具,然後把這些工具暴露給 AI agent 來用。換句話說,它定義了一套「工具作者」跟「AI agent」之間的共通語言。工具作者按照這個協定,把能力包成一台 MCP server;而 AI agent 只要會講 MCP 這套語言,就能發現、然後呼叫這台 server 上的工具。重點是——雙方不需要為對方寫任何客製化的整合程式碼。對 Claude Code 來說,這代表它的能力邊界,不再被「讀檔加 bash」框死了。

那實際加一台 MCP server 會發生什麼事?流程其實超直接:你新增一台 server,Claude 就立刻拿到這台 server 暴露出來的全部工具。舉例來說,接上一台 Figma 的 MCP server,Claude 就能存取你的 Figma 檔案;接上一台 Slack 的,Claude 就能讀 Slack 的內容。

你可以想像成,Claude Code 在中間,一條 MCP 協定的線連到 Figma server、一條連到 Slack server、還可以連到其他各種公開 server;而這些 server 各自再接到背後真正的服務。你不需要一個一個去教 Claude「Figma 的 API 長怎樣」「Slack 要怎麼呼叫」,這些細節全都封裝在 server 那一側。Claude 只是照著協定,把 server 說「我有這些工具」的清單拿過來用,就這麼簡單。

而 MCP 真正實用的地方,關鍵在生態。你現在可以立刻接上數千台公開可用的 MCP server。也就是說,多數情況下你根本不用自己寫。想讓 Claude 連上某個常見服務的時候,先去看看社群有沒有現成的——通常都有。你要做的,就只是把它接上去,Claude 馬上就多了一整組新工具。而且因為 MCP 是開放協定,這些 server 不會綁死在單一 AI 應用上。同一台 server,任何支援 MCP 的 agent 都能共用。工具作者維護一份實作,整個生態都受惠。

好,我幫你收斂成三個核心要點。第一,MCP 是一個開放協定,任何人都能打造工具、並暴露給 AI agent 使用。第二,你每加一台 MCP server,Claude 就拿到它暴露的全部工具,中間的整合細節你完全不用碰。第三,現在已經有數千台公開 server 可以直接接,多數時候你不用自己造輪子。

所以對工程師最實際的起點,就是去找找你每天在用的那些服務——Figma、Slack、資料庫——看有沒有現成的 MCP server,挑一兩台接上去,親自感受一下 Claude Code 從一個「本機助手」,變成「連得上你整個工具生態」的那個瞬間。

Tags

Related Articles

RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site

Over the past two years RAG evolved from a 'linear pipeline' to 'loop-based reasoning'. It maps cleanly to five stages: Naive, Advanced, Modular, Graph, Agentic. The real inflection point is control moving from pipeline to agent — a System 1 → System 2 shift. Looking back at engineer-news's own RAG stack, it's stuck at the Naive edge — so this post also lays out what to fix next.

Building a Real RAG: 5 Infra Lessons from InfiniFlow's 2024 Year-in-Review

The previous post zoomed out for a five-stage panorama of RAG. This one zooms in on the five infra lessons any real RAG has to face: document ingestion, contextualized chunking, three-lane hybrid search, tensor reranker, and GraphRAG's semantic gap. Each lesson is checked against engineer-news's current stack, ending with a priority list for a personal site.