Set up Expand for OpenCode with the webfetch hook and MCP tools.
Route OpenCode's native webfetch through Expand. Install the hook to replace webfetch output with rendered Markdown and a snapshot reference, and register the Expand MCP server in the same command so OpenCode can also fetch pages directly or call Expand tools when it needs more control.
expandai login
expandai hook install opencode projectRun the project command from the project root. Expand writes OpenCode project config into the current working directory, not a detected git root.
Verify the hook intercepts native webfetch:
Use OpenCode webfetch to read https://news.ycombinator.com through Expand.
Confirm that the output includes an Expand snapshot reference, then show me the first 10 lines of page Markdown.The hook output can start with a snapshot note before the page content. That is expected, and it is the fastest signal that OpenCode is seeing the Expand hook.
Verify the MCP tools are wired up:
Use the Expand MCP fetch tool to fetch https://news.ycombinator.com.
See also: Expand Skill, MCP Tools & Resources, and CLI Commands.
The hook path is the OpenCode default because it improves the thing users already ask OpenCode to do: webfetch. OpenCode still runs its native webfetch tool, then the Expand plugin takes over the result.
The plugin hooks tool.execute.after for the native webfetch tool, shells out to expandai hook opencode, and replaces the tool output with Expand Markdown. The same installer registers the Expand MCP server, so OpenCode can call Expand tools directly when a task needs snapshot search, JSON output, or more precise control.
MCP is not a separate Expand product. It is one integration surface onto Fetch, the same product the hook uses.
expandai hook install opencode project writes two things: the webfetch plugin and the MCP server entry.
| Piece | Project path | Global path |
|---|---|---|
| Webfetch plugin | .opencode/plugins/expandai-webfetch.js | ~/.config/opencode/plugins/expandai-webfetch.js |
| MCP config | opencode.json | ~/.config/opencode/opencode.json |
OpenCode MCP config uses a top-level mcp key, not mcpServers. The installed entry is a local server, enabled, that runs expandai mcp run:
{
"mcp": {
"expandai": {
"type": "local",
"command": ["expandai", "mcp", "run"],
"enabled": true
}
The installer writes this for you. Copy the install command rather than hand-editing JSON.
Project scope is the safer default.
| Scope | Command | Writes to | Use when |
|---|---|---|---|
| Project | expandai hook install opencode project | .opencode/plugins/, opencode.json | You want Expand enabled for this project. |
| Global | expandai hook install opencode global |
Commit .opencode/plugins/expandai-webfetch.js and opencode.json only if the team wants Expand enabled for collaborators.
OpenCode has three Expand surfaces. Start with the hook; the others are additive.
| Surface | Command | What it does | Recommended |
|---|---|---|---|
| Hook | expandai hook install opencode project | Replaces native webfetch output with Expand Markdown and installs MCP. | Yes, default |
| MCP | expandai mcp install opencode project | Registers Expand tools without changing native . |
Use the hook first. Add the Skill only if you want OpenCode to carry explicit Expand usage guidance in its skill system. The Skill installs to .opencode/skills/expandai/SKILL.md for project scope or ~/.config/opencode/skills/expandai/SKILL.md for global scope. Read Expand Skill for its behavior and lifecycle.
expandai hook uninstall opencode project
expandai hook uninstall opencode globalHook uninstall removes the OpenCode webfetch plugin and the Expand MCP entry for the selected scope. It does not touch unrelated OpenCode config or other MCP servers. If you installed only MCP or only the Skill, uninstall it with the matching command (expandai mcp uninstall opencode <scope> or expandai skill uninstall opencode <scope>).
.opencode/plugins/expandai-webfetch.js or ~/.config/opencode/plugins/expandai-webfetch.js.webfetch.expandai login and retry.opencode.json or ~/.config/opencode/opencode.json contains the mcp.expandai entry.expandai mcp run.Expand writes project-scoped OpenCode files into the current directory, not a detected git root. If OpenCode cannot see the plugin or MCP server, check whether you ran the installer from a subfolder.
Run expandai login in your terminal, then ask OpenCode to try again. Local OpenCode setup should not require putting an API key into OpenCode config.
Install the Expand Skill if you want OpenCode to keep explicit guidance for when to fetch, reuse snapshots, and return citations.
~/.config/opencode/plugins/, ~/.config/opencode/opencode.json |
| You want Expand available in every OpenCode workspace. |
webfetch| When you only want tools |
| Skill | expandai skill install opencode project | Adds agent-readable instructions for when and how to use Expand. | Optional |