> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Give an OpenCode V2 project keyless web search and page extraction through local MCP.

Add WebRouter as a project-local MCP server to expose `webrouter_search` and
`webrouter_extract` to your OpenCode agent. The recipe uses [OpenCode V2](https://opencode.ai/docs/),
a POSIX shell, and [uv](https://docs.astral.sh/uv/getting-started/installation/)
with `uvx` on the OpenCode server's PATH. uv runs WebRouter 0.17.0 with its MCP
extra and Python 3.11 or later. The server requires no WebRouter account or
provider credentials.

## Set up a project

Use the [example files](https://github.com/Nimbleway/webrouter/tree/main/examples/opencode).
Put `opencode.json` and `webrouter-mcp.sh` in your project root. If the project
already has `opencode.json` or `opencode.jsonc`, merge the `mcp.servers.webrouter`
entry into that file.

From the project root, start a local OpenCode service and leave it running:

```sh theme={null}
opencode serve --hostname 127.0.0.1 --port 0
```

In another terminal in the same project, set `OPENCODE_PASSWORD` to the
password printed by the service. Replace the example address below with the
loopback URL it printed:

```sh theme={null}
opencode --server http://127.0.0.1:4096 mcp list
```

Look for `webrouter  connected`. If the first check reports no servers or a
pending connection, repeat it against the same service. The first launch may
need to download Python, WebRouter, and its dependencies.

With a tool-capable model configured in OpenCode, try:

> Use webrouter\_search to find the official Python pathlib documentation. Then
> use webrouter\_extract to read the current documentation page and summarize
> how pure paths differ from concrete paths. Include the source URL.

## Credentials and scope

The launcher gives WebRouter a temporary home and a clean environment while
keeping dedicated directories for uv downloads. It skips working-directory
and remembered credential files and disables the `load_env` tool. OpenCode's
model uses its own configuration. The example serves only search and extract.

To turn off the MCP server, set `disabled: true` on the `mcp.servers.webrouter`
entry or remove the entry. The example pins the MCP protocol to `2026-07-28`
for the packaged server. OpenCode v2.4.3 was verified with real keyless calls
through the CLI on macOS arm64. See the [OpenCode MCP guide](https://opencode.ai/docs/mcp-servers/)
for V2 configuration details.

[Back to Integrations](https://docs.webrouter.net/integrations/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.