MCP Hosts
Khái niệm cơ bản
Phần tiêu đề “Khái niệm cơ bản”Tưởng tượng Host như “ngôi nhà” của AI…
- AI (LLM) là người ở trong nhà
- MCP Servers là các dịch vụ bên ngoài (điện, nước, internet…)
- Host là ngôi nhà kết nối tất cả lại
Host = Ứng dụng nơi user tương tác với AI, đồng thời quản lý kết nối đến MCP Servers.
Nhiệm vụ của Host
Phần tiêu đề “Nhiệm vụ của Host”1. Discovery & Lifecycle Management
Phần tiêu đề “1. Discovery & Lifecycle Management”- Đọc config file để biết servers nào khả dụng
- Khởi động/dừng server processes
- Reconnect khi server crash
2. Permission Management
Phần tiêu đề “2. Permission Management”- Hỏi user: “Claude muốn đọc file X. Cho phép?”
- Quản lý consent cho từng server/tool
3. Context Injection
Phần tiêu đề “3. Context Injection”- Lấy data từ servers
- Inject vào context window của LLM
- Quản lý token budget
4. Tool Orchestration
Phần tiêu đề “4. Tool Orchestration”- Nhận tool calls từ LLM
- Route đến đúng server
- Trả kết quả về LLM
Các Host phổ biến
Phần tiêu đề “Các Host phổ biến”| Host | Status | Đặc điểm |
|---|---|---|
| Claude Desktop | ✅ Production | Host đầu tiên, config bằng JSON |
| Zed Editor | ✅ Production | IDE với MCP tích hợp |
| Cursor | 🔄 Beta | Popular AI code editor |
| Gemini CLI | 🔄 Beta | Google’s AI in terminal |
| Continue.dev | ✅ Production | VS Code extension |
| BeeAI (IBM) | ✅ Production | Enterprise solution |
Claude Desktop Config
Phần tiêu đề “Claude Desktop Config”File: ~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/docs"] }, "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres"], "env": { "DATABASE_URL": "postgresql://user:pass@localhost/mydb" } }, "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN": "ghp_xxxx" } } }}Zed Editor Config
Phần tiêu đề “Zed Editor Config”File: ~/.config/zed/settings.json
{ "context_servers": { "filesystem": { "command": { "path": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"] } } }}Host Responsibilities Flow
Phần tiêu đề “Host Responsibilities Flow”User Query │ ▼┌──────────────────────────────────────────────┐│ HOST ││ ││ 1. Check available servers ││ 2. Inject server capabilities into prompt ││ 3. Send to LLM ││ ││ ┌─────────────────────────────────┐ ││ │ LLM │ ││ │ "I want to call tool X..." │ ││ └─────────────────────────────────┘ ││ ││ 4. Parse tool call request ││ 5. Ask user permission (if needed) ││ 6. Route to correct server ││ 7. Get result ││ 8. Inject result, continue conversation │└──────────────────────────────────────────────┘ │ ▼MCP Servers (filesystem, postgres, ...)Bài tập thực hành
Phần tiêu đề “Bài tập thực hành”Mục tiêu
Phần tiêu đề “Mục tiêu”Thêm 2 servers vào Claude Desktop.
Bước thực hiện
Phần tiêu đề “Bước thực hiện”- Mở config file Claude Desktop
- Thêm Filesystem server (đọc folder dự án)
- Thêm Memory server (để Claude nhớ thông tin)
{ "mcpServers": { "project": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/project"] }, "memory": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"] } }}- Restart Claude
- Test:
- “Nhớ tên tôi là Phúc”
- “Tên tôi là gì?”
- “Đọc file README trong project”
Tóm tắt
Phần tiêu đề “Tóm tắt”| Khái niệm | Ý nghĩa |
|---|---|
| Host | App quản lý MCP connections |
| Config file | JSON định nghĩa servers |
| Permission | User approve mỗi action |
| Orchestration | Route tool calls đến servers |
Bài tiếp theo: MCP Clients - Giao thức kết nối.