注册并分享邀请链接,可获得视频播放与邀请奖励。

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
加入 May 2026
258 正在关注    262 粉丝
# Practical ways to use the Claude Agent SDK 🔧 Define your internal APIs, databases, and domain logic with `@tool` and let Claude call them. Custom Tools lets you define your own functions as in-process MCP servers using the `@tool` decorator, making them callable by Claude during conversations. 📌 Title: Providing Custom Tools to Claude 🔗 URL: 🧩 Overview Define tools with `@tool` (Python) / `tool()` (TypeScript) specifying name, description, schema, and handler. Wrap with `create_sdk_mcp_server` and pass to `mcp_servers`. Annotate side-effect-free tools with `readOnlyHint: true` for parallel execution. 🛠 How to use it Define tools with `@tool` (Python) / `tool()` (TypeScript) specifying name, description, schema, and handler. Wrap with `create_sdk_mcp_server` and pass to `mcp_servers={"weather": server}`. Tools are exposed to Claude as `mcp__weather__get_temperature`. 🏗 Practical usage - Define internal APIs (customer info, inventory, order status) as `@tool` and build agents that respond to natural language queries. - Add `readOnlyHint: true` to read-only tools for parallel execution and lower latency. - Catch exceptions in handlers and return `is_error=True` so the agent loop continues and Claude retries or tries alternatives. - Return chart images via `image` blocks (base64) for Claude to analyze visually. 💡 Use cases 🏢 Natural language access to internal APIs 📊 Chart generation + image analysis pipeline 🔄 Fault-tolerant autonomous retry ⚠️ Watch out Uncaught exceptions in handlers crash the entire `query()`. Always handle errors. Use `tools: ["Read","Grep"]` to restrict which built-in tools are available. #ClaudeAgentSDK# #AI#
显示更多