Chapter 4 — Tool Use & MCP
Câu hỏi trung tâm: LLM gọi API bên ngoài bằng cơ chế gì? MCP server là gì và tại sao nó đang thành chuẩn?
🔒 Chapter chưa mở
Nội dung chi tiết sẽ được unlock dần. Dưới đây là outline.
Outline
4.1 — Function/Tool Calling: model quyết định, code bạn chạy
- LLM không thật sự "gọi" API — nó chỉ output JSON mô tả intent
- Luồng hoạt động: user → model → tool call → your code → model → response
- So sánh syntax: OpenAI tools vs Anthropic tool_use
- Lab: build tool đầu tiên — tra thời tiết qua API
4.2 — Thiết kế tool tốt
- Tool description là prompt cho model — viết rõ hơn = gọi đúng hơn
- Parameter schema: type, description, enum, required
- Bao nhiêu tool là quá nhiều? Khi nào model bị "confused"
- Error handling: tool fail thì conversation xử lý thế nào
4.3 — MCP (Model Context Protocol)
- MCP giải quyết vấn đề gì: "mỗi app một cách kết nối" → chuẩn chung
- Architecture: Host → Client → Server → Tools/Resources/Prompts
- Transport: stdio vs SSE — khi nào dùng cái nào
- Lab: build MCP server đầu tiên — cắm vào Claude Desktop
4.4 — MCP trong thực tế
- Dùng MCP server có sẵn (filesystem, GitHub, Postgres...)
- Kết hợp nhiều MCP server — agent dùng nhiều tool
- Security: tool approval, sandboxing
- MCP vs custom API integration — trade-off
Checkpoint
- Giải thích luồng tool calling bằng sơ đồ — từ user message đến final response
- MCP khác gì function calling thông thường?
- Khi nào nên build MCP server, khi nào dùng function calling trực tiếp?
Tiếp theo: Chapter 5 — Workflow Patterns →