Skip to main content
OpenCode can use Mirage through a native plugin, without MCP. The plugin replaces its filesystem and shell tools with Mirage-backed versions.

Install

Create a mirage.yaml in your project:
mirage.yaml
Add the plugin to opencode.json:
opencode.json
Run opencode normally. Mirage searches the project and parent directories for mirage.yaml, workspace.yaml, .mirage/workspace.yaml, and their .yml variants. To select another config or disable stale-write protection, pass plugin options:
opencode.json
You can also set MIRAGE_OPENCODE_CONFIG or MIRAGE_CONFIG to the workspace config path.

Stale writes

Stale-write protection is enabled by default and isolated per OpenCode session. read records a content fingerprint; write and edit verify it immediately before changing the file. If the file changed, OpenCode must reread it before retrying. bash commands are not tracked because they can read or mutate arbitrary paths. Use the structured read, write, and edit tools when stale-write protection is required.

Custom plugin

Use @struktoai/mirage-agents/opencode directly when the workspace is constructed in code rather than YAML:
Create .opencode/plugins/mirage.ts:
.opencode/plugins/mirage.ts
Add the dependencies to .opencode/package.json:
.opencode/package.json

Exports

Tool reference

Tools return text except PDF and image reads, which return OpenCode attachments. bash, glob, and grep run through the Mirage shell across all mounts.

Examples