Bạn từng thắc mắc Claude làm sao biết MCP server có những tool gì mà gọi đúng? Câu trả lời nằm trong Discovery Protocol, layer hầu hết developer ít chú ý nhưng quyết định 80% trải nghiệm tích hợp tool. Theo MCP Cheat Sheet 2026 (2026), mọi kết nối MCP đều bắt đầu bằng handshake JSON-RPC 2.0 với capability negotiation. Effloow (2026) ghi nhận 97 triệu lượt SDK download mỗi tháng và 10.000+ public server, đa phần dựa vào Discovery Protocol để Claude/ChatGPT/Gemini tự nhận biết.
Key Takeaways - Discovery Protocol dùng JSON-RPC 2.0 cho handshake, gồm
initialize→initialized→tools/list(Get Knit, 2026). - 2026 chuẩn.well-known/mcp.jsoncho phép server expose metadata public, bot crawler tự index (Ekamoira, 2026). - Mỗi tool có JSON Schema input/output rõ ràng, Claude validate trước khi gọi giảm 40% lỗi runtime. - Spec MCP phiên bản tiếp theo dự kiến June 2026 thêm tool annotations và streaming responses.
Discovery Protocol Là Gì Trong MCP?
Discovery Protocol là layer cho phép MCP client (Claude, ChatGPT, Cursor) tự khám phá MCP server có những "tool", "resource", "prompt" gì mà không cần config thủ công. MCP Cat (2026) giải thích chi tiết: client gửi JSON-RPC initialize, server đáp lại danh sách capability, client tiếp tục tools/list, resources/list, prompts/list để biết đầy đủ surface area.
Pattern này giống USB plug-and-play. Khi cắm USB vào máy, OS tự đọc descriptor (vendor ID, product ID, capability), không cần driver riêng. MCP Discovery cũng vậy: cắm server vào Claude, Claude tự đọc descriptor, không cần Claude biết trước server đó là gì.
Vantage Point (2026) gọi MCP là "USB-C cho AI", Discovery Protocol chính là USB descriptor layer. Sự đơn giản này cho phép ecosystem phát triển: 10.000+ server hiện có vì cắm vào client nào cũng chạy.
Tham khảo thêm: - MCP Là Gì? Tổng Quan Model Context Protocol - Build MCP Server TypeScript Step-By-Step
Capability Negotiation Diễn Ra Như Thế Nào?
Capability negotiation là bước hai sau initialize, nơi client và server agree về feature nào hỗ trợ ở cả hai phía. Model Context Protocol Docs (2026) định nghĩa 3 capability chính: tools (chạy hành động), resources (đọc dữ liệu), prompts (template prompt re-use).
Ví dụ initialize request từ Claude:
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-03-26",
"capabilities": {
"roots": { "listChanged": true },
"sampling": {}
},
"clientInfo": { "name": "claude-desktop", "version": "0.7.5" }
}
}
Server đáp lại:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-03-26",
"capabilities": {
"tools": { "listChanged": true },
"resources": { "subscribe": true, "listChanged": true },
"prompts": { "listChanged": true }
},
"serverInfo": { "name": "github-mcp", "version": "1.4.0" }
}
}
Sau khi agree, client biết server hỗ trợ tools (có thể subscribe khi list thay đổi), resources (có thể subscribe theo dõi resource thay đổi), prompts (có template). DEV Community (2026) gọi pattern này là "feature negotiation", giống TLS handshake.
Tham khảo thêm: - MCP Authentication Patterns - MCP Rate Limiting Best Practices
Tool Discovery Trả Về Schema Như Thế Nào?
Mỗi tool được mô tả bằng JSON Schema, gồm name, description, inputSchema, và optional outputSchema. Pattern này giúp Claude validate input trước khi call, giảm 40% lỗi runtime so với tool không có schema.
Ví dụ response từ tools/list:
{
"tools": [
{
"name": "create_issue",
"description": "Tạo issue mới trên GitHub repository",
"inputSchema": {
"type": "object",
"properties": {
"owner": { "type": "string" },
"repo": { "type": "string" },
"title": { "type": "string" },
"body": { "type": "string" },
"labels": { "type": "array", "items": { "type": "string" } }
},
"required": ["owner", "repo", "title"]
}
}
]
}
Data Everything (2026) khuyến nghị description nên chi tiết hơn name vì Claude dùng description để quyết định tool nào hợp với task. Description "Tạo issue trên GitHub khi user muốn báo bug" tốt hơn "Create GitHub issue".
Tham khảo thêm: - Build MCP Server TypeScript Step-By-Step - MCP Server Cho Notion Database
.well-known/mcp.json Là Tiêu Chuẩn Mới 2026?
Đúng, từ tháng 1/2026 nhiều MCP server adopt .well-known/mcp.json cho public discovery, giống .well-known/security.txt. Ekamoira (2026) ghi nhận pattern này lan rộng sau MCP Dev Summit North America 2026.
Cấu trúc .well-known/mcp.json mẫu:
{
"name": "Acme HR Server",
"description": "Truy cập HR data và onboarding workflow",
"version": "1.2.0",
"transports": ["sse", "websocket"],
"endpoints": {
"sse": "https://api.acme.com/mcp/sse",
"websocket": "wss://api.acme.com/mcp/ws"
},
"auth": {
"type": "oauth2.1",
"discovery": "https://api.acme.com/.well-known/oauth-authorization-server"
},
"publisher": "Acme Inc.",
"category": "hr"
}
Crawler như mcp.so, mcpmanager.ai tự crawl .well-known/mcp.json của domain để index server vào registry public. Effloow (2026) cho biết 80% top server đã expose well-known endpoint, giúp Claude Desktop từ Q2/2026 có khả năng "auto-discover" server từ domain.
Tham khảo thêm: - MCP Authentication Patterns - Top MCP Servers Đáng Cài 2026
Tool Annotations Mới Trong Spec 2026 Là Gì?
Tool annotations là metadata bổ sung cho mỗi tool, giúp client phân loại và áp dụng policy tự động. Get Knit (2026) liệt kê các annotation đang được đề xuất: read-only, idempotent, destructive, requires-confirmation, cost-tier.
Ví dụ tool có annotations:
{
"name": "delete_user",
"description": "Xóa user khỏi hệ thống",
"annotations": {
"destructive": true,
"requires-confirmation": true,
"audit-required": true
},
"inputSchema": { /* ... */ }
}
Khi Claude thấy destructive: true, nó tự động hỏi user "Bạn chắc muốn xóa user X?" trước khi gọi. Nếu audit-required: true, client log toàn bộ request/response vào audit trail. Pattern này giảm 71% incident "Claude vô tình làm thay đổi không thể undo" trong test enterprise của Pento.
Pento (2026) cho biết tool annotations dự kiến chính thức trong spec MCP June 2026. Hiện đã có draft trong GitHub spec repo, nhiều server đã adopt sớm.
Tham khảo thêm: - MCP Security Prevention - MCP Server Logging Va Observability
Streaming Responses Trong MCP Discovery Là Gì?
Streaming responses cho phép server trả về kết quả từng phần thay vì chờ toàn bộ rồi mới trả. Model Context Protocol Blog (2026) giải thích pattern này quan trọng cho tool query lượng data lớn (CRM 50.000 contact, log 1 triệu dòng).
Ví dụ tool search_logs không streaming: client chờ 30 giây mới nhận 5MB JSON. Streaming: client nhận token đầu sau 800ms, sau đó từng chunk 100KB cho đến khi xong. UX khác biệt rõ rệt.
Implementation streaming dùng SSE hoặc HTTP chunked transfer. Code TypeScript mẫu:
server.tool("search_logs", { /* schema */ }, async function* ({ query }) {
for await (const chunk of streamLogs(query)) {
yield { content: [{ type: "text", text: JSON.stringify(chunk) }] };
}
});
DEV Community (2026) cho biết streaming dự kiến chính thức trong spec June 2026. Hiện đã có proposal SEP-014 trong GitHub spec repo, được implement trong @modelcontextprotocol/sdk v1.5+.
Tham khảo thêm: - MCP Caching Strategy - Top MCP Servers 2026 Review
FAQ: Câu Hỏi Thường Gặp Về MCP Discovery
1. Discovery có khác nhau giữa stdio và HTTP transport không? Logic giống nhau (initialize → capabilities → tools/list), chỉ transport khác. Stdio dùng cho local server (Claude Desktop spawn process), HTTP/SSE cho remote server. Theo MCP Cheat Sheet (2026), 60% server hiện hỗ trợ cả hai.
2. Có cách nào cache discovery để tránh handshake mỗi request không?
Có. Client cache tools/list trong session. Server gửi tools/listChanged notification khi danh sách thay đổi, client invalidate cache. Theo MCP Cat (2026), pattern này tiết kiệm 80% RTT trong session dài.
3. Claude Desktop tự động discover MCP server từ domain không?
Từ Q2/2026 có hỗ trợ. User nhập "Connect to acme.com", Claude Desktop tự fetch .well-known/mcp.json, discovery, oauth, thêm vào sidebar. Pattern này còn beta tháng 5/2026.
4. Multiple version protocol có vấn đề gì không?
Capability negotiation handle. Client gửi protocolVersion: "2025-03-26", server có thể đáp version cũ hơn nếu chưa update, client downgrade gracefully. Theo Anthropic News (2026), backward compat đảm bảo 24 tháng.
5. Tool có thể đổi schema runtime không?
Có, qua tools/listChanged notification. Server thêm/xóa tool, gửi notification, client refresh tools/list. Pattern này cho phép server có "dynamic tool" như "expose REST endpoint thành MCP tool tự động".
Kết Luận: Discovery Protocol Là Trái Tim MCP
Hiểu Discovery Protocol giúp bạn build MCP server tốt hơn: đầu tư schema, tận dụng annotation, plan streaming khi data lớn. Pattern handshake JSON-RPC là chuẩn vững cho cả ecosystem 10.000+ server hiện tại và 25.000+ dự kiến cuối 2027.
Bước tiếp theo nên làm:
- Đọc spec chính thức tại modelcontextprotocol.io
- Inspect handshake bằng MCP Inspector tool: npx @modelcontextprotocol/inspector
- Implement .well-known/mcp.json cho server public của bạn
- Adopt tool annotations từ draft spec để chuẩn bị MCP June 2026
- Plan migration sang streaming khi tool query data >1MB
Tham khảo thêm: - MCP Là Gì? Tổng Quan 2026 - MCP Authentication Patterns Đầy Đủ - MCP Rate Limiting Best Practices - Top MCP Servers Đáng Cài 2026