Mục tiêu học tập

Sau bài này, bạn sẽ có thể:
  • ✅ Giải thích MCP là gì và tại sao nó là open standard quan trọng với hệ sinh thái agentic AI
  • ✅ Add MCP server (HTTP và stdio) bằng claude mcp add và cấu hình auth đúng cách
  • ✅ Chọn đúng scope (local / user / project) cho từng MCP server trong từng tình huống
  • ✅ Dùng /mcp để audit context cost và disable server không cần thiết
  • ✅ Quyết định khi nào dùng MCP, khi nào dùng CLI, khi nào dùng Skill

Mở đầu: Từ copy-paste đến fetch tự động

Đỗ Minh Khoa là backend engineer tại một startup fintech. Hôm nay anh cần review pull request cho ticket Linear MEN-12 — một thay đổi trong payment reconciliation flow. Trước khi có MCP: Khoa mở Linear trong browser, đọc ticket. Copy requirements. Mở terminal, mở Claude Code. Paste toàn bộ nội dung ticket vào prompt: “Đây là yêu cầu: [dán 400 từ]. Review PR này theo yêu cầu đó.” Claude đọc, review. Mất khoảng 5 phút cho việc copy-paste, chưa kể khi ticket thay đổi (PM vừa update acceptance criteria) thì bản copy đã outdated và Claude đưa ra nhận xét không còn chính xác. Sau khi add Linear MCP:
> review PR #238 theo requirements của ticket MEN-12
Claude tự fetch ticket MEN-12 từ Linear — description, acceptance criteria, comments mới nhất của PM — rồi cross-check với diff của PR. Toàn bộ diễn ra trong 30 giây. Không copy-paste. Không outdated. Claude có đúng context thực tế. Đây chính là lý do MCP tồn tại. Như tài liệu gốc của Anthropic viết:
“A lot of your context lives outside your codebase — in databases, productivity apps, or public repositories. MCP bridges that gap.”
Context không chỉ nằm trong codebase của bạn. Nó nằm trong Linear, Slack, Notion, Figma, Postgres production, Datadog dashboard, Jira backlog. MCP là cầu nối để Claude Code chạm tới tất cả những nơi đó — không phải qua copy-paste thủ công, mà qua tool calls có structured, real-time, và có thể audit.

MCP là gì?

Model Context Protocol (MCP) là open standard cho phép Claude Code kết nối với external tools và data sources. “Open standard” nghĩa là Anthropic không độc quyền — bất kỳ service nào cũng có thể build MCP server, và Claude Code (cũng như các AI agent khác) có thể connect tới.

Khái niệm cốt lõi: Tools

Trước khi hiểu MCP, cần hiểu khái niệm tools trong agentic AI. Tools cho phép agent như Claude Code thực hiện hành động — không chỉ trả về text. Khi Claude Code chạy grep, đọc file, gọi bash, hay tìm kiếm web — đó là tools. MCP mở rộng khả năng này ra ngoài máy tính của bạn: Claude có thể gọi Linear API, query Postgres, post Slack message — tất cả thông qua tool call. Đây là điểm khác biệt căn bản với AI “bình thường”: thay vì chỉ generate text, Claude Code có thể làm việc trong hệ thống thực của bạn.

Kiến trúc MCP

Claude Code nói chuyện với MCP server qua MCP Protocol (một JSON-RPC protocol chuẩn). MCP server sau đó nói chuyện với service thực (Linear API, database, v.v.). Bạn không cần biết chi tiết protocol — chỉ cần biết: Claude gọi tool, MCP server thực thi, kết quả trả về cho Claude.

2 loại MCP server

HTTP servers — Remote, hosted by service provider

HTTP servers chạy trên cloud của service provider (Linear, Slack, Notion…). Bạn connect tới chúng qua network. Thường yêu cầu auth (OAuth2 hoặc API key). Ví dụ: Linear MCP, Slack MCP, Notion MCP, GitHub MCP, Context7 MCP.

Stdio servers — Local processes trên máy bạn

Stdio servers là các process chạy trực tiếp trên máy bạn. Claude Code spawn process đó, giao tiếp qua stdin/stdout. Không có network call, không cần expose port. Ví dụ: MCP server cho local Postgres, MCP server cho nội bộ công ty (CRM, internal DB), MCP server bạn tự viết.

Bảng so sánh HTTP vs Stdio

Tiêu chíHTTP ServerStdio Server
Nơi chạyCloud của providerMáy bạn (local process)
Setup complexityThấp (URL + auth)Trung bình (cài package/binary)
Network dependencyCần internetKhông cần internet
SecurityAuth qua OAuth2 / API keyChỉ truy cập local resources
LatencyCao hơn (network round-trip)Thấp (IPC local)
Secrets exposureAPI key / OAuth tokenKhông expose ra ngoài
Ideal use caseSaaS tools (Linear, Slack, Notion)Local DB, internal tools, dev tools
Ví dụLinear, Slack, Context7, FigmaPostgres local, file system, nội bộ

Add MCP Server

Cú pháp cơ bản

# HTTP server
claude mcp add linear https://mcp.linear.app/sse

# Stdio server (command + args)
claude mcp add postgres -- npx @modelcontextprotocol/server-postgres postgresql://localhost/mydb

# Với scope cụ thể
claude mcp add --scope project linear https://mcp.linear.app/sse
Sau khi chạy lệnh, Claude Code wizard sẽ hướng dẫn auth:
Adding Linear MCP server...

Authentication required:
  → OAuth2 flow (recommended): Open browser to authenticate
  → API key: Enter your Linear API key manually

Select method [1/2]: 1

Opening browser for OAuth2...
✓ Authenticated as: Khoa Đỗ (khoa@company.com)
✓ Linear MCP server added (scope: local)

Tools available:
  • linear.get_issue       — Fetch issue details
  • linear.create_issue    — Create new issue
  • linear.update_issue    — Update status, assignee, labels
  • linear.comment         — Add comment to issue
  • linear.list_issues     — Query issues by filter
  (12 tools total, ~8k tokens in context)

Quản lý servers với /mcp

Trong session Claude Code, gõ /mcp để xem trạng thái:
> /mcp

Connected MCP Servers:
  ✓ linear       12 tools  ~8k tokens   HTTP    [active]
  ✓ context7      3 tools  ~2k tokens   HTTP    [active]
  ✓ slack         6 tools  ~4k tokens   HTTP    [idle 2h]
  ✓ postgres      8 tools  ~5k tokens   stdio   [active]
  ✗ figma        15 tools  ~12k tokens  HTTP    [disabled]

Total MCP overhead: ~19k tokens (9.5% context)

Commands: /mcp disable <name> | /mcp enable <name> | /mcp reconnect <name>

3 Scope của MCP server

Scope quyết định MCP server được lưu ở đâu và ai có thể dùng.
ScopeFile lưuAi có thể dùngChia sẻQuản lý secret
Local~/.claude/mcp.json (project-specific entry)Chỉ bạn, project hiện tạiKhôngAPI key trong local config, không vào repo
User~/.claude/mcp.json (global)Chỉ bạn, tất cả projectsKhôngAPI key trong local config
Project.mcp.json trong root repoCả team (ai clone repo đều get)Có — qua version controlDùng env vars, KHÔNG hardcode key
Typical use case Local scope: MCP server cho database dev local (chỉ bạn dùng, chỉ project này). Test API key cá nhân. User scope: Linear MCP, Slack MCP bạn dùng across mọi project. Personal preference. Project scope: Team shared servers — Linear (cả team đều cần xem ticket), Context7 (docs cho stack chung), GitHub MCP. Commit .mcp.json vào repo, mọi người clone về là có ngay.

.mcp.json example (project scope)

{
  "mcpServers": {
    "linear": {
      "type": "http",
      "url": "https://mcp.linear.app/sse",
      "env": {
        "LINEAR_API_KEY": "${LINEAR_API_KEY}"
      }
    },
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/sse"
    },
    "postgres": {
      "type": "stdio",
      "command": "npx",
      "args": ["@modelcontextprotocol/server-postgres", "${DATABASE_URL}"]
    }
  }
}
API key đặt trong env vars (.env gitignored) — không bao giờ hardcode vào .mcp.json.

CRITICAL: Context Cost của MCP

Đây là phần quan trọng nhất bài này. Hiểu sai điểm này dẫn đến lãng phí context window rất lớn.

MCP servers add tool definitions — kể cả khi bạn không dùng

Khi Claude Code start, nó load toàn bộ tool definitions của tất cả MCP server đang enabled. Tool definition là JSON schema mô tả mỗi tool có tham số gì, làm gì. Mỗi definition này tốn token. 5 server không dùng → 30k token lãng phí — tương đương 15% context window mất trước khi bạn gõ prompt đầu tiên.

Tính toán thực tế

ServerToolsToken definitionDùng thực tế
Linear12~8kMỗi ngày
Context73~2kKhi cần docs
Slack6~4kVài lần/tuần
Figma15~12kChỉ khi design
Jira10~7kTeam không dùng nữa
Tổng46~33k
Nếu bạn chỉ làm backend dev hôm nay: Linear + Context7 là đủ (~10k). Figma và Jira là 19k wasted. Hơn 57% MCP overhead là không cần thiết.

Audit và clean up với /mcp

> /mcp

⚠️  MCP overhead: 33k tokens (16.5% context)
    Recommend: disable unused servers

> /mcp disable figma
✓ figma disabled. Restart session for effect.

> /mcp disable jira
✓ jira disabled. Restart session for effect.

> /mcp
MCP overhead: 14k tokens (7% context)  ← giảm được 19k tokens

Auto tool search mode (unstable)

Khi MCP tools vượt 10% context window, Claude Code tự động switch sang tool search mode — thay vì load toàn bộ definitions, nó search on-demand khi cần tool nào mới load tool đó. Nghe hay, nhưng feature này chưa stable. Tool search đôi khi miss tool phù hợp, dẫn đến Claude không biết tool đó tồn tại. Không nên dựa vào auto tool search. Chủ động /mcp disable vẫn là cách tốt hơn. Xem thêm về quản lý context trong Bài 2.5: Quản lý Context — phần “Chiến thuật 5: Dọn dẹp MCP servers không dùng”.

CRITICAL: MCP vs CLI vs Skill — Decision tree

Đây là quyết định quan trọng. Không phải mọi integration đều nên là MCP server.

Bảng so sánh CLI vs MCP vs Skill

Tiêu chíCLI (gh, aws…)MCP ServerSkill
Context costKhông (zero)Cao (2-15k/server, luôn on)Thấp (chỉ load khi dùng)
SetupĐã có sẵnCần claude mcp add + authViết 1 file markdown
CapabilityTheo CLI flagsTheo tool definitionsTheo instructions trong file
Real-time dataQua lệnh CLITự động qua tool callCần bạn provide data
Best forGitHub, AWS, k8s, DB migrationLinear, Slack, Figma, NotionWorkflows lặp lại, checklists
Khi nào dùngCLI tốt và documentedDùng hàng ngày, cần real-timeTask specific, không có CLI/MCP

Anthropic internal example: cu tool

Anthropic sử dụng một internal CLI tool tên cu cho các workflows nội bộ. Thay vì tạo MCP server riêng cho cu, Anthropic chỉ cần ghi vào CLAUDE.md:
## Internal Tools

We use `cu` for internal task management. Key commands:
- `cu task list` — list your open tasks
- `cu task create "title" --project X` — create task
- `cu deploy --env staging` — deploy to staging
Claude tự biết khi nào cần gọi cu, không cần MCP server, không tốn token cho tool definitions. Đây là triết lý CLI > MCP khi CLI đã đủ tốt. Xem thêm về cách document internal tools trong CLAUDE.md ở Bài 2.7: File CLAUDE.md.

Ví dụ thực chiến: Setup Linear + Context7 + Slack cho dev team

Bối cảnh

Team 5 người, stack: Next.js + Postgres + Linear + Slack. Bạn muốn Claude Code có thể:
  • Fetch ticket details từ Linear
  • Tra cứu docs thư viện up-to-date
  • Post notification khi PR merge

Bước 1: Add Linear MCP (HTTP, OAuth)

claude mcp add --scope project linear https://mcp.linear.app/sse
Wizard mở browser → Authenticate với Linear account → Done. Claude giờ có thể:
  • Fetch ticket chi tiết, acceptance criteria, comments
  • Transition status (In Progress → In Review)
  • Comment trực tiếp lên ticket

Bước 2: Add Context7 MCP (HTTP)

claude mcp add --scope project context7 https://mcp.context7.com/sse
Không cần auth (public service). Claude giờ có thể fetch docs Next.js, React, Postgres, bất kỳ npm package nào — luôn up-to-date, không hallucinate API cũ.

Bước 3: Add Slack MCP (HTTP)

claude mcp add --scope user slack https://mcp.slack.com/sse
Scope user (không phải project) vì Slack token là cá nhân. Wizard → OAuth → Done.

Bước 4: Save vào .mcp.json project, commit

Linear và Context7 đã ở scope project nên tự động vào .mcp.json. Kiểm tra:
cat .mcp.json
{
  "mcpServers": {
    "linear": {
      "type": "http",
      "url": "https://mcp.linear.app/sse",
      "env": { "LINEAR_API_KEY": "${LINEAR_API_KEY}" }
    },
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/sse"
    }
  }
}
Commit file này:
git add .mcp.json
git commit -m "chore: add Linear + Context7 MCP servers for team"
Slack không vào .mcp.json vì scope user — mỗi người tự auth bằng account của mình.

Bước 5: Team clone repo → auto get MCP servers

Teammate mới clone repo:
git clone https://github.com/company/project
cd project
claude
Claude Code tự đọc .mcp.json, prompt:
Found .mcp.json with 2 servers:
  • linear — requires auth (click to authenticate)
  • context7 — no auth required

Set up now? [Y/n]: Y
Teammate authenticate Linear một lần → xong. Không cần hướng dẫn manual setup.

Bước 6: /mcp audit context cost — disable khi không cần

Cuối sprint, bạn đang focus code, không cần Slack notifications:
> /mcp

Connected:
  ✓ linear   12 tools  ~8k tokens   [active]
  ✓ context7  3 tools  ~2k tokens   [active]
  ✓ slack     6 tools  ~4k tokens   [user scope, idle]

Total overhead: ~14k tokens (7% context)

> /mcp disable slack
✓ slack disabled for this session.
  Context freed: ~4k tokens

Case studies theo role

Backend Engineer: Postgres MCP + Plan Mode

Tình huống: Cần optimize query đang slow, nhưng không nhớ chính xác schema các bảng.
> Trong Plan Mode: analyze query này trong src/reports/monthly.ts
  và đề xuất optimization. Dùng Postgres MCP để check actual indexes.
Claude switch Plan Mode, dùng postgres.describe_table() để xem schema thực, postgres.list_indexes() để xem indexes hiện tại, sau đó đề xuất plan thêm index composite cụ thể. Không cần bạn copy-paste schema. MCP dùng: Stdio Postgres server (local DB), scope local.

DevOps/SRE: Incident Response với Datadog + PagerDuty

Tình huống: Alert 2h sáng, service down.
> Check Datadog MCP: service payments-api — error rate và p99 latency
  30 phút qua. Sau đó check PagerDuty MCP: incidents liên quan.
  Tóm tắt root cause hypothesis.
Claude fetch metrics từ Datadog, check incident history từ PagerDuty, cross-reference. Trả về “p99 tăng đột biến lúc 01:43 UTC, trùng với deploy v2.3.1, khả năng connection pool exhaustion” — trong 2 phút, không cần mở 3 tab browser. MCP dùng: Datadog MCP + PagerDuty MCP, scope user.

Frontend Engineer: Figma MCP fetch design specs

Tình huống: Implement component mới từ Figma design.
> Fetch Figma frame "Button variants" từ file Design System v3.
  Implement theo exact specs: colors, padding, border-radius, hover state.
Claude dùng Figma MCP lấy design tokens trực tiếp — không cần bạn đo pixel hay copy hex code thủ công. Implementation khớp 100% với design. MCP dùng: Figma MCP, scope user.

Product Manager: Sprint Summary

Tình huống: Viết sprint summary hàng tuần.
> Dùng Linear MCP: fetch tất cả issues completed sprint MEN-Sprint-14.
  Dùng Notion MCP: lấy template sprint summary.
  Generate summary hoàn chỉnh theo template.
Claude fetch từ cả hai nguồn, generate summary có đầy đủ: features shipped, bugs fixed, blocked items, metrics. PM chỉ cần review và publish. MCP dùng: Linear MCP + Notion MCP, scope project.

Marketing: weekly metrics digest

Tình huống: Báo cáo metrics hàng tuần cho team.
> Google Analytics MCP: fetch sessions, conversion rate, top pages tuần này.
  So sánh với tuần trước. Format theo template và post lên #marketing-metrics Slack.
MCP dùng: Google Analytics MCP + Slack MCP, scope user.

Anti-patterns

Anti-pattern 1: Bật mọi MCP server “phòng khi cần”

Triệu chứng: /mcp show 12 server connected. Tổng overhead 60k tokens. Bạn thực sự dùng 2 server mỗi ngày. Tại sao tệ: 60k token = 30% context window mất trước khi làm việc. Performance giảm, cost tăng, Claude bị “loãng” attention. Cách đúng: Enable MCP server theo project (.mcp.json chỉ có những gì cả team cần), disable cá nhân những gì bạn không dùng session đó.

Anti-pattern 2: Dùng MCP khi CLI đã đủ tốt

Ví dụ sai: Add github-mcp trong khi gh CLI đã có sẵn, documented tốt, và bạn dùng thành thạo. Tại sao tệ: gh tốn 0 token overhead. github-mcp tốn ~10k token definitions. Với gh, bạn kiểm soát chính xác command nào chạy. Với MCP, Claude tự quyết — đôi khi gọi tool không cần thiết. Cách đúng: GitHub → dùng gh. AWS → dùng aws. Kubernetes → dùng kubectl. Chỉ dùng MCP khi không có CLI tốt hoặc khi cần real-time data phức tạp hơn CLI cho phép.

Anti-pattern 3: Hardcode API key trong .mcp.json

Ví dụ sai:
{
  "mcpServers": {
    "linear": {
      "env": { "LINEAR_API_KEY": "lin_api_abc123xyz..." }
    }
  }
}
File này checked vào repo → API key lộ cho toàn team, lộ vào git history. Cách đúng: Dùng env vars:
{ "LINEAR_API_KEY": "${LINEAR_API_KEY}" }
Key thực nằm trong .env (gitignored) hoặc CI/CD secrets.

Anti-pattern 4: Không refresh OAuth token định kỳ

Triệu chứng: Đang làm việc giữa session, Claude báo “Linear MCP error: 401 Unauthorized”. Mất đà, phải interrupt để re-auth. Cách đúng: /mcp reconnect linear để refresh token trước khi bắt đầu session dài. Set calendar reminder re-auth OAuth monthly (token thường expire 30-90 ngày).

Anti-pattern 5: Skip /mcp audit — MCP zombie

Triệu chứng: 6 tháng sau bạn nhận ra Jira MCP vẫn connected dù team chuyển sang Linear từ tháng 2. 7k token mất mỗi session từ tháng 2. Cách đúng: Mỗi tháng gõ /mcp một lần, check usage. Disable server không còn relevant. 5 phút/tháng tiết kiệm hàng nghìn token.

Anti-pattern 6: Dùng MCP cho one-off task

Tình huống: Bạn cần một lần duy nhất query Notion để lấy meeting notes hôm qua. Sai: Add Notion MCP (setup, auth, tốn ~5k token overhead mãi mãi sau đó). Đúng: Viết Skill nhỏ với curl gọi Notion API một lần, hoặc copy-paste thủ công nếu thực sự chỉ 1 lần.

Mẹo nâng cao

Mẹo 1: Local MCP server cho internal tools

Nếu công ty có internal CRM, legacy system không expose public API — bạn vẫn có thể build MCP server local (stdio):
# Build simple stdio MCP server
# chạy trên máy bạn, không expose ra internet
claude mcp add --scope project internal-crm -- python3 ./scripts/crm-mcp-server.py
Script Python gọi internal REST API của công ty, serve MCP protocol qua stdio. Không cần firewall rules, không expose mạng.

Mẹo 2: .mcp.json template cho organization

Tạo template repo có sẵn .mcp.json với cấu hình chuẩn cho stack của team:
organization-templates/
├── nextjs-starter/
│   └── .mcp.json  # linear + context7 + postgres
├── python-api/
│   └── .mcp.json  # linear + context7 + datadog
└── mobile-react-native/
    └── .mcp.json  # linear + figma + context7
Mỗi project mới fork từ template → có sẵn MCP config chuẩn của org.

Mẹo 3: Multiple environment — dev vs prod MCP

{
  "mcpServers": {
    "postgres-dev": {
      "type": "stdio",
      "command": "npx",
      "args": ["@mcp/postgres", "${DEV_DATABASE_URL}"]
    },
    "postgres-prod": {
      "type": "stdio",
      "command": "npx",
      "args": ["@mcp/postgres", "${PROD_DATABASE_URL}"]
    }
  }
}
Dev và prod database tách biệt trong .mcp.json. Switch bằng env vars — không nhầm lẫn.

Mẹo 4: Combine MCP + Skill cho workflows phức tạp

Skill /sprint-review (xem Bài 2.9: Skills) có thể orchestrate nhiều MCP servers:
# /sprint-review

Workflow:
1. Linear MCP: fetch all completed issues sprint hiện tại
2. GitHub MCP: fetch PRs merged tuần này, link với issues
3. Slack MCP: fetch messages #bugs channel 7 ngày qua
4. Generate sprint review document:
   - Features shipped (link PR + ticket)
   - Bugs fixed vs reported
   - Velocity metrics
   - Blockers next sprint
5. Post summary vào Slack #engineering channel
Bạn gõ /sprint-review, Claude orchestrate 3 MCP servers, tổng hợp, post kết quả. 10 phút thủ công → 30 giây.

Mẹo 5: Delegate MCP-heavy task sang subagent

Nếu task cần fetch nhiều data từ nhiều MCP servers (ví dụ: generate quarterly report từ Linear + GitHub + Datadog + Slack + Google Analytics), đừng để main context phình:
Spawn subagent để generate quarterly report Q1:
- Fetch từ Linear: 3 sprints completed
- Fetch từ GitHub: PRs, contributors
- Fetch từ Datadog: uptime, incident count
- Trả về summary 1 trang, không cần raw data
Subagent chạy với context window riêng (xem Bài 2.8: Subagents), gọi các MCP tools, trả về summary. Main context của bạn nhận 1 trang kết quả thay vì hàng chục nghìn token raw data.

Mẹo 6: Audit monthly

Lịch đơn giản để không có MCP zombie:
Mỗi đầu tháng:
1. /mcp → review list
2. Có server nào không dùng tháng trước? → disable
3. Có workflow mới cần MCP server? → add
4. OAuth token nào gần expire? → renew
5. .mcp.json có outdated server? → remove + commit
5 phút/tháng, context luôn clean.

Áp dụng ngay

Bài tập 1: Khám phá MCP ecosystem (15 phút)

Bước 1: Mở trình duyệt, vào claude.com/connectors. Bước 2: Browse theo category. Identify 2-3 MCP servers relevant với stack/workflow của bạn. Gợi ý theo stack:
  • Web dev: Context7 (docs) + Linear/Jira (tickets) + GitHub (PRs)
  • Backend/Data: Postgres/MySQL MCP + any analytics MCP
  • DevOps: Datadog/Grafana MCP + PagerDuty MCP
  • Mobile: Figma MCP + Linear MCP
Bước 3: Add 1 server thử:
claude mcp add --scope local <name> <url>
Bước 4: Trong session Claude Code, thử dùng tool của server đó. Ví dụ với Context7:
> Tìm latest API của React Hook useCallback, dùng context7
Ghi lại: Server add mất bao lâu? Tool hoạt động như kỳ vọng?

Bài tập 2: Audit context cost (10 phút)

Bước 1: Mở project bạn đang làm, start Claude Code. Bước 2: Gõ /mcp. Bước 3: Điền vào bảng audit:
Server name    | Tools | Token est | Dùng lần cuối | Giữ?
──────────────────────────────────────────────────────────
               |       |           |               | Y/N
               |       |           |               | Y/N
               |       |           |               | Y/N

Total overhead: ___ tokens (___ % context)
Overhead sau khi clean: ___ tokens (___ % context)
Bước 4: Disable 1+ server không cần thiết:
> /mcp disable <name>
Bước 5: Gõ lại /mcp, so sánh overhead trước và sau.

Tóm tắt

🎯 MCP là open standard — cho phép Claude Code thực hiện actions trong external services (Linear, Slack, Postgres, Figma…) thay vì chỉ trả về text. Tools là cơ chế core của agentic AI. 🎯 2 loại server: HTTP server (remote, provider-hosted, cần auth) và Stdio server (local process, không cần network, an toàn cho internal tools). 🎯 3 scope: Local (chỉ bạn, project này), User (bạn, mọi project), Project (cả team, qua .mcp.json checked in repo). API key luôn qua env vars, không hardcode. 🎯 MCP tốn context kể cả khi không dùng — mỗi server 2-15k token definitions. Dùng /mcp audit định kỳ, disable server không essential. Tránh MCP zombie. 🎯 CLI > MCP khi CLI đã tốt. gh cho GitHub, aws cho AWS — zero context overhead. MCP tốt nhất khi service không có CLI và bạn dùng hàng ngày.

Bài tiếp theo

Bạn đã biết cách mở rộng Claude Code ra ngoài codebase qua MCP. Nhưng còn một lớp automation nữa: Hooks — scripts chạy tự động ở các lifecycle events (trước khi tool chạy, sau khi Claude hoàn thành, khi có lỗi…). Hooks khác với MCP, Skills, hay CLAUDE.md ở điểm quan trọng: deterministic — chạy mọi lúc, không phụ thuộc vào Claude quyết định. Bài 2.11 sẽ đi sâu vào Hooks: PreToolUse, PostToolUse, exit codes, và cách build automation pipeline thực sự tin cậy. ➡️ Bài tiếp theo: Bài 2.11 — Hooks: Automation tất định

Tài liệu tham khảo

  • claude.com/connectors — Catalog hàng trăm MCP server chính thức
  • MCP specification — Open standard spec, JSON-RPC protocol details
  • Anthropic MCP docs — Official Claude Code MCP guide
  • Slash command trong session: /mcp — list, disable, reconnect servers
  • CLI command: claude mcp add, claude mcp list, claude mcp remove
  • Cross-reference: Bài 2.5 (context cost quản lý), Bài 2.7 (CLAUDE.md + internal CLI tools), Bài 2.8 (subagent + MCP delegation), Bài 2.9 (MCP vs Skill decision)
Khoá học “Claude Code 101” — bản tiếng Việt v1.0Bản quyền 2026 Anthropic. Mọi quyền được bảo lưu.