Skip to content

Commit f51c4fa

Browse files
SannidhyaSahSannidhya
andauthored
docs: add Custom Tools experimental feature documentation (#471)
Co-authored-by: Sannidhya <[email protected]>
1 parent 2cd44a1 commit f51c4fa

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
description: Define TypeScript/JavaScript tools that extend Roo's capabilities beyond built-in tools, enabling project-specific workflows and team standardization.
3+
keywords:
4+
- experimental features
5+
- custom tools
6+
- TypeScript tools
7+
- JavaScript tools
8+
- tool extension
9+
- defineCustomTool
10+
- workflow automation
11+
image: /img/social-share.jpg
12+
---
13+
# Custom Tools
14+
15+
Define TypeScript or JavaScript tools that Roo can call like built-in tools—standardize team workflows instead of re-prompting the same steps every task.
16+
17+
:::warning Experimental Feature
18+
Custom tools is an experimental feature. Custom tools are **automatically approved** when enabled—Roo won't ask for permission before running them. Only enable this feature if you trust your tool code.
19+
:::
20+
21+
---
22+
23+
## What it does
24+
25+
Custom tools let you codify project-specific actions into TypeScript/JavaScript files that Roo calls like [`read_file()`](/basic-usage/how-tools-work) or [`execute_command()`](/basic-usage/how-tools-work). Ship tool schemas alongside your repo so teammates don't need to keep re-explaining the same workflow steps. Tools are validated with Zod and automatically transpiled from TypeScript.
26+
27+
---
28+
29+
## How to create a tool
30+
31+
Tools live in `.roo/tools/` (project-specific) or `~/.roo/tools/` (global) as `.ts` or `.js` files. Tools from later directories can override earlier ones.
32+
33+
#### Basic structure
34+
35+
```typescript
36+
import { parametersSchema as z, defineCustomTool } from "@roo-code/types"
37+
38+
export default defineCustomTool({
39+
name: "tool_name",
40+
description: "What the tool does (shown to AI)",
41+
parameters: z.object({
42+
param1: z.string().describe("Parameter description"),
43+
param2: z.number().describe("Another parameter"),
44+
}),
45+
async execute(args, context) {
46+
// args are type-safe and validated
47+
// context provides: mode, task
48+
return "Result string shown to AI"
49+
}
50+
})
51+
```
52+
53+
#### What you define
54+
55+
- **`name`**: Tool name Roo sees in its available tools list
56+
- **`description`**: Shown to the AI so it knows when to call the tool
57+
- **`parameters`**: Zod schema converted to JSON Schema for validation
58+
- **`execute`**: Async function returning a string result to Roo
59+
60+
Tools are dynamically loaded and transpiled with esbuild. Changes to tool files trigger automatic reload.
61+
62+
---
63+
64+
## Enabling the feature
65+
66+
1. Open Roo Code settings (gear icon in top right)
67+
2. Go to the "Experimental" tab
68+
3. Toggle "Enable custom tools"
69+
70+
<img src="/img/custom-tools/custom-tools.png" alt="Enable custom tools toggle in experimental settings" width="400" />
71+
72+
**Critical:** When enabled, custom tools are **auto-approved**—Roo runs them without asking. Disable if you don't trust the tool code.
73+
74+
---
75+
76+
## Tool directories
77+
78+
- **`.roo/tools/`** in your workspace: project-specific tools shared with your team
79+
- **`~/.roo/tools/`** in your home folder: personal tools across all projects
80+
81+
Tools from both directories are loaded. Tools with the same name in `.roo/tools/` override those in `~/.roo/tools/`.
82+
83+
---
84+
85+
## Limits
86+
87+
- **No approval prompts**: Tools are auto-approved when the feature is enabled—security trade-off for convenience
88+
- **String-only results**: Tools must return strings (Roo's protocol constraint)
89+
- **No interactive input**: Tools can't prompt the user mid-execution
90+
- **No npm packages**: Tools are transpiled in isolation; use Node.js built-ins only
91+
- **Cache invalidation**: Tool updates may require reloading the window
92+
93+
**vs. MCP:** [MCP](/features/mcp/overview) is for external services (search, APIs). Custom tools are for in-repo logic you control directly. MCP is more extensible; custom tools are lighter weight for project-specific actions.

docs/features/experimental/experimental-features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ To enable or disable experimental features:
3232

3333
The following experimental features are currently available:
3434

35+
- [Custom Tools](/features/experimental/custom-tools) - Define TypeScript/JavaScript tools that Roo can call like built-in tools
3536
- [Concurrent File Edits](/features/experimental/concurrent-file-edits) - Edit multiple files in a single operation
3637
- [Power Steering](/features/experimental/power-steering) - Enhanced consistency in AI responses
3738
- [Background Editing](/features/experimental/background-editing) - Work uninterrupted while Roo edits files in the background

docs/features/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Discover the powerful features that make Roo Code your ultimate AI-powered codin
5858

5959
Push the boundaries with cutting-edge capabilities:
6060

61+
- [**Custom Tools**](/features/experimental/custom-tools) - Define TypeScript/JavaScript tools that Roo can call
6162
- [**Concurrent File Edits**](/features/experimental/concurrent-file-edits) - Edit multiple files in a single operation
6263
- [**Power Steering**](/features/experimental/power-steering) - Enhanced consistency in AI responses
6364
- [**More Experimental Features**](/features/experimental/experimental-features) - Explore features under development

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const sidebars: SidebarsConfig = {
7070
label: 'Experimental',
7171
items: [
7272
'features/experimental/experimental-features',
73+
'features/experimental/custom-tools',
7374
'features/experimental/concurrent-file-edits',
7475
'features/experimental/power-steering',
7576
'features/experimental/background-editing',
40 KB
Loading

0 commit comments

Comments
 (0)