MCP - Giao thức Kết nối Vạn năng cho Hệ thống AI Multi-Agent 2026

Posted on: 4/13/2026 3:19:05 PM

MCP Multi-Agent Claude Code Agentic AI System Architecture

1. MCP là gì và tại sao nó quan trọng?

Model Context Protocol (MCP) là giao thức chuẩn mở cho phép các ứng dụng AI (LLM) kết nối với dữ liệu, công cụ và dịch vụ bên ngoài một cách thống nhất. Nếu bạn đã từng phải viết integration riêng cho từng API, từng database, từng dịch vụ cloud - thì MCP chính là lời giải cho bài toán "N x M integration" đó.

Hãy tưởng tượng MCP như USB-C của thế giới AI: thay vì mỗi thiết bị dùng một loại cáp riêng, tất cả đều kết nối qua một chuẩn duy nhất. Trước MCP, mỗi khi bạn muốn Claude đọc file, truy vấn database, hay gọi API, bạn phải viết custom tool definitions và integration code. Với MCP, bạn chỉ cần kết nối MCP Server có sẵn - hàng nghìn server đã được cộng đồng xây dựng.

97M+Lượt cài đặt MCP (03/2026)
12,000+MCP Server trên Registry
8Founding Members AAIF
100%LLM hàng đầu hỗ trợ MCP

Điểm nhấn quan trọng

Tính đến tháng 4/2026, MCP đã vượt mốc 97 triệu lượt cài đặt - tốc độ adoption nhanh nhất của bất kỳ chuẩn hạ tầng AI nào trong lịch sử, vượt cả Kubernetes trong giai đoạn tương đương. Mọi nền tảng AI lớn - Claude, ChatGPT, Gemini, Copilot - đều hỗ trợ MCP native.

2. Hành trình từ nội bộ Anthropic đến chuẩn mở toàn cầu

Câu chuyện của MCP là một trong những case study đáng chú ý nhất về cách một công nghệ nội bộ trở thành chuẩn công nghiệp:

Tháng 11/2024
Anthropic công bố MCP dưới dạng mã nguồn mở. Ban đầu chỉ hỗ trợ Claude Desktop và Claude Code, giao thức sử dụng stdio transport cho kết nối local.
Tháng 3/2025
MCP spec được cập nhật lớn: thêm Streamable HTTP transport thay thế SSE, hỗ trợ OAuth 2.1 cho xác thực, và giới thiệu Tool Annotations.
Tháng 5/2025
OpenAI tuyên bố hỗ trợ MCP trong ChatGPT và Agents SDK. Đây là bước ngoặt: đối thủ cạnh tranh chấp nhận chuẩn của Anthropic.
Tháng 11/2025
MCP spec November 2025 release: thêm async operations, stateless mode, server identity, và DPoP authentication extension.
Tháng 12/2025
Anthropic trao MCP cho Agentic AI Foundation (AAIF) thuộc Linux Foundation. Founding members: Anthropic, OpenAI, Google, Microsoft, AWS, Cloudflare, Block, Bloomberg.
Tháng 4/2026
MCP Dev Summit North America tổ chức tại NYC. Cộng đồng vượt 12,000 MCP Server trên Registry.

Tại sao Anthropic trao MCP cho Linux Foundation?

Đây là chiến lược thông minh: một giao thức do một công ty sở hữu sẽ luôn bị nghi ngờ về tính trung lập. Bằng cách trao cho foundation trung lập với các đối thủ làm co-founders, MCP chuyển từ "chuẩn của Anthropic" thành "chuẩn của ngành" - tương tự cách Google trao Kubernetes cho CNCF.

3. Kiến trúc kỹ thuật của MCP

MCP sử dụng kiến trúc Client-Server với giao thức truyền thông dựa trên JSON-RPC 2.0. Điểm khác biệt quan trọng so với REST API truyền thống: MCP được thiết kế cho stateful sessions với khả năng discovery tự động.

graph LR
    A["Host Application"] --> B["MCP Client"]
    B -->|"JSON-RPC 2.0"| C["MCP Server 1 - Filesystem"]
    B -->|"JSON-RPC 2.0"| D["MCP Server 2 - Database"]
    B -->|"JSON-RPC 2.0"| E["MCP Server 3 - API Gateway"]
    C --> F["Local Files"]
    D --> G["PostgreSQL, Redis, ClickHouse"]
    E --> H["GitHub, Jira, Slack"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff
    style C fill:#4CAF50,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff
    style E fill:#4CAF50,stroke:#fff,color:#fff

Hình 1: Kiến trúc tổng quan MCP - Host Application kết nối nhiều MCP Server qua JSON-RPC 2.0

3.1. Ba thành phần chính

Host Application là ứng dụng AI mà người dùng tương tác trực tiếp (Claude Code, Cursor, VS Code Copilot...). Host chứa một hoặc nhiều MCP Client.

MCP Client duy trì kết nối 1:1 với một MCP Server. Client chịu trách nhiệm:

  • Khởi tạo kết nối và capability negotiation
  • Gửi requests (tool calls, resource reads) đến server
  • Nhận notifications và kết quả từ server
  • Quản lý vòng đời của kết nối

MCP Server expose capabilities cho client. Mỗi server có thể cung cấp:

  • Tools: Hành động mà LLM có thể thực thi (gọi API, query database, chạy command...)
  • Resources: Dữ liệu mà LLM có thể đọc (file content, database records, API responses...)
  • Prompts: Template prompt được định nghĩa sẵn cho các tác vụ cụ thể

3.2. Capability Negotiation

Khi kết nối được thiết lập, client và server thực hiện capability negotiation - trao đổi thông tin về những gì mỗi bên hỗ trợ:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-11-05",
    "capabilities": {
      "roots": { "listChanged": true },
      "sampling": {}
    },
    "clientInfo": {
      "name": "claude-code",
      "version": "1.45.0"
    }
  }
}

4. Transport Layer: Streamable HTTP và SSE

MCP hỗ trợ nhiều transport layer, cho phép linh hoạt trong triển khai:

TransportUse CaseĐặc điểmƯu/Nhược
stdioLocal development, CLI toolsGiao tiếp qua stdin/stdoutĐơn giản, không cần network. Chỉ local.
Streamable HTTPProduction, remote serversHTTP POST + SSE streamingHỗ trợ stateless lẫn stateful. Chuẩn mới nhất.
SSE (Legacy)Remote servers (cũ)Server-Sent EventsĐang bị thay thế bởi Streamable HTTP.

4.1. Streamable HTTP - Transport chính thức

Từ spec tháng 3/2025, Streamable HTTP trở thành transport được khuyến nghị cho mọi deployment production. Client gửi JSON-RPC qua HTTP POST, server có thể trả về response trực tiếp hoặc mở SSE stream cho long-running operations.

sequenceDiagram
    participant C as MCP Client
    participant S as MCP Server
    C->>S: POST /mcp initialize
    S-->>C: 200 OK + Session ID
    C->>S: POST /mcp tools/call
    Note over S: Short operation
    S-->>C: 200 OK JSON-RPC result
    C->>S: POST /mcp tools/call long
    Note over S: Long-running operation
    S-->>C: 200 OK SSE stream start
    S-->>C: event progress 25 pct
    S-->>C: event progress 75 pct
    S-->>C: event result final

Hình 2: Streamable HTTP - Tự động chuyển đổi giữa response trực tiếp và SSE stream

Tại sao không dùng WebSocket?

Nhiều developer thắc mắc tại sao MCP chọn HTTP + SSE thay vì WebSocket. Lý do chính: compatibility. HTTP hoạt động tốt với proxy, load balancer, CDN, và firewall. SSE tự động reconnect khi mất kết nối. WebSocket tuy bidirectional nhưng gặp nhiều vấn đề với enterprise infrastructure.

5. Primitives: Tools, Resources, Prompts và Sampling

5.1. Tools - Hành động của Agent

Tools là primitive quan trọng nhất, cho phép LLM thực thi hành động trong thế giới thực. Mỗi tool được mô tả bằng JSON Schema:

{
  "name": "query_database",
  "description": "Execute a read-only SQL query",
  "inputSchema": {
    "type": "object",
    "properties": {
      "sql": { "type": "string", "description": "The SQL SELECT query" },
      "params": { "type": "array", "description": "Parameterized values" }
    },
    "required": ["sql"]
  },
  "annotations": {
    "readOnlyHint": true,
    "openWorldHint": false
  }
}

Tool Annotations - Metadata thông minh

Từ spec 2025, MCP thêm Tool Annotations - metadata mô tả tính chất của tool:

  • readOnlyHint: Tool chỉ đọc dữ liệu, không ghi
  • destructiveHint: Tool có thể xóa hoặc sửa đổi dữ liệu
  • idempotentHint: Gọi nhiều lần cho cùng kết quả
  • openWorldHint: Tool tương tác với hệ thống bên ngoài

5.2. Resources - Dữ liệu của Agent

Resources cho phép server expose dữ liệu theo kiểu URI-based. Khác với tools, resources thường do application control.

5.3. Sampling - Reverse LLM Calls

Đây là primitive độc đáo nhất của MCP: Sampling cho phép server yêu cầu LLM xử lý thông tin. Luồng thông thường là LLM đến tool, nhưng sampling đảo ngược: tool đến LLM.

graph LR
    A["MCP Server"] -->|"sampling/createMessage"| B["MCP Client"]
    B -->|"Forward to LLM"| C["LLM"]
    C -->|"Response"| B
    B -->|"Result"| A
    style A fill:#4CAF50,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff
    style C fill:#e94560,stroke:#fff,color:#fff

Hình 3: Sampling - MCP Server yêu cầu LLM xử lý thông qua host application

6. MCP vs A2A: Hai giao thức bổ trợ nhau

Một nhầm lẫn phổ biến: coi MCPA2A (Agent-to-Agent Protocol) của Google là đối thủ cạnh tranh. Thực tế, chúng giải quyết hai bài toán khác nhau.

Tiêu chíMCPA2A (Google)
Mục đíchAgent - Tool/DataAgent - Agent
Ví vonUSB-C (kết nối ngoại vi)HTTP (giao tiếp giữa máy chủ)
Bài toán chínhAgent truy cập tools, data, APIsAgents giao tiếp, phối hợp
DiscoveryServer Cards, MCP RegistryAgent Cards
FoundationAAIF - Linux FoundationChưa có foundation riêng
graph LR
    A["Agent A - Claude"] -->|"A2A Protocol"| B["Agent B - Gemini"]
    A -->|"MCP"| C["Tool: GitHub"]
    A -->|"MCP"| D["Tool: Database"]
    B -->|"MCP"| E["Tool: Search"]
    B -->|"MCP"| F["Tool: Calendar"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#4285f4,stroke:#fff,color:#fff
    style C fill:#4CAF50,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff
    style E fill:#4CAF50,stroke:#fff,color:#fff
    style F fill:#4CAF50,stroke:#fff,color:#fff

Hình 4: MCP và A2A trong hệ thống Multi-Agent

Quy tắc vàng

Dùng MCP khi agent cần nói chuyện với công cụ/dữ liệu. Dùng A2A khi agent cần nói chuyện với agent khác. Trong production, hầu hết hệ thống sẽ dùng cả hai.

7. 9 Production Patterns cho Multi-Agent với MCP

Dựa trên kinh nghiệm triển khai thực tế và case study tại MCP Dev Summit 2026:

Pattern 1: Single Agent + Multiple MCP Servers

Bắt đầu từ đây. Pattern phổ biến nhất, giải quyết khoảng 80% use cases. Một agent kết nối nhiều MCP servers.

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/project"]
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "postgresql://..." }
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "ghp_..." }
    }
  }
}

Sai lầm phổ biến

Nhiều team nhảy thẳng vào multi-agent mà chưa thử single agent + MCP. Kết quả: tốn 10x token, debugging phức tạp. Luôn bắt đầu với single agent, chỉ scale lên multi-agent khi có bottleneck rõ ràng.

Pattern 2: Supervisor - Hierarchical Delegation

Một agent manager phân công tasks cho các agent chuyên biệt:

graph TD
    A["Supervisor Agent"] --> B["Code Agent"]
    A --> C["Test Agent"]
    A --> D["Deploy Agent"]
    B --> E["Result"]
    C --> E
    D --> E
    E --> A
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff
    style C fill:#4CAF50,stroke:#fff,color:#fff
    style D fill:#ff9800,stroke:#fff,color:#fff

Hình 5: Supervisor Pattern - Agent manager phân công và tổng hợp kết quả

Các pattern còn lại

  • Pattern 3 - Pipeline: Các agents xử lý tuần tự, output trước là input sau
  • Pattern 4 - Map-Reduce: Chia subtasks, xử lý song song, tổng hợp kết quả
  • Pattern 5 - Router: Agent router phân loại và chuyển request đến agent phù hợp
  • Pattern 6 - Evaluator-Optimizer: Một agent tạo, một agent đánh giá, lặp đến khi đạt chuẩn
  • Pattern 7 - Swarm: Nhiều agents tự chủ, chia sẻ context qua MCP resources
  • Pattern 8 - Server Chaining: MCP Server A gọi MCP Server B trong xử lý
  • Pattern 9 - Human-in-the-Loop: MCP Server yêu cầu human approval trước khi thực thi

8. Claude Code - Triển khai MCP tham chiếu thực tế

Claude Code là reference implementation tốt nhất để hiểu MCP trong production.

graph TD
    A["Claude Code CLI"] --> B["Agent Loop"]
    B --> C["Built-in Tools"]
    B --> D["MCP Client Manager"]
    D --> E["MCP Server: Filesystem"]
    D --> F["MCP Server: GitHub"]
    D --> G["MCP Server: Database"]
    D --> H["MCP Server: Custom"]
    B --> I["Context Manager"]
    B --> J["Permission System"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff

Hình 6: Kiến trúc Claude Code với MCP Client Manager

Các tính năng MCP-powered nổi bật

  • Dynamic Tool Discovery: Tự động discover tools từ MCP servers khi khởi động
  • Permission Modes: Tận dụng Tool Annotations để auto-approve read-only tools
  • Sub-agents: Agent tool tạo sub-agents với MCP servers riêng
  • Remote MCP: Kết nối qua Streamable HTTP cho shared team tools

Ví dụ cấu hình MCP Server

{
  "mcpServers": {
    "postgres": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb" }
    },
    "remote-jira": {
      "type": "streamable-http",
      "url": "https://mcp.company.com/jira"
    }
  }
}

9. Bảo mật và xác thực trong MCP

9.1. OAuth 2.1 - Authentication chuẩn

Từ spec tháng 3/2025, MCP sử dụng OAuth 2.1 làm cơ chế xác thực chính: PKCE flow, Dynamic Client Registration, delegate sang third-party IdP.

9.2. DPoP - Proof of Possession

Spec tháng 11/2025 thêm DPoP extension giải quyết vấn đề token theft: ngay cả khi attacker đánh cắp access token, họ không thể sử dụng nếu không có private key tương ứng.

9.3. Server Identity và Trust

{
  "name": "company-postgres",
  "version": "2.1.0",
  "capabilities": ["tools", "resources"],
  "authentication": {
    "type": "oauth2",
    "authorizationUrl": "https://auth.company.com/authorize"
  },
  "publisher": { "name": "Company Inc", "verified": true }
}

Security Best Practices

1. Luôn dùng read-only access cho database production. 2. Audit tool calls - log mọi tool invocation. 3. Principle of least privilege. 4. Review third-party servers trước khi dùng.

10. Hướng dẫn xây dựng MCP Server đầu tiên

Xây dựng MCP Server bằng TypeScript - query ClickHouse database:

mkdir mcp-clickhouse && cd mcp-clickhouse
npm init -y
npm install @modelcontextprotocol/sdk @clickhouse/client zod
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { createClient } from "@clickhouse/client";
import { z } from "zod";

const clickhouse = createClient({
  url: process.env.CLICKHOUSE_URL || "http://localhost:8123",
  database: process.env.CLICKHOUSE_DB || "default",
});

const server = new McpServer({
  name: "clickhouse-analytics",
  version: "1.0.0",
});

server.tool(
  "query_clickhouse",
  "Execute a read-only ClickHouse SQL query",
  {
    sql: z.string().describe("SELECT query to execute"),
    format: z.enum(["JSON", "CSV", "TSV"]).default("JSON"),
  },
  async ({ sql, format }) => {
    if (!/^\s*SELECT/i.test(sql)) {
      return {
        content: [{ type: "text", text: "Error: Only SELECT queries" }],
        isError: true,
      };
    }
    const result = await clickhouse.query({ query: sql, format: "JSONEachRow" });
    const data = await result.text();
    return { content: [{ type: "text", text: data }] };
  }
);

const transport = new StdioServerTransport();
await server.connect(transport);

11. Tương lai của MCP và hệ sinh thái Agentic AI

11.1. MCP Registry - App Store cho AI Tools

MCP Registry đang phát triển thành hệ sinh thái tương tự npm. Với hơn 12,000 servers, tăng trưởng khoảng 500 servers/tuần.

11.2. Enterprise Adoption

Các tổ chức lớn đang xây dựng internal MCP server catalogs - tương tự private Docker registries.

11.3. MCP + A2A Convergence

MCP và A2A sẽ có integration points chính thức. Agent vừa dùng MCP access tools, vừa dùng A2A phối hợp với agents khác.

11.4. Embedded MCP trong Hardware

Thiết bị IoT và edge devices expose capabilities qua MCP servers. AI agent tương tác với thế giới vật lý thông qua cùng giao thức.

graph TD
    A["AI Agent"] --> B["MCP Client"]
    B --> C["Cloud MCP Servers"]
    B --> D["Enterprise MCP Servers"]
    B --> E["Edge MCP Servers"]
    B --> F["A2A Gateway"]
    C --> G["GitHub, Jira, Slack, Database"]
    D --> H["HRIS, CRM, ERP, Internal APIs"]
    E --> I["Sensors, Cameras, Actuators"]
    F --> J["Gemini, GPT, Custom Agents"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff

Hình 7: Tầm nhìn hệ sinh thái MCP 2026-2027

12. Kết luận

MCP đã chuyển từ internal protocol của Anthropic thành chuẩn công nghiệp de facto cho AI tool integration chỉ trong 18 tháng. Với 97 triệu lượt cài đặt và sự backing của Linux Foundation, MCP là infrastructure layer bắt buộc cho bất kỳ hệ thống AI nào nghiêm túc.

Những điểm then chốt:

  • Bắt đầu từ single agent + MCP - đừng vội multi-agent khi chưa cần
  • MCP cho agent-to-tool, A2A cho agent-to-agent - hai giao thức bổ trợ nhau
  • Security first - luôn audit, least privilege, read-only khi có thể
  • Tham gia ecosystem - contribute MCP servers, tham gia AAIF community
  • Streamable HTTP là transport chuẩn cho production

Thế giới AI đang chuyển từ "mô hình thông minh hơn" sang "mô hình kết nối tốt hơn". MCP chính là giao thức kết nối đó.

Bắt đầu ngay hôm nay

1. Cài Claude Code và thêm MCP server đầu tiên. 2. Khám phá MCP Registry. 3. Thử viết MCP Server riêng cho internal tool của team. 4. Tham gia AAIF community trên GitHub và Discord.