Creating Custom Tools
createCustomTool()
Create a custom tool with your own execution logic.Examples
- Simple Custom Tool
- With Toolkit Integration
- Database Query Tool
- API Wrapper Tool
Execute Function Signature
Theexecute function receives three parameters:
Input Parameter
Parsed and validated input matching your Zod schema:Connection Config
Auth credentials whentoolkitSlug is provided:
Execute Tool Request
Make authenticated API calls to the toolkit:Return Value
Theexecute function must return a ToolExecuteResponse:
Using Custom Tools
Once created, custom tools work like any built-in tool:Best Practices
- Clear Descriptions: Write clear tool descriptions for AI models
- Input Validation: Use Zod for robust input validation
- Error Handling: Return proper error messages in the response
- Type Safety: Use TypeScript for type-safe implementations
- Idempotency: Make tools idempotent when possible
- Rate Limiting: Handle rate limits in your implementation
- Logging: Log errors for debugging
Limitations
- Custom tools are stored in-memory (not persisted)
- Re-create custom tools on each SDK initialization
- Cannot use
executeToolRequestwithouttoolkitSlug - Custom tools require manual version management
Next Steps
Tools API
Learn about built-in tools
Toolkits
Browse available toolkits
Connected Accounts
Set up authentication
Providers
Choose your AI framework