QuotaCheap Playbook
Claude Agent SDK custom tools: in-process MCP server, schemas và handlers
Tìm hiểu claude agent sdk custom tools: in process mcp server, schemas và handlers theo Claude Code docs: Python, TypeScript, custom tools, cost tracking,…
Custom tools docs nói SDK cho phép define functions Claude có thể call qua in-process MCP server; tool gồm name, description, input schema và handler, có thể gọi APIs, databases hoặc domain-specific logic.
Bài Claude Agent SDK Playbook: Custom tools docs nói SDK cho phép define functions Claude có thể call qua in-process MCP server; tool gồm name, description, input schema và handler, có thể gọi APIs, databases hoặc domain-specific logic. Bài viết bám documentation, tập trung production workflow, tools, permissions, cost và observability.
Claude Agent SDK custom tools: in process MCP server, schemas và handlers Custom tools docs nói SDK cho phép define functions Claude có thể call qua in process MCP server; tool gồm name, description, input schema và handler, có thể gọi APIs, databases hoặc domain specific logic.
Điều docs xác nhận Custom tools docs nói SDK cho phép define functions Claude có thể call qua in process MCP server; tool gồm name, description, input schema và handler, có thể gọi APIs, databases hoặc domain specific logic.
SDK khác với dùng Claude Code tương tác trong terminal.
Ở terminal, developer dẫn dắt conversation.
Với SDK, bạn nhúng agent loop vào Python hoặc TypeScript app, truyền options, đọc stream message, cấp tool, cấu hình permissions và quan sát usage.
Vì vậy bài viết phải nói bằng ngôn ngữ production engineering: interface, trust boundary, retry, telemetry, cost, test harness và failure mode.
Khi nào nên dùng Agent SDK Dùng SDK khi agent là một sản phẩm hoặc workflow lặp lại: bug fixing bot, repo reviewer, internal assistant, research worker, code migration helper, support triage tool hoặc automation chạy theo event.
Không cần SDK nếu bạn chỉ muốn hỏi repo vài câu hoặc sửa bug thủ công; Claude Code interactive đủ nhanh và ít overhead hơn.
SDK có giá trị khi bạn cần điều khiển bằng code: truyền prompt theo template, giới hạn tools, chạy trong folder xác định, đọc structured stream, tích hợp với queue, lưu audit log, hoặc expose agent workflow qua UI nội bộ.
Nhưng mỗi quyền bạn cấp cho agent phải có lý do.
Built in tools có thể đọc file, chạy command và edit code; custom tools có thể gọi API của bạn.
Đây là năng lực mạnh, không phải chatbot embed đơn giản.
Prompt mẫu cho agent workflow Prompt này không thay thế permissions, nhưng làm output dễ audit hơn.
Với SDK, output contract quan trọng vì caller thường là app hoặc queue worker, không phải người đọc transcript liên tục.
Runbook triển khai Bước một: làm quickstart nhỏ trong repo sandbox.
Bước hai: xác định tool allowlist.
Agent sửa code cần Read/Edit/Bash có giới hạn; agent research có thể chỉ cần read only.
Bước ba: chuẩn hóa output schema hoặc message parsing.
Bước bốn: thêm telemetry/cost tracking trước khi cho chạy nhiều task.
Bước năm: chạy với fixture repo hoặc branch thử nghiệm.
Không nên bắt đầu bằng production queue xử lý hàng trăm jobs.
Hãy chạy 5 10 job mẫu, xem agent fail như thế nào, rồi mới mở rộng.
Failure mode của agent thường không nằm ở “model không biết code”, mà nằm ở scope mơ hồ, tool quá rộng, verification thiếu, hoặc app không xử lý message/error đúng.
Tool và permission boundary Custom tools cần name, description, input schema và handler rõ.