Skip to main content
Complete, runnable examples for defining custom tools, using built-in toolkits, and combining them in agents. Each snippet is self-contained — copy, paste, and run.

1. defineTool Basics

Create a custom tool with a Zod schema. The LLM sees the name, description, and parameter descriptions to decide when and how to call it.

2. Tool with External API

A tool that calls a REST API and returns the result to the LLM.

3. Tool with File I/O

A tool that reads and writes local files. Pair with FileSystemToolkit for sandboxed access.

4. Calculator Toolkit

Evaluate math expressions with no dependencies or API keys.

5. Web Search Toolkit

DuckDuckGo (no API key)

Tavily (AI-optimized results)


6. Wikipedia Toolkit

Search articles and get summaries — no API key required.

7. HTTP Toolkit

Make arbitrary HTTP requests to any REST API.

8. SQL Toolkit

Query databases directly. Supports SQLite, PostgreSQL, and MySQL.

SQLite variant


9. GitHub Toolkit

List repos, create issues, read files — uses the GitHub REST API.

10. Slack Toolkit

Send messages, read channels, and reply in threads.

11. Shell Toolkit

Run shell commands with timeout and command allowlisting for safety.

12. PDF Toolkit

Extract text, metadata, and pages from PDF documents.

13. Code Interpreter

Execute JavaScript, Python, or TypeScript in a sandboxed subprocess.

14. Google Sheets Toolkit

Read, write, and append data in Google Sheets.

15. Filesystem Toolkit

Read, write, list, and inspect files with path sandboxing.

16. MCP Client

Connect to any MCP (Model Context Protocol) server and use its tools natively.

stdio transport

HTTP transport

Multiple MCP servers


17. Dynamic Tools

Add, remove, and resolve tools at runtime based on context.

Runtime mutation

Tool resolver (context-dependent tools)

Hot-swapping with setTools


18. Combining Multiple Toolkits

Build a fully-equipped agent with several toolkits loaded together.

Using collectToolkitTools for a named registry