opencode-skills-collection 1.0.186 → 1.0.187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/.antigravity-install-manifest.json +5 -1
- package/bundled-skills/3d-web-experience/SKILL.md +152 -37
- package/bundled-skills/agent-evaluation/SKILL.md +1088 -26
- package/bundled-skills/agent-memory-systems/SKILL.md +1037 -25
- package/bundled-skills/agent-tool-builder/SKILL.md +668 -16
- package/bundled-skills/ai-agents-architect/SKILL.md +271 -31
- package/bundled-skills/ai-product/SKILL.md +716 -26
- package/bundled-skills/ai-wrapper-product/SKILL.md +450 -44
- package/bundled-skills/algolia-search/SKILL.md +867 -15
- package/bundled-skills/autonomous-agents/SKILL.md +1033 -26
- package/bundled-skills/aws-serverless/SKILL.md +1046 -35
- package/bundled-skills/azure-functions/SKILL.md +1318 -19
- package/bundled-skills/browser-automation/SKILL.md +1065 -28
- package/bundled-skills/browser-extension-builder/SKILL.md +159 -32
- package/bundled-skills/bullmq-specialist/SKILL.md +347 -16
- package/bundled-skills/clerk-auth/SKILL.md +796 -15
- package/bundled-skills/computer-use-agents/SKILL.md +1870 -28
- package/bundled-skills/context-window-management/SKILL.md +271 -18
- package/bundled-skills/conversation-memory/SKILL.md +453 -24
- package/bundled-skills/crewai/SKILL.md +252 -46
- package/bundled-skills/discord-bot-architect/SKILL.md +1207 -34
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/users/bundles.md +1 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/email-systems/SKILL.md +646 -26
- package/bundled-skills/faf-expert/SKILL.md +221 -0
- package/bundled-skills/faf-wizard/SKILL.md +252 -0
- package/bundled-skills/file-uploads/SKILL.md +212 -11
- package/bundled-skills/firebase/SKILL.md +646 -16
- package/bundled-skills/gcp-cloud-run/SKILL.md +1117 -32
- package/bundled-skills/graphql/SKILL.md +1026 -27
- package/bundled-skills/hubspot-integration/SKILL.md +804 -19
- package/bundled-skills/idea-darwin/SKILL.md +120 -0
- package/bundled-skills/inngest/SKILL.md +431 -16
- package/bundled-skills/interactive-portfolio/SKILL.md +342 -44
- package/bundled-skills/langfuse/SKILL.md +296 -41
- package/bundled-skills/langgraph/SKILL.md +259 -50
- package/bundled-skills/micro-saas-launcher/SKILL.md +343 -44
- package/bundled-skills/neon-postgres/SKILL.md +572 -15
- package/bundled-skills/nextjs-supabase-auth/SKILL.md +269 -21
- package/bundled-skills/notion-template-business/SKILL.md +371 -44
- package/bundled-skills/personal-tool-builder/SKILL.md +537 -44
- package/bundled-skills/plaid-fintech/SKILL.md +825 -19
- package/bundled-skills/prompt-caching/SKILL.md +438 -25
- package/bundled-skills/rag-engineer/SKILL.md +271 -29
- package/bundled-skills/salesforce-development/SKILL.md +912 -19
- package/bundled-skills/satori/SKILL.md +54 -0
- package/bundled-skills/scroll-experience/SKILL.md +381 -44
- package/bundled-skills/segment-cdp/SKILL.md +817 -19
- package/bundled-skills/shopify-apps/SKILL.md +1475 -19
- package/bundled-skills/slack-bot-builder/SKILL.md +1162 -28
- package/bundled-skills/telegram-bot-builder/SKILL.md +152 -37
- package/bundled-skills/telegram-mini-app/SKILL.md +445 -44
- package/bundled-skills/trigger-dev/SKILL.md +916 -27
- package/bundled-skills/twilio-communications/SKILL.md +1310 -28
- package/bundled-skills/upstash-qstash/SKILL.md +898 -27
- package/bundled-skills/vercel-deployment/SKILL.md +637 -39
- package/bundled-skills/viral-generator-builder/SKILL.md +132 -37
- package/bundled-skills/voice-agents/SKILL.md +937 -27
- package/bundled-skills/voice-ai-development/SKILL.md +375 -46
- package/bundled-skills/workflow-automation/SKILL.md +982 -29
- package/bundled-skills/zapier-make-patterns/SKILL.md +772 -27
- package/package.json +1 -1
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-tool-builder
|
|
3
|
-
description:
|
|
3
|
+
description: Tools are how AI agents interact with the world. A well-designed
|
|
4
|
+
tool is the difference between an agent that works and one that hallucinates,
|
|
5
|
+
fails silently, or costs 10x more tokens than necessary. This skill covers
|
|
6
|
+
tool design from schema to error handling.
|
|
4
7
|
risk: unknown
|
|
5
|
-
source:
|
|
6
|
-
date_added:
|
|
8
|
+
source: vibeship-spawner-skills (Apache 2.0)
|
|
9
|
+
date_added: 2026-02-27
|
|
7
10
|
---
|
|
8
11
|
|
|
9
12
|
# Agent Tool Builder
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
in the design, not the implementation.
|
|
14
|
+
Tools are how AI agents interact with the world. A well-designed tool is the
|
|
15
|
+
difference between an agent that works and one that hallucinates, fails
|
|
16
|
+
silently, or costs 10x more tokens than necessary.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
This skill covers tool design from schema to error handling. JSON Schema
|
|
19
|
+
best practices, description writing that actually helps the LLM, validation,
|
|
20
|
+
and the emerging MCP standard that's becoming the lingua franca for AI tools.
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
Key insight: Tool descriptions are more important than tool implementations.
|
|
23
|
+
The LLM never sees your code - it only sees the schema and description.
|
|
24
|
+
|
|
25
|
+
## Principles
|
|
26
|
+
|
|
27
|
+
- Description quality > implementation quality for LLM accuracy
|
|
28
|
+
- Aim for fewer than 20 tools - more causes confusion
|
|
29
|
+
- Every tool needs explicit error handling - silent failures poison agents
|
|
30
|
+
- Return strings, not objects - LLMs process text
|
|
31
|
+
- Validation gates before execution - reject, fix, or escalate, never silent fail
|
|
32
|
+
- Test tools with the LLM, not just unit tests
|
|
21
33
|
|
|
22
34
|
## Capabilities
|
|
23
35
|
|
|
@@ -28,31 +40,671 @@ You push for explicit error hand
|
|
|
28
40
|
- tool-validation
|
|
29
41
|
- tool-error-handling
|
|
30
42
|
|
|
43
|
+
## Scope
|
|
44
|
+
|
|
45
|
+
- multi-agent-coordination → multi-agent-orchestration
|
|
46
|
+
- agent-memory → agent-memory-systems
|
|
47
|
+
- api-design → api-designer
|
|
48
|
+
- llm-prompting → prompt-engineering
|
|
49
|
+
|
|
50
|
+
## Tooling
|
|
51
|
+
|
|
52
|
+
### Standards
|
|
53
|
+
|
|
54
|
+
- JSON Schema - When: All tool definitions Note: The universal format for tool schemas
|
|
55
|
+
- MCP (Model Context Protocol) - When: Building reusable, cross-platform tools Note: Anthropic's open standard, widely adopted
|
|
56
|
+
|
|
57
|
+
### Frameworks
|
|
58
|
+
|
|
59
|
+
- Anthropic SDK - When: Claude-based agents Note: Beta tool runner handles most complexity
|
|
60
|
+
- OpenAI Functions - When: OpenAI-based agents Note: Use strict mode for guaranteed schema compliance
|
|
61
|
+
- Vercel AI SDK - When: Multi-provider tool handling Note: Abstracts differences between providers
|
|
62
|
+
- LangChain Tools - When: LangChain-based agents Note: Converts MCP tools to LangChain format
|
|
63
|
+
|
|
31
64
|
## Patterns
|
|
32
65
|
|
|
33
66
|
### Tool Schema Design
|
|
34
67
|
|
|
35
68
|
Creating clear, unambiguous JSON Schema for tools
|
|
36
69
|
|
|
70
|
+
**When to use**: Defining any new tool for an agent
|
|
71
|
+
|
|
72
|
+
# TOOL SCHEMA BEST PRACTICES:
|
|
73
|
+
|
|
74
|
+
## 1. Detailed Descriptions (Most Important)
|
|
75
|
+
"""
|
|
76
|
+
BAD - Too vague:
|
|
77
|
+
{
|
|
78
|
+
"name": "get_stock_price",
|
|
79
|
+
"description": "Gets stock price",
|
|
80
|
+
"input_schema": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"properties": {
|
|
83
|
+
"ticker": {"type": "string"}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
GOOD - Comprehensive:
|
|
89
|
+
{
|
|
90
|
+
"name": "get_stock_price",
|
|
91
|
+
"description": "Retrieves the current stock price for a given ticker
|
|
92
|
+
symbol. The ticker symbol must be a valid symbol for a publicly
|
|
93
|
+
traded company on a major US stock exchange like NYSE or NASDAQ.
|
|
94
|
+
Returns the latest trade price in USD. Use when the user asks
|
|
95
|
+
about current or recent stock prices. Does NOT provide historical
|
|
96
|
+
data, company info, or predictions.",
|
|
97
|
+
"input_schema": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"properties": {
|
|
100
|
+
"ticker": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"required": ["ticker"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
## 2. Parameter Descriptions
|
|
111
|
+
"""
|
|
112
|
+
Every parameter needs:
|
|
113
|
+
- What it is
|
|
114
|
+
- Format expected
|
|
115
|
+
- Example value
|
|
116
|
+
- Edge cases/limitations
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
"location": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"description": "City and state/country. Format: 'City, State' for US
|
|
122
|
+
(e.g., 'San Francisco, CA') or 'City, Country' for international
|
|
123
|
+
(e.g., 'Tokyo, Japan'). Do not use ZIP codes or coordinates."
|
|
124
|
+
},
|
|
125
|
+
"unit": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"enum": ["celsius", "fahrenheit"],
|
|
128
|
+
"description": "Temperature unit. Defaults to user's locale if not
|
|
129
|
+
specified. Use 'fahrenheit' for US users, 'celsius' for others."
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
## 3. Use Enums When Possible
|
|
135
|
+
"""
|
|
136
|
+
Enums constrain the LLM to valid values:
|
|
137
|
+
|
|
138
|
+
"priority": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"enum": ["low", "medium", "high", "critical"],
|
|
141
|
+
"description": "Task priority level"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
"action": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"enum": ["create", "read", "update", "delete"],
|
|
147
|
+
"description": "The CRUD operation to perform"
|
|
148
|
+
}
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
## 4. Required vs Optional
|
|
152
|
+
"""
|
|
153
|
+
Be explicit about what's required:
|
|
154
|
+
|
|
155
|
+
{
|
|
156
|
+
"type": "object",
|
|
157
|
+
"properties": {
|
|
158
|
+
"query": {...}, // Required
|
|
159
|
+
"limit": {...}, // Optional with default
|
|
160
|
+
"offset": {...} // Optional
|
|
161
|
+
},
|
|
162
|
+
"required": ["query"],
|
|
163
|
+
"additionalProperties": false // Strict mode
|
|
164
|
+
}
|
|
165
|
+
"""
|
|
166
|
+
|
|
37
167
|
### Tool with Input Examples
|
|
38
168
|
|
|
39
169
|
Using examples to guide LLM tool usage
|
|
40
170
|
|
|
171
|
+
**When to use**: Complex tools with nested objects or format-sensitive inputs
|
|
172
|
+
|
|
173
|
+
# TOOL USE EXAMPLES (Anthropic Beta Feature):
|
|
174
|
+
|
|
175
|
+
"""
|
|
176
|
+
Examples show Claude concrete patterns that schemas can't express.
|
|
177
|
+
Improves accuracy from 72% to 90% on complex operations.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
{
|
|
181
|
+
"name": "create_calendar_event",
|
|
182
|
+
"description": "Creates a calendar event with optional attendees and reminders",
|
|
183
|
+
"input_schema": {
|
|
184
|
+
"type": "object",
|
|
185
|
+
"properties": {
|
|
186
|
+
"title": {"type": "string", "description": "Event title"},
|
|
187
|
+
"start_time": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "ISO 8601 datetime, e.g. 2024-03-15T14:00:00Z"
|
|
190
|
+
},
|
|
191
|
+
"duration_minutes": {"type": "integer", "description": "Event duration"},
|
|
192
|
+
"attendees": {
|
|
193
|
+
"type": "array",
|
|
194
|
+
"items": {"type": "string"},
|
|
195
|
+
"description": "Email addresses of attendees"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"required": ["title", "start_time", "duration_minutes"]
|
|
199
|
+
},
|
|
200
|
+
"input_examples": [
|
|
201
|
+
{
|
|
202
|
+
"title": "Team Standup",
|
|
203
|
+
"start_time": "2024-03-15T09:00:00Z",
|
|
204
|
+
"duration_minutes": 30,
|
|
205
|
+
"attendees": ["alice@company.com", "bob@company.com"]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"title": "Quick Chat",
|
|
209
|
+
"start_time": "2024-03-15T14:00:00Z",
|
|
210
|
+
"duration_minutes": 15
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"title": "Project Review",
|
|
214
|
+
"start_time": "2024-03-15T16:00:00-05:00",
|
|
215
|
+
"duration_minutes": 60,
|
|
216
|
+
"attendees": ["team@company.com"]
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
# EXAMPLE DESIGN PRINCIPLES:
|
|
222
|
+
# - Use realistic data, not placeholders
|
|
223
|
+
# - Show minimal, partial, and full specification patterns
|
|
224
|
+
# - Keep concise: 1-5 examples per tool
|
|
225
|
+
# - Focus on ambiguous cases
|
|
226
|
+
|
|
41
227
|
### Tool Error Handling
|
|
42
228
|
|
|
43
229
|
Returning errors that help the LLM recover
|
|
44
230
|
|
|
45
|
-
|
|
231
|
+
**When to use**: Any tool that can fail
|
|
232
|
+
|
|
233
|
+
# ERROR HANDLING BEST PRACTICES:
|
|
234
|
+
|
|
235
|
+
## Return Informative Errors
|
|
236
|
+
"""
|
|
237
|
+
BAD:
|
|
238
|
+
{"error": "Failed"}
|
|
239
|
+
{"error": true}
|
|
240
|
+
|
|
241
|
+
GOOD:
|
|
242
|
+
{
|
|
243
|
+
"error": true,
|
|
244
|
+
"error_type": "not_found",
|
|
245
|
+
"message": "Location 'Atlantis' not found in weather database.
|
|
246
|
+
Please provide a real city name like 'San Francisco, CA'.",
|
|
247
|
+
"suggestions": ["San Francisco, CA", "Los Angeles, CA"]
|
|
248
|
+
}
|
|
249
|
+
"""
|
|
250
|
+
|
|
251
|
+
## Anthropic Tool Result with Error
|
|
252
|
+
"""
|
|
253
|
+
{
|
|
254
|
+
"type": "tool_result",
|
|
255
|
+
"tool_use_id": "toolu_01A09q90qw90lq917835lq9",
|
|
256
|
+
"content": "Error: Location 'Atlantis' not found in weather database.
|
|
257
|
+
Please provide a real city name like 'San Francisco, CA'.",
|
|
258
|
+
"is_error": true
|
|
259
|
+
}
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
## Error Categories to Handle
|
|
263
|
+
"""
|
|
264
|
+
1. Input Validation Errors
|
|
265
|
+
- Missing required parameters
|
|
266
|
+
- Invalid format
|
|
267
|
+
- Out of range values
|
|
268
|
+
|
|
269
|
+
2. External Service Errors
|
|
270
|
+
- API unavailable
|
|
271
|
+
- Rate limited
|
|
272
|
+
- Timeout
|
|
273
|
+
|
|
274
|
+
3. Business Logic Errors
|
|
275
|
+
- Resource not found
|
|
276
|
+
- Permission denied
|
|
277
|
+
- Conflict/duplicate
|
|
278
|
+
|
|
279
|
+
4. Internal Errors
|
|
280
|
+
- Unexpected exceptions
|
|
281
|
+
- Data corruption
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
## Implementation Pattern
|
|
285
|
+
"""
|
|
286
|
+
from dataclasses import dataclass
|
|
287
|
+
from typing import Union
|
|
288
|
+
|
|
289
|
+
@dataclass
|
|
290
|
+
class ToolResult:
|
|
291
|
+
success: bool
|
|
292
|
+
content: str
|
|
293
|
+
error_type: str = None
|
|
294
|
+
suggestions: list[str] = None
|
|
295
|
+
|
|
296
|
+
def to_response(self) -> dict:
|
|
297
|
+
if self.success:
|
|
298
|
+
return {"content": self.content}
|
|
299
|
+
return {
|
|
300
|
+
"content": f"Error ({self.error_type}): {self.content}",
|
|
301
|
+
"is_error": True
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
def get_weather(location: str) -> ToolResult:
|
|
305
|
+
# Validate input
|
|
306
|
+
if not location or len(location) < 2:
|
|
307
|
+
return ToolResult(
|
|
308
|
+
success=False,
|
|
309
|
+
content="Location must be at least 2 characters",
|
|
310
|
+
error_type="validation_error"
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
try:
|
|
314
|
+
data = weather_api.fetch(location)
|
|
315
|
+
return ToolResult(
|
|
316
|
+
success=True,
|
|
317
|
+
content=f"Temperature: {data.temp}°F, Conditions: {data.conditions}"
|
|
318
|
+
)
|
|
319
|
+
except LocationNotFound:
|
|
320
|
+
return ToolResult(
|
|
321
|
+
success=False,
|
|
322
|
+
content=f"Location '{location}' not found",
|
|
323
|
+
error_type="not_found",
|
|
324
|
+
suggestions=weather_api.suggest_locations(location)
|
|
325
|
+
)
|
|
326
|
+
except RateLimitError:
|
|
327
|
+
return ToolResult(
|
|
328
|
+
success=False,
|
|
329
|
+
content="Weather service rate limit exceeded. Try again in 60 seconds.",
|
|
330
|
+
error_type="rate_limit"
|
|
331
|
+
)
|
|
332
|
+
except Exception as e:
|
|
333
|
+
return ToolResult(
|
|
334
|
+
success=False,
|
|
335
|
+
content=f"Unexpected error: {str(e)}",
|
|
336
|
+
error_type="internal_error"
|
|
337
|
+
)
|
|
338
|
+
"""
|
|
339
|
+
|
|
340
|
+
### MCP Tool Pattern
|
|
341
|
+
|
|
342
|
+
Building tools using Model Context Protocol
|
|
343
|
+
|
|
344
|
+
**When to use**: Creating reusable, cross-platform tools
|
|
345
|
+
|
|
346
|
+
# MCP TOOL IMPLEMENTATION:
|
|
347
|
+
|
|
348
|
+
"""
|
|
349
|
+
MCP (Model Context Protocol) is Anthropic's open standard for
|
|
350
|
+
connecting AI agents to external systems. Build once, use everywhere.
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
## Basic MCP Server (TypeScript)
|
|
354
|
+
"""
|
|
355
|
+
import { Server } from "@modelcontextprotocol/sdk/server";
|
|
356
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio";
|
|
357
|
+
|
|
358
|
+
const server = new Server({
|
|
359
|
+
name: "weather-server",
|
|
360
|
+
version: "1.0.0"
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Define tools
|
|
364
|
+
server.setRequestHandler("tools/list", async () => ({
|
|
365
|
+
tools: [
|
|
366
|
+
{
|
|
367
|
+
name: "get_weather",
|
|
368
|
+
description: "Get current weather for a location. Returns
|
|
369
|
+
temperature, conditions, and humidity. Use for weather
|
|
370
|
+
queries about specific cities.",
|
|
371
|
+
inputSchema: {
|
|
372
|
+
type: "object",
|
|
373
|
+
properties: {
|
|
374
|
+
location: {
|
|
375
|
+
type: "string",
|
|
376
|
+
description: "City and state, e.g. 'San Francisco, CA'"
|
|
377
|
+
},
|
|
378
|
+
unit: {
|
|
379
|
+
type: "string",
|
|
380
|
+
enum: ["celsius", "fahrenheit"],
|
|
381
|
+
default: "fahrenheit"
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
required: ["location"]
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
}));
|
|
389
|
+
|
|
390
|
+
// Handle tool calls
|
|
391
|
+
server.setRequestHandler("tools/call", async (request) => {
|
|
392
|
+
const { name, arguments: args } = request.params;
|
|
393
|
+
|
|
394
|
+
if (name === "get_weather") {
|
|
395
|
+
try {
|
|
396
|
+
const weather = await fetchWeather(args.location, args.unit);
|
|
397
|
+
return {
|
|
398
|
+
content: [
|
|
399
|
+
{
|
|
400
|
+
type: "text",
|
|
401
|
+
text: JSON.stringify(weather)
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
};
|
|
405
|
+
} catch (error) {
|
|
406
|
+
return {
|
|
407
|
+
content: [
|
|
408
|
+
{
|
|
409
|
+
type: "text",
|
|
410
|
+
text: `Error: ${error.message}`
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
isError: true
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// Start server
|
|
422
|
+
const transport = new StdioServerTransport();
|
|
423
|
+
await server.connect(transport);
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
## MCP Benefits
|
|
427
|
+
"""
|
|
428
|
+
- Universal compatibility across LLM providers
|
|
429
|
+
- Reusable tool libraries
|
|
430
|
+
- Streaming and SSE transport support
|
|
431
|
+
- Built-in observability
|
|
432
|
+
- Tool access controls
|
|
433
|
+
"""
|
|
434
|
+
|
|
435
|
+
### Tool Runner Pattern
|
|
436
|
+
|
|
437
|
+
Using SDK tool runners for automatic handling
|
|
438
|
+
|
|
439
|
+
**When to use**: Building tool loops without manual management
|
|
440
|
+
|
|
441
|
+
# TOOL RUNNER (Anthropic SDK Beta):
|
|
442
|
+
|
|
443
|
+
"""
|
|
444
|
+
The tool runner handles the tool call loop automatically:
|
|
445
|
+
- Executes tools when Claude calls them
|
|
446
|
+
- Manages conversation state
|
|
447
|
+
- Handles error retries
|
|
448
|
+
- Provides streaming support
|
|
449
|
+
"""
|
|
450
|
+
|
|
451
|
+
## Python Example
|
|
452
|
+
"""
|
|
453
|
+
import anthropic
|
|
454
|
+
from anthropic import beta_tool
|
|
455
|
+
|
|
456
|
+
client = anthropic.Anthropic()
|
|
457
|
+
|
|
458
|
+
@beta_tool
|
|
459
|
+
def get_weather(location: str, unit: str = "fahrenheit") -> str:
|
|
460
|
+
'''Get the current weather in a given location.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
location: The city and state, e.g. San Francisco, CA
|
|
464
|
+
unit: Temperature unit, either 'celsius' or 'fahrenheit'
|
|
465
|
+
'''
|
|
466
|
+
# Implementation
|
|
467
|
+
return json.dumps({"temperature": "72°F", "conditions": "Sunny"})
|
|
468
|
+
|
|
469
|
+
@beta_tool
|
|
470
|
+
def search_web(query: str) -> str:
|
|
471
|
+
'''Search the web for information.
|
|
472
|
+
|
|
473
|
+
Args:
|
|
474
|
+
query: The search query
|
|
475
|
+
'''
|
|
476
|
+
# Implementation
|
|
477
|
+
return json.dumps({"results": [...]})
|
|
478
|
+
|
|
479
|
+
# Tool runner handles the loop
|
|
480
|
+
runner = client.beta.messages.tool_runner(
|
|
481
|
+
model="claude-sonnet-4-5",
|
|
482
|
+
max_tokens=1024,
|
|
483
|
+
tools=[get_weather, search_web],
|
|
484
|
+
messages=[
|
|
485
|
+
{"role": "user", "content": "What's the weather in Paris?"}
|
|
486
|
+
]
|
|
487
|
+
)
|
|
46
488
|
|
|
47
|
-
|
|
489
|
+
# Process each message
|
|
490
|
+
for message in runner:
|
|
491
|
+
print(message.content[0].text)
|
|
48
492
|
|
|
49
|
-
|
|
493
|
+
# Or just get final result
|
|
494
|
+
final = runner.until_done()
|
|
495
|
+
"""
|
|
50
496
|
|
|
51
|
-
|
|
497
|
+
## TypeScript with Zod
|
|
498
|
+
"""
|
|
499
|
+
import { Anthropic } from '@anthropic-ai/sdk';
|
|
500
|
+
import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
|
|
501
|
+
import { z } from 'zod';
|
|
502
|
+
|
|
503
|
+
const anthropic = new Anthropic();
|
|
504
|
+
|
|
505
|
+
const getWeatherTool = betaZodTool({
|
|
506
|
+
name: 'get_weather',
|
|
507
|
+
description: 'Get the current weather in a given location',
|
|
508
|
+
inputSchema: z.object({
|
|
509
|
+
location: z.string().describe('City and state, e.g. San Francisco, CA'),
|
|
510
|
+
unit: z.enum(['celsius', 'fahrenheit']).default('fahrenheit')
|
|
511
|
+
}),
|
|
512
|
+
run: async (input) => {
|
|
513
|
+
// Type-safe input!
|
|
514
|
+
return JSON.stringify({temperature: '72°F'});
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
const runner = anthropic.beta.messages.toolRunner({
|
|
519
|
+
model: 'claude-sonnet-4-5',
|
|
520
|
+
max_tokens: 1024,
|
|
521
|
+
tools: [getWeatherTool],
|
|
522
|
+
messages: [{ role: 'user', content: "What's the weather in Paris?" }]
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
for await (const message of runner) {
|
|
526
|
+
console.log(message.content[0].text);
|
|
527
|
+
}
|
|
528
|
+
"""
|
|
529
|
+
|
|
530
|
+
### Parallel Tool Execution
|
|
531
|
+
|
|
532
|
+
Running multiple tools simultaneously
|
|
533
|
+
|
|
534
|
+
**When to use**: Independent tool calls that can run in parallel
|
|
535
|
+
|
|
536
|
+
# PARALLEL TOOL EXECUTION:
|
|
537
|
+
|
|
538
|
+
"""
|
|
539
|
+
By default, Claude can call multiple tools in one response.
|
|
540
|
+
This dramatically reduces latency for independent operations.
|
|
541
|
+
"""
|
|
542
|
+
|
|
543
|
+
## Handling Parallel Results
|
|
544
|
+
"""
|
|
545
|
+
# Claude returns multiple tool_use blocks:
|
|
546
|
+
response.content = [
|
|
547
|
+
{"type": "text", "text": "I'll check both locations..."},
|
|
548
|
+
{"type": "tool_use", "id": "toolu_01", "name": "get_weather",
|
|
549
|
+
"input": {"location": "San Francisco, CA"}},
|
|
550
|
+
{"type": "tool_use", "id": "toolu_02", "name": "get_weather",
|
|
551
|
+
"input": {"location": "New York, NY"}},
|
|
552
|
+
{"type": "tool_use", "id": "toolu_03", "name": "get_time",
|
|
553
|
+
"input": {"timezone": "America/Los_Angeles"}},
|
|
554
|
+
{"type": "tool_use", "id": "toolu_04", "name": "get_time",
|
|
555
|
+
"input": {"timezone": "America/New_York"}}
|
|
556
|
+
]
|
|
557
|
+
|
|
558
|
+
# Execute in parallel
|
|
559
|
+
import asyncio
|
|
560
|
+
|
|
561
|
+
async def execute_tools_parallel(tool_uses):
|
|
562
|
+
tasks = [execute_tool(t) for t in tool_uses]
|
|
563
|
+
return await asyncio.gather(*tasks)
|
|
564
|
+
|
|
565
|
+
results = await execute_tools_parallel(tool_uses)
|
|
566
|
+
|
|
567
|
+
# Return ALL results in SINGLE user message (critical!)
|
|
568
|
+
tool_results = [
|
|
569
|
+
{"type": "tool_result", "tool_use_id": "toolu_01", "content": "72°F, Sunny"},
|
|
570
|
+
{"type": "tool_result", "tool_use_id": "toolu_02", "content": "45°F, Cloudy"},
|
|
571
|
+
{"type": "tool_result", "tool_use_id": "toolu_03", "content": "2:30 PM PST"},
|
|
572
|
+
{"type": "tool_result", "tool_use_id": "toolu_04", "content": "5:30 PM EST"}
|
|
573
|
+
]
|
|
574
|
+
|
|
575
|
+
# CORRECT: All results in one message
|
|
576
|
+
messages.append({"role": "user", "content": tool_results})
|
|
577
|
+
|
|
578
|
+
# WRONG: Separate messages (breaks parallel execution pattern)
|
|
579
|
+
# messages.append({"role": "user", "content": [tool_results[0]]})
|
|
580
|
+
# messages.append({"role": "user", "content": [tool_results[1]]})
|
|
581
|
+
"""
|
|
582
|
+
|
|
583
|
+
## Encouraging Parallel Tool Use
|
|
584
|
+
"""
|
|
585
|
+
Add to system prompt:
|
|
586
|
+
"For maximum efficiency, whenever you need to perform multiple
|
|
587
|
+
independent operations, invoke all relevant tools simultaneously
|
|
588
|
+
rather than sequentially."
|
|
589
|
+
"""
|
|
590
|
+
|
|
591
|
+
## Disabling Parallel (When Needed)
|
|
592
|
+
"""
|
|
593
|
+
response = client.messages.create(
|
|
594
|
+
model="claude-sonnet-4-5",
|
|
595
|
+
tools=tools,
|
|
596
|
+
tool_choice={"type": "auto", "disable_parallel_tool_use": True},
|
|
597
|
+
messages=messages
|
|
598
|
+
)
|
|
599
|
+
"""
|
|
600
|
+
|
|
601
|
+
## Validation Checks
|
|
602
|
+
|
|
603
|
+
### Tool Description Must Be Comprehensive
|
|
604
|
+
|
|
605
|
+
Severity: WARNING
|
|
606
|
+
|
|
607
|
+
Tool descriptions should be at least 100 characters
|
|
608
|
+
|
|
609
|
+
Message: Tool description is too short. Add details about when to use it, parameters, and return values.
|
|
610
|
+
|
|
611
|
+
### Parameter Descriptions Required
|
|
612
|
+
|
|
613
|
+
Severity: WARNING
|
|
614
|
+
|
|
615
|
+
Every parameter should have a description
|
|
616
|
+
|
|
617
|
+
Message: Parameter missing description. Describe what it is and the expected format.
|
|
618
|
+
|
|
619
|
+
### Schema Should Specify Required Fields
|
|
620
|
+
|
|
621
|
+
Severity: INFO
|
|
622
|
+
|
|
623
|
+
Explicitly define which fields are required
|
|
624
|
+
|
|
625
|
+
Message: Schema doesn't specify required fields. Add 'required' array.
|
|
626
|
+
|
|
627
|
+
### Tool Implementation Needs Error Handling
|
|
628
|
+
|
|
629
|
+
Severity: ERROR
|
|
630
|
+
|
|
631
|
+
Tool functions should handle exceptions
|
|
632
|
+
|
|
633
|
+
Message: Tool function without try/except block. Add error handling.
|
|
634
|
+
|
|
635
|
+
### Error Results Need is_error Flag
|
|
636
|
+
|
|
637
|
+
Severity: WARNING
|
|
638
|
+
|
|
639
|
+
When returning errors, set is_error to true
|
|
640
|
+
|
|
641
|
+
Message: Error result without is_error flag. Add 'is_error': true.
|
|
642
|
+
|
|
643
|
+
### Tools Should Return Strings
|
|
644
|
+
|
|
645
|
+
Severity: WARNING
|
|
646
|
+
|
|
647
|
+
Return JSON string, not dict/object
|
|
648
|
+
|
|
649
|
+
Message: Returning dict instead of string. Use json.dumps() or JSON.stringify().
|
|
650
|
+
|
|
651
|
+
### Tools Should Validate Inputs
|
|
652
|
+
|
|
653
|
+
Severity: WARNING
|
|
654
|
+
|
|
655
|
+
Validate LLM-provided inputs before execution
|
|
656
|
+
|
|
657
|
+
Message: Tool function without visible input validation. Validate before execution.
|
|
658
|
+
|
|
659
|
+
### SQL Queries Must Use Parameterization
|
|
660
|
+
|
|
661
|
+
Severity: ERROR
|
|
662
|
+
|
|
663
|
+
Never concatenate user input into SQL
|
|
664
|
+
|
|
665
|
+
Message: SQL query appears to use string concatenation. Use parameterized queries.
|
|
666
|
+
|
|
667
|
+
### External Calls Need Timeouts
|
|
668
|
+
|
|
669
|
+
Severity: WARNING
|
|
670
|
+
|
|
671
|
+
HTTP requests and external calls should have timeouts
|
|
672
|
+
|
|
673
|
+
Message: External API call without timeout. Add timeout parameter.
|
|
674
|
+
|
|
675
|
+
### MCP Tools Must Have Input Schema
|
|
676
|
+
|
|
677
|
+
Severity: ERROR
|
|
678
|
+
|
|
679
|
+
All MCP tools require inputSchema
|
|
680
|
+
|
|
681
|
+
Message: MCP tool definition missing inputSchema.
|
|
682
|
+
|
|
683
|
+
## Collaboration
|
|
684
|
+
|
|
685
|
+
### Delegation Triggers
|
|
686
|
+
|
|
687
|
+
- user needs to coordinate multiple tools -> multi-agent-orchestration (Tool orchestration across agents)
|
|
688
|
+
- user needs persistent memory between tool calls -> agent-memory-systems (State management for tools)
|
|
689
|
+
- user building voice agent tools -> voice-agents (Audio/voice-specific tool requirements)
|
|
690
|
+
- user needs computer control tools -> computer-use-agents (Desktop automation tools)
|
|
691
|
+
- user wants to test their tools -> agent-evaluation (Tool testing and evaluation)
|
|
52
692
|
|
|
53
693
|
## Related Skills
|
|
54
694
|
|
|
55
695
|
Works well with: `multi-agent-orchestration`, `api-designer`, `llm-architect`, `backend`
|
|
56
696
|
|
|
57
697
|
## When to Use
|
|
58
|
-
|
|
698
|
+
|
|
699
|
+
- User mentions or implies: agent tool
|
|
700
|
+
- User mentions or implies: function calling
|
|
701
|
+
- User mentions or implies: tool schema
|
|
702
|
+
- User mentions or implies: tool design
|
|
703
|
+
- User mentions or implies: mcp server
|
|
704
|
+
- User mentions or implies: mcp tool
|
|
705
|
+
- User mentions or implies: tool use
|
|
706
|
+
- User mentions or implies: build tool for agent
|
|
707
|
+
- User mentions or implies: define function
|
|
708
|
+
- User mentions or implies: input_schema
|
|
709
|
+
- User mentions or implies: tool_use
|
|
710
|
+
- User mentions or implies: tool_result
|