# OpenCode MCP server

> Delegates heavy tasks from orchestrator models to isolated OpenCode subagents to preserve context window quality and reduce token costs.

- Repository: https://github.com/alejandro-technology/opencode-mcp
- Page: https://hostedmcp.org/servers/alejandro-technology/opencode-mcp
- Transport: stdio
- Stars: 6

## Install

### Claude Code

```sh
claude mcp add opencode-mcp -- npx -y mcp-server-opencode
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "opencode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-opencode"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "opencode-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-opencode"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"opencode-mcp","type":"stdio","command":"npx","args":["-y","mcp-server-opencode"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "opencode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-opencode"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add opencode-mcp -- npx -y mcp-server-opencode
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.opencode-mcp]
command = "npx"
args = ["-y", "mcp-server-opencode"]
```

### Gemini CLI

```sh
gemini mcp add -s user opencode-mcp npx -- -y mcp-server-opencode
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "opencode-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-opencode"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `MCP_TOOL_TIMEOUT` | no | no |  |
| `OPENCODE_MCP_SMOKE_MODEL` | no | no |  |

## Tools (10)

- `opencode_start_server`
- `opencode_stop_server`
- `opencode_list_agents`
- `opencode_start_task`
- `opencode_continue_task`
- `opencode_cancel_task`
- `opencode_cleanup_workspace`
- `opencode_get_task_status`
- `opencode_get_task_result`
- `opencode_wait_for_task`

## FAQ

### How does this server help with context window management?

It prevents context rot and bloat by delegating large file reads, extensive searches, and repetitive test runs to isolated subagents, returning only concise results to the lead agent.

### Can I run multiple tasks at the same time?

Yes, task delegation is asynchronous, allowing you to dispatch multiple investigation or implementation tasks in parallel without blocking the orchestrator.

### What are the system requirements for installation?

You need Node.js 18+ and OpenCode 1.x installed and configured on your PATH.
