Lộ trình học›Claude API›Building with the Claude API Mở bản đồ

6.58 · Giới thiệu MCP — Model Context Protocol

Bài viếtTrung cấp → Nâng20 phút đọc

Bạn build chatbot cho enterprise. Cần tools:

Sau bài này, bạn sẽ
  1. Giải thích MCP giải quyết vấn đề gì (tool integration maintenance burden)
  2. Phân biệt MCP vs tool use thông thường
  3. Hiểu architecture: Client, Server, Tools/Prompts/Resources
  4. Biết tại sao MCP đang thành industry standard

Mở đầu: Scale khi có 50 integrations

  • GitHub (list repos, PRs, issues)
  • Slack (send msg, read channels)
  • Jira (create ticket, update status)
  • Google Drive (search, read docs)
  • Gmail (send, search emails)
  • Salesforce (query leads)
  • ...

Mỗi integration = 10-50 tool schemas + functions. 50 integrations × 30 tools = 1500 tools bạn maintain.

Mỗi thay đổi API upstream (Slack update v2) → bạn update 30 tool functions.

Unsustainable.

MCP = "Language for tool providers"

Idea: Service providers (GitHub, Slack, etc.) implement MCP servers exposing their tools qua chuẩn chung. Bạn chỉ cần connect MCP client tới servers.

Before MCP:
┌──────────────────────┐
│  Your chatbot app    │
│                      │
│  - GitHub tool 1     │
│  - GitHub tool 2     │
│  - ...50 tools       │  ← BẠN MAINTAIN
│  - Slack tool 1      │
│  - ...30 tools       │  ← BẠN MAINTAIN
│  - ...               │
└──────────────────────┘

After MCP:
┌──────────────────────┐         ┌──────────────────┐
│  Your chatbot app    │ ──MCP──▶ │ GitHub MCP       │
│  (just client)       │         │ (official)        │
│                      │ ──MCP──▶ │ Slack MCP        │
│                      │         │ (official)        │
│                      │ ──MCP──▶ │ Jira MCP         │
└──────────────────────┘         └──────────────────┘

Anthropic, AWS, GitHub, Google, Slack, Notion đều release MCP servers chính thức. Bạn reuse, không build.

MCP architecture

┌────────────────────────────────────────────────┐
│                                                │
│     Your App (MCP Client)                      │
│     ┌──────────────────┐                       │
│     │  MCP Client SDK  │                       │
│     └────────┬─────────┘                       │
│              │                                 │
│              │ Protocol messages               │
│              │ (stdio, HTTP, WebSocket)        │
│              ▼                                 │
│     ┌──────────────────┐                       │
│     │  MCP Server       │                       │
│     │  ┌────────────┐   │                       │
│     │  │ Tools      │   │ tools (functions)     │
│     │  │ Prompts    │   │ prompts (templates)  │
│     │  │ Resources  │   │ resources (data)     │
│     │  └────────────┘   │                       │
│     └──────────────────┘                       │
│              │                                 │
│              ▼                                 │
│     External service                           │
│     (GitHub API, DB, files, ...)               │
│                                                │
└────────────────────────────────────────────────┘

3 core concepts

1. Tools

Function Claude can call. Tương tự tool use Module 5, nhưng served qua MCP.

2. Prompts

Pre-built, high-quality prompt templates server provide. User pick prompt thay vì viết from scratch.

3. Resources

Data sources MCP server expose. Files, database records, documents. Client có thể read.

Module 8 cover từng piece.

MCP vs plain tool use

Plain tool useMCP
SchemaBạn viếtServer provides
ImplementationBạn viếtServer implements
UpdatesBạn maintainServer provider updates
ReusePer-appAny MCP client can use
OverheadLow (1 app)Medium (need MCP client)
ScaleHardEasy (add servers)
When MCP worth
> 5 integrations, long-term maintenance, team scale.
When plain OK
1-3 tools cụ thể, MVP, tightly coupled to app.

Common questions

Ai viết MCP servers?

  • Service providers: GitHub, AWS, Google, Slack đã public MCP servers
  • Community: OSS devs wrap APIs
  • Bạn: custom business logic internal services

MCP khác gì API?

  • API: endpoints generic (REST, GraphQL)
  • MCP server: wraps API với AI-friendly tool schemas, structured for LLM consumption

MCP khác gì tool use?

  • Tool use: cơ chế Claude gọi function
  • MCP: where tool schemas + functions live

MCP tools → Claude vẫn dùng tool use pattern.

Ai invent MCP?

Anthropic. Công bố 11/2024. Open standard, cộng đồng contribute.

Ecosystem growing

(2026-04) đã có:

  • 100+ official servers: GitHub, Slack, Notion, Gmail, PostgreSQL, Stripe, ...
  • 500+ community servers: niche tools
  • Multiple clients: Claude Desktop, Claude Code, custom apps
  • SDKs: Python, TypeScript, Go, Rust

Registry: modelcontextprotocol.io

Use cases

Developer workflows

GitHub MCP + Filesystem MCP + Terminal MCP → Claude Code super power.

Enterprise assistant

Gmail + Slack + Jira + Google Drive MCP → single chatbot interface mọi tools.

Data analysis

Snowflake + Postgres + Google Sheets MCP → query + analyze across databases.

Custom business

Build internal MCP server cho CRM, ERP. Team dùng qua Claude Desktop hoặc custom chatbot.

Anti-patterns preview

Build MCP server cho 1 internal tool

Overhead not worth. Plain tool use OK.

Fix: MCP khi > 3 integrations hoặc tool sẽ shared cross-app.

Wrap existing API 1-to-1

MCP server thêm overhead. Nếu không AI-optimize, not adding value.

Fix: Design MCP tools theo AI use case, không phải mirror API.

Ignore security

MCP server = executable code. Untrusted server = security risk.

Fix: Only connect to trusted servers.

Áp dụng ngay

Bài tập 1: Explore registry (10 phút)

Visit modelcontextprotocol.io. Browse servers. Identify 3 potentially useful cho app của bạn.

Bài tập 2: Plan MCP architecture (10 phút)

Cho app bạn xây trong khóa:

  • Tools cần: ___
  • MCP server hiện có match không?
  • Build custom hay reuse?

Tóm tắt bài học

Những điều cốt lõi
  • MCP = standard protocol cho AI-tool integration. Solve maintenance burden của 50+ integrations.
  • Client-server architecture. Client = your app. Server = tool provider.
  • 3 concepts: Tools (functions), Prompts (templates), Resources (data).
  • MCP vs tool use: MCP is where tools live. Tool use is how Claude calls them.
  • Growing ecosystem 2026: 100+ official servers, industry adopting as standard.
Kiểm tra nhanh3 câu hỏi · chọn đáp án để xem giải thích
    Bạn đã hoàn thành bài này chưa?Tiến độ lưu trên trình duyệt của bạn.