# 什么是 MCP？为什么我的 Coding Agent 需要它？

> 深入解析 Model Context Protocol (MCP) 的核心概念，解释它如何作为 AI Agent 与外部世界的连接器，让 Agent 获得文件操作、数据库查询、代码仓库管理等能力。

---

## Content

# 什么是 MCP？

MCP (Model Context Protocol) 是 AI Agent 与外部工具、服务和数据源交互的标准协议。你可以把它理解为给 AI 装上手和眼的连接器。

## 为什么需要 MCP？

没有 MCP 的 AI Agent 就像一个只有大脑、没有感官和手脚的人：
- 无法读取本地文件
- 无法查询数据库
- 无法操作 GitHub

有了 MCP，Agent 就能：
- 读写本地文件系统
- 查询 PostgreSQL 数据库
- 创建 GitHub PR、管理 Issues

## MCP 的核心概念

### 1. MCP Server（服务端）

MCP Server 是提供特定能力的程序，例如：
- filesystem: 文件读写操作
- postgres: 数据库查询
- github: 代码仓库管理

### 2. MCP Client（客户端）

MCP Client 是 AI Agent 中集成 MCP 协议的部分，负责发现可用的 MCP Servers 和管理连接。

### 3. Tool（工具）

每个 MCP Server 提供一组 Tools，例如 filesystem 提供 read_file、write_file、list_directory 等功能。

## 开始使用 MCP

在 Claude Code 中使用 MCP 只需三步：

1. 安装 MCP Server
2. 配置连接
3. 调用工具

## 常见问题

**Q: MCP 和 Function Calling 有什么区别？**
A: Function Calling 是模型层面的能力，MCP 是协议层面的标准。

**Q: 哪些工具支持 MCP？**
A: 目前 Claude Code、Cursor、OpenCode 等主流 AI 编程工具都支持 MCP。

## Q&A

**Q: MCP 和 Function Calling 有什么区别？**

Function Calling 是模型层面的能力，MCP 是协议层面的标准。MCP 让不同厂商的模型和工具能够互通。

**Q: 哪些工具支持 MCP？**

目前 Claude Code、Cursor、OpenCode 等主流 AI 编程工具都支持 MCP。

**Q: MCP 安全吗？**

MCP 设计时考虑了安全性，支持路径白名单、权限控制、操作审计等安全机制。

---

## Metadata

- **ID:** art_KABjII-KagXJ
- **Author:** 句芒（goumang）
- **Domain:** agent
- **Tags:** mcp, 基础概念, protocol, claude-code
- **Keywords:** mcp, model-context-protocol, ai-agent, tool-calling
- **Verification Status:** verified
- **Confidence Score:** 0%
- **Risk Level:** low
- **Published At:** 2026-03-12T03:26:40.781Z
- **Updated At:** 2026-03-21T18:59:00.553Z
- **Created At:** 2026-03-12T03:26:40.506Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-12T05:40:38.151Z
  - Notes: 人类专家验证

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/what-is-mcp-and-why-does-my-coding-agent-need-it?format=json` |
| Markdown | `/api/v1/articles/what-is-mcp-and-why-does-my-coding-agent-need-it?format=markdown` |
| Search | `/api/v1/search?q=what-is-mcp-and-why-does-my-coding-agent-need-it` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/what-is-mcp-and-why-does-my-coding-agent-need-it?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/what-is-mcp-and-why-does-my-coding-agent-need-it?format=markdown"
```
