You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/web/src/content/docs/tools.mdx
+70-89Lines changed: 70 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,86 +5,37 @@ description: Manage the tools an LLM can use.
5
5
6
6
Tools allow the LLM to perform actions in your codebase. OpenCode comes with a set of built-in tools, but you can extend it with [custom tools](/docs/custom-tools) or [MCP servers](/docs/mcp-servers).
7
7
8
-
By default, all tools are **enabled** and don't need permission to run. But you can configure this and control the [permissions](/docs/permissions) through your config.
8
+
By default, all tools are **enabled** and don't need permission to run. You can control tool behavior through [permissions](/docs/permissions).
9
9
10
10
---
11
11
12
12
## Configure
13
13
14
-
You can configure tools globally or per agent. Agent-specific configs override global settings.
15
-
16
-
By default, all tools are set to `true`. To disable a tool, set it to `false`.
17
-
18
-
---
19
-
20
-
### Global
21
-
22
-
Disable or enable tools globally using the `tools` option.
14
+
Use the `permission` field to control tool behavior. You can allow, deny, or require approval for each tool.
23
15
24
16
```json title="opencode.json"
25
17
{
26
18
"$schema": "https://opencode.ai/config.json",
27
-
"tools": {
28
-
"write": false,
29
-
"bash": false,
30
-
"webfetch": true
19
+
"permission": {
20
+
"edit": "deny",
21
+
"bash": "ask",
22
+
"webfetch": "allow"
31
23
}
32
24
}
33
25
```
34
26
35
-
You can also use wildcards to control multiple tools at once. For example, to disable all tools from an MCP server:
27
+
You can also use wildcards to control multiple tools at once. For example, to require approval for all tools from an MCP server:
36
28
37
29
```json title="opencode.json"
38
30
{
39
31
"$schema": "https://opencode.ai/config.json",
40
-
"tools": {
41
-
"mymcp_*": false
42
-
}
43
-
}
44
-
```
45
-
46
-
---
47
-
48
-
### Per agent
49
-
50
-
Override global tool settings for specific agents using the `tools` config in the agent definition.
51
-
52
-
```json title="opencode.json" {3-6,9-12}
53
-
{
54
-
"$schema": "https://opencode.ai/config.json",
55
-
"tools": {
56
-
"write": true,
57
-
"bash": true
58
-
},
59
-
"agent": {
60
-
"plan": {
61
-
"tools": {
62
-
"write": false,
63
-
"bash": false
64
-
}
65
-
}
32
+
"permission": {
33
+
"mymcp_*": "ask"
66
34
}
67
35
}
68
36
```
69
37
70
-
For example, here the `plan` agent overrides the global config to disable `write` and `bash` tools.
71
-
72
-
You can also configure tools for agents in Markdown.
@@ -135,14 +86,18 @@ Create new files or overwrite existing ones.
135
86
```json title="opencode.json" {4}
136
87
{
137
88
"$schema": "https://opencode.ai/config.json",
138
-
"tools": {
139
-
"write": true
89
+
"permission": {
90
+
"edit": "allow"
140
91
}
141
92
}
142
93
```
143
94
144
95
Use this to allow the LLM to create new files. It will overwrite existing files if they already exist.
145
96
97
+
:::note
98
+
The `write` tool is controlled by the `edit` permission, which covers all file modifications (`edit`, `write`, `patch`, `multiedit`).
99
+
:::
100
+
146
101
---
147
102
148
103
### read
@@ -152,8 +107,8 @@ Read file contents from your codebase.
152
107
```json title="opencode.json" {4}
153
108
{
154
109
"$schema": "https://opencode.ai/config.json",
155
-
"tools": {
156
-
"read": true
110
+
"permission": {
111
+
"read": "allow"
157
112
}
158
113
}
159
114
```
@@ -169,8 +124,8 @@ Search file contents using regular expressions.
169
124
```json title="opencode.json" {4}
170
125
{
171
126
"$schema": "https://opencode.ai/config.json",
172
-
"tools": {
173
-
"grep": true
127
+
"permission": {
128
+
"grep": "allow"
174
129
}
175
130
}
176
131
```
@@ -186,8 +141,8 @@ Find files by pattern matching.
186
141
```json title="opencode.json" {4}
187
142
{
188
143
"$schema": "https://opencode.ai/config.json",
189
-
"tools": {
190
-
"glob": true
144
+
"permission": {
145
+
"glob": "allow"
191
146
}
192
147
}
193
148
```
@@ -203,8 +158,8 @@ List files and directories in a given path.
203
158
```json title="opencode.json" {4}
204
159
{
205
160
"$schema": "https://opencode.ai/config.json",
206
-
"tools": {
207
-
"list": true
161
+
"permission": {
162
+
"list": "allow"
208
163
}
209
164
}
210
165
```
@@ -224,8 +179,8 @@ This tool is only available when `OPENCODE_EXPERIMENTAL_LSP_TOOL=true` (or `OPEN
224
179
```json title="opencode.json" {4}
225
180
{
226
181
"$schema": "https://opencode.ai/config.json",
227
-
"tools": {
228
-
"lsp": true
182
+
"permission": {
183
+
"lsp": "allow"
229
184
}
230
185
}
231
186
```
@@ -243,14 +198,18 @@ Apply patches to files.
243
198
```json title="opencode.json" {4}
244
199
{
245
200
"$schema": "https://opencode.ai/config.json",
246
-
"tools": {
247
-
"patch": true
201
+
"permission": {
202
+
"edit": "allow"
248
203
}
249
204
}
250
205
```
251
206
252
207
This tool applies patch files to your codebase. Useful for applying diffs and patches from various sources.
253
208
209
+
:::note
210
+
The `patch` tool is controlled by the `edit` permission, which covers all file modifications (`edit`, `write`, `patch`, `multiedit`).
211
+
:::
212
+
254
213
---
255
214
256
215
### skill
@@ -260,14 +219,12 @@ Load a [skill](/docs/skills) (a `SKILL.md` file) and return its content in the c
260
219
```json title="opencode.json" {4}
261
220
{
262
221
"$schema": "https://opencode.ai/config.json",
263
-
"tools": {
264
-
"skill": true
222
+
"permission": {
223
+
"skill": "allow"
265
224
}
266
225
}
267
226
```
268
227
269
-
You can control approval prompts for loading skills via [permissions](/docs/permissions) using `permission.skill`.
270
-
271
228
---
272
229
273
230
### todowrite
@@ -277,16 +234,16 @@ Manage todo lists during coding sessions.
277
234
```json title="opencode.json" {4}
278
235
{
279
236
"$schema": "https://opencode.ai/config.json",
280
-
"tools": {
281
-
"todowrite": true
237
+
"permission": {
238
+
"todowrite": "allow"
282
239
}
283
240
}
284
241
```
285
242
286
243
Creates and updates task lists to track progress during complex operations. The LLM uses this to organize multi-step tasks.
287
244
288
245
:::note
289
-
This tool is disabled for subagents by default, but you can enable it manually. [Learn more](/docs/agents/#tools)
246
+
This tool is disabled for subagents by default, but you can enable it manually. [Learn more](/docs/agents/#permissions)
290
247
:::
291
248
292
249
---
@@ -298,16 +255,16 @@ Read existing todo lists.
298
255
```json title="opencode.json" {4}
299
256
{
300
257
"$schema": "https://opencode.ai/config.json",
301
-
"tools": {
302
-
"todoread": true
258
+
"permission": {
259
+
"todoread": "allow"
303
260
}
304
261
}
305
262
```
306
263
307
264
Reads the current todo list state. Used by the LLM to track what tasks are pending or completed.
308
265
309
266
:::note
310
-
This tool is disabled for subagents by default, but you can enable it manually. [Learn more](/docs/agents/#tools)
267
+
This tool is disabled for subagents by default, but you can enable it manually. [Learn more](/docs/agents/#permissions)
311
268
:::
312
269
313
270
---
@@ -319,8 +276,8 @@ Fetch web content.
319
276
```json title="opencode.json" {4}
320
277
{
321
278
"$schema": "https://opencode.ai/config.json",
322
-
"tools": {
323
-
"webfetch": true
279
+
"permission": {
280
+
"webfetch": "allow"
324
281
}
325
282
}
326
283
```
@@ -329,6 +286,30 @@ Allows the LLM to fetch and read web pages. Useful for looking up documentation
329
286
330
287
---
331
288
289
+
### question
290
+
291
+
Ask the user questions during execution.
292
+
293
+
```json title="opencode.json" {4}
294
+
{
295
+
"$schema": "https://opencode.ai/config.json",
296
+
"permission": {
297
+
"question": "allow"
298
+
}
299
+
}
300
+
```
301
+
302
+
This tool allows the LLM to ask the user questions during a task. It's useful for:
303
+
304
+
- Gathering user preferences or requirements
305
+
- Clarifying ambiguous instructions
306
+
- Getting decisions on implementation choices
307
+
- Offering choices about what direction to take
308
+
309
+
Each question includes a header, the question text, and a list of options. Users can select from the provided options or type a custom answer. When there are multiple questions, users can navigate between them before submitting all answers.
310
+
311
+
---
312
+
332
313
## Custom tools
333
314
334
315
Custom tools let you define your own functions that the LLM can call. These are defined in your config file and can execute arbitrary code.
0 commit comments