MCP Là Gì Và Tại Sao Developer Cần Quan Tâm
Nếu bạn đang vibe coding, có lẽ bạn đã gặp tình huống này: bạn nhờ AI agent viết code, nhưng nó không thể truy cập database để xem schema thật, không đọc được Jira tickets để hiểu requirements, không kiểm tra được Slack messages cho context, và không deploy được code lên server.
AI agent thông minh nhưng bị cô lập — nó sống trong sandbox không kết nối với hệ sinh thái tools của bạn. Model Context Protocol (MCP) giải quyết chính xác vấn đề này.
MCP là tiêu chuẩn mở (open standard) do Anthropic phát triển và publish cuối năm 2024, định nghĩa cách AI models kết nối với external tools, data sources, và services. Hãy nghĩ MCP như “USB-C cho AI” — một cổng kết nối universal cho phép mọi AI agent giao tiếp với mọi tool bên ngoài qua giao thức chung.
Kiến Trúc MCP — Hiểu Từ Gốc
Ba thành phần cốt lõi
Kiến trúc MCP gồm ba layers:
MCP Host là AI application (Claude Code, Cursor, hoặc bất kỳ app nào tích hợp MCP). Host là nơi user tương tác và là nơi AI model chạy. Host quản lý connections đến nhiều MCP Servers đồng thời.
MCP Client là protocol layer nằm giữa Host và Server. Client handle communication protocol: request/response, notifications, capability negotiation. Mỗi connection đến một Server được quản lý bởi một Client instance riêng.
MCP Server là lightweight program cung cấp capabilities cụ thể cho AI. Mỗi server expose một hoặc nhiều resources (data sources), tools (functions AI có thể gọi), và prompts (templates cho common workflows). Server có thể là local process hoặc remote service.
Luồng hoạt động thực tế
Khi bạn nói với Claude Code: “Kiểm tra database và tạo API endpoint cho bảng orders,” luồng diễn ra như sau:
Bước 1 — Claude Code (Host) nhận message từ bạn và gửi đến Claude model. Bước 2 — Claude phân tích request và quyết định cần dùng database tool. Bước 3 — Host gửi tool call request qua MCP Client đến Supabase MCP Server. Bước 4 — Supabase MCP Server kết nối database, query schema bảng orders, return kết quả. Bước 5 — Claude nhận schema data, viết API endpoint code phù hợp với schema thật. Bước 6 — Output hiển thị cho bạn — code chính xác, không cần sửa vì dựa trên data thật.
Toàn bộ luồng này transparent với user — bạn chỉ thấy Claude “biết” database schema mà không cần paste vào.
Transport Mechanisms
MCP hỗ trợ hai transport mechanisms. Stdio dành cho local servers chạy trên máy user — communicate qua standard input/output, đơn giản, fast, phù hợp cho development tools. HTTP + SSE (Server-Sent Events) dành cho remote servers — communicate qua HTTP cho requests và SSE cho streaming responses, phù hợp cho cloud services và shared infrastructure.
MCP Servers Quan Trọng Nhất Cho Vibe Coding
Filesystem MCP Server
Cho phép AI agent đọc, viết, và quản lý files trên local system. Nghe đơn giản nhưng đây là nền tảng cho mọi coding task. Capabilities bao gồm read/write files với permission controls, directory listing và search, file watching cho changes, và symlink handling.
Git MCP Server
Kết nối AI agent trực tiếp với Git repository. AI có thể xem history, create branches, commit changes, và thậm chí resolve merge conflicts. Capabilities gồm repository status và log, branch management, commit và diff operations, và stash operations.
Database MCP Servers (PostgreSQL, Supabase, MySQL)
Đây là game-changer cho vibe coding. Thay vì paste schema vào prompt, AI agent trực tiếp query database để hiểu structure, relationships, và existing data patterns.
Ví dụ thực tế: bạn nói “Tạo API endpoint cho search products với filter theo price range, category, và rating.” AI agent sẽ query database schema để biết chính xác column names và types, kiểm tra existing indexes, xem sample data để hiểu data patterns, rồi viết code chính xác cho schema thật — không phải schema tưởng tượng.
Slack MCP Server
Kết nối AI agent với Slack workspace. AI có thể đọc messages, search conversations, và thậm chí post updates. Đặc biệt hữu ích cho context gathering — khi bạn nói “implement feature theo yêu cầu trong Slack channel #product-requests,” AI có thể tự tìm và đọc relevant messages.
Browser MCP Server
Cho phép AI agent tương tác với web browser: navigate URLs, read page content, fill forms, click buttons. Powerful cho testing và web scraping tasks.
Cách MCP Thay Đổi Workflow Vibe Coding
Trước MCP: Context Manual
Workflow cũ đòi hỏi bạn phải copy database schema → paste vào prompt, copy API docs → paste vào prompt, copy error logs → paste vào prompt, mô tả bằng lời infrastructure setup. AI phải làm việc với context bạn cung cấp — thiếu gì thì sai đó.
Sau MCP: Context Automatic
Workflow mới để AI tự lấy context: AI query database trực tiếp cho schema, AI đọc docs từ Notion/Confluence, AI pull error logs từ monitoring service, AI inspect infrastructure config từ cloud provider. Bạn chỉ cần mô tả what — AI tự tìm context cần thiết.
Impact lên code quality
Với MCP, code quality tăng đáng kể vì AI không còn “đoán” context nữa mà dựa trên data thật. Database queries match real schema — không còn typo column names. API integrations dùng correct endpoints và parameters. Error handling cover real error cases (dựa trên production logs). Config values match actual infrastructure.
Xây Dựng Custom MCP Server — Hướng Dẫn Thực Chiến
Khi nào cần custom MCP Server
Bạn cần custom server khi internal tool không có MCP server sẵn (HR system, custom CRM, proprietary API), khi muốn expose specific data cho AI với custom logic, hoặc khi cần combine nhiều data sources thành một unified interface.
Anatomy của MCP Server
Mỗi MCP Server gồm ba primitives. Resources là data endpoints AI có thể read — giống GET endpoints. Ví dụ: resource “db://schema” trả về database schema, resource “jira://ticket/PROJ-123” trả về ticket details. Tools là functions AI có thể execute — giống POST endpoints. Ví dụ: tool “run_query” chạy SQL query, tool “create_ticket” tạo Jira ticket. Prompts là predefined templates cho common workflows. Ví dụ: prompt “code_review” setup context cho code review session.
Ví dụ: Custom MCP Server cho Internal API
# server.py - MCP Server cho internal product API
from mcp.server import Server
from mcp.types import Tool, TextContent
import httpx
server = Server("internal-product-api")
@server.tool()
async def get_product(product_id: str) -> list[TextContent]:
"""Lấy thông tin product từ internal API"""
async with httpx.AsyncClient() as client:
response = await client.get(
f"https://api.internal.company.com/products/{product_id}",
headers={"Authorization": f"Bearer {API_TOKEN}"}
)
return [TextContent(type="text", text=response.text)]
@server.tool()
async def search_products(query: str, category: str = None) -> list[TextContent]:
"""Search products với optional category filter"""
params = {"q": query}
if category:
params["category"] = category
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.internal.company.com/products/search",
params=params,
headers={"Authorization": f"Bearer {API_TOKEN}"}
)
return [TextContent(type="text", text=response.text)]
@server.tool()
async def get_product_analytics(
product_id: str,
period: str = "7d"
) -> list[TextContent]:
"""Lấy analytics data cho product (views, conversions, revenue)"""
async with httpx.AsyncClient() as client:
response = await client.get(
f"https://analytics.internal.company.com/products/{product_id}",
params={"period": period},
headers={"Authorization": f"Bearer {ANALYTICS_TOKEN}"}
)
return [TextContent(type="text", text=response.text)]
Đăng ký MCP Server với AI Agent
Với Claude Code, thêm vào file .mcp.json:
{
"mcpServers": {
"internal-products": {
"command": "python",
"args": ["server.py"],
"env": {
"API_TOKEN": "your-api-token",
"ANALYTICS_TOKEN": "your-analytics-token"
}
}
}
}
Sau đó, khi bạn nói “Xem analytics product X và đề xuất cách tăng conversion,” Claude tự gọi MCP server để lấy data thật và phân tích trên data thật.
MCP Ecosystem Năm 2026 — Landscape Hiện Tại
Official MCP Servers
Anthropic và community đã phát triển MCP servers cho hầu hết services phổ biến. Về databases có PostgreSQL, MySQL, SQLite, Supabase, MongoDB. Về cloud services có AWS, Google Cloud, Cloudflare. Về development tools có Git, GitHub, GitLab, Docker. Về communication có Slack, Discord, Email. Về project management có Jira, Linear, Notion, Asana. Và về monitoring có Sentry, Datadog, PagerDuty.
Community-Built Servers
Open-source community đang bùng nổ với custom MCP servers cho mọi thứ: Shopify cho e-commerce data, Stripe cho payment analytics, Twilio cho SMS/voice, OpenAI cho multi-model workflows, và hàng trăm servers khác trên mcp.so registry.
Tương Lai: MCP + OpenSpace + Vibe Coding
Sự kết hợp giữa MCP và OpenSpace (self-evolving skill engine) tạo ra một vision mạnh mẽ cho tương lai vibe coding.
Hiện tại: AI agent + MCP = agent có thể access external tools. Bạn vẫn cần mô tả workflow mỗi lần.
Tương lai gần: AI agent + MCP + OpenSpace = agent có thể access external tools VÀ tự học workflow. Lần đầu bạn mô tả “deploy to production,” agent thực hiện qua MCP (connect Git, run tests, deploy to Vercel). OpenSpace capture workflow thành skill. Lần sau bạn chỉ cần nói “deploy” — agent đã biết workflow cụ thể của project bạn.
Đây là convergence point: MCP cung cấp connectivity, OpenSpace cung cấp memory, và AI model cung cấp intelligence. Kết hợp cả ba tạo ra AI agent thực sự autonomous — hiểu context từ tools thật, nhớ workflows đã thành công, và ngày càng hiệu quả theo thời gian.
Kết Luận
MCP không chỉ là protocol kỹ thuật — nó là infrastructure layer cho thế hệ tiếp theo của vibe coding. Khi AI agent có thể kết nối trực tiếp với mọi tool trong ecosystem, ranh giới giữa “mô tả task” và “hoàn thành task” gần như biến mất.
Cho developer: hãy bắt đầu tích hợp MCP servers vào workflow vibe coding. Mỗi server bạn kết nối mở rộng khả năng của AI agent. Cho team leads: đầu tư xây custom MCP servers cho internal tools. ROI cực kỳ cao — mỗi team member đều hưởng lợi từ mỗi server. Cho startup founders: MCP ecosystem đang tạo cơ hội cho specialized MCP server as a service — một niche mới đáng khám phá.
Tương lai của vibe coding không chỉ là AI viết code tốt hơn. Nó là AI tích hợp sâu vào toàn bộ development lifecycle — và MCP chính là cầu nối biến vision đó thành hiện thực.
Leave a Reply
You must be logged in to post a comment.