Tools
Tools allow the LLM to perform actions in your codebase. OpenCode comes with built-in tools and supports extension via custom tools and MCP servers.
By default, all tools are enabled and don't require permission to run. You can control behavior through permissions.
Built-in Tools
bash
Execute shell commands in your project environment.
# The LLM can run commands like:
npm install
git status
python test.pyedit
Modify existing files using exact string replacements. This is the primary way the LLM modifies code — it finds an exact text match and replaces it.
write
Create new files or overwrite existing ones. Controlled by the edit permission (which covers all file modifications: edit, write, apply_patch, multiedit).
read
Read file contents from your codebase. Supports reading specific line ranges for large files.
grep
Search file contents using regular expressions. Fast content search across your entire codebase with support for file pattern filtering.
glob
Find files by pattern matching (e.g., **/*.js, src/**/*.ts). Returns matching file paths sorted by modification time.
list
List files and directories in a given path. Accepts glob patterns to filter results.
apply_patch
Apply patches to files. Useful for applying diffs and patches. Controlled by the edit permission.
INFO
apply_patch uses output.args.patchText instead of output.args.filePath. Paths are embedded in marker lines within the patch text (e.g., *** Add File: src/new-file.ts).
lsp (experimental)
Interact with configured LSP servers for code intelligence:
goToDefinition— Jump to symbol definitionfindReferences— Find all references to a symbolhover— Get hover informationdocumentSymbol/workspaceSymbol— Browse symbolsgoToImplementation— Find implementationsprepareCallHierarchy/incomingCalls/outgoingCalls— Call hierarchy
WARNING
Only available when OPENCODE_EXPERIMENTAL_LSP_TOOL=true (or OPENCODE_EXPERIMENTAL=true).
skill
Load a skill (SKILL.md file) and return its content in the conversation.
todowrite
Manage todo lists during coding sessions. Creates and updates task lists to track progress during complex multi-step operations.
webfetch
Fetch and read web page content. Useful for looking up documentation or online resources.
websearch
Search the web using Exa AI. No API key required.
TIP
Use websearch for discovery (finding information) and webfetch for retrieval (getting content from a known URL).
Only available when using OpenCode provider or when OPENCODE_ENABLE_EXA=1:
OPENCODE_ENABLE_EXA=1 opencodequestion
Ask the user questions during execution. This includes options for the user to select from, useful for gathering preferences, clarifying instructions, or getting decisions.
Tool Permissions
Control each tool's behavior via the permission config:
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "allow",
"bash": "ask",
"webfetch": "allow",
"websearch": "allow"
}
}| Value | Behavior |
|---|---|
"allow" | Tool runs without asking (default) |
"ask" | Requires user approval before running |
"deny" | Tool is disabled |
Use wildcards for MCP server tools:
{
"permission": {
"mymcp_*": "ask"
}
}Custom Tools
Define your own tools that the LLM can call. These execute arbitrary code and are defined in your config file.
See Custom Tools Documentation for details.
MCP Servers
MCP (Model Context Protocol) servers integrate external tools and services — database access, API integrations, third-party services, and more.
Configure them in your opencode.json:
{
"mcp": {
"my-server": {
"type": "remote",
"url": "https://example.com/mcp",
"enabled": true
}
}
}See MCP Servers Documentation for details.
Internals
Tools like grep, glob, and list use ripgrep internally. By default, ripgrep respects .gitignore patterns.
To include files that are normally ignored, create a .ignore file in your project root:
# .ignore
!node_modules/
!dist/
!build/