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

# OpenCode

> Connect CodeAlive with OpenCode AI terminal assistant

## Overview

Connect CodeAlive with OpenCode — an open-source AI coding assistant that runs in your terminal. OpenCode uses its own JSON configuration format with a `type: remote` transport for HTTP connections.

> [!TIP]
>
> **Quick install:** Run `npx @codealive/installer` to automatically configure CodeAlive for OpenCode.
> See the [Installation Guide](https://docs.codealive.ai/installation.md) for details.

## Prerequisites

* OpenCode installed ([github.com/opencode-ai/opencode](https://github.com/opencode-ai/opencode))
* CodeAlive account ([Sign up here](https://app.codealive.ai))
* Indexed repositories in your CodeAlive dashboard

## Setup

**1. Locate Config File**

OpenCode reads configuration from `opencode.json` in your project root or home directory.

**2. Add CodeAlive Server**

Add this to your `opencode.json`:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "codealive": {
      "type": "remote",
      "url": "https://mcp.codealive.ai/api",
      "enabled": true
    }
  }
}
```

OpenCode discovers OAuth automatically. Restart OpenCode and follow the browser prompt, or run `opencode mcp auth codealive` explicitly.

> [!NOTE]
>
> OpenCode uses `type: "remote"` for HTTP-based MCP servers, which is different from most other clients that use `type: "http"` or `type: "streamable-http"`.

> [!NOTE]
>
> Existing API-key configurations remain supported. To use one intentionally, set `"oauth": false` and add an `Authorization: Bearer ...` header.

**3. Restart OpenCode**

Restart OpenCode to load the new MCP configuration.

**4. Verify Integration**

Try these commands with OpenCode:

* "Show me all available repositories"
* "Find authentication code in my codebase"
* "Explain how the payment flow works"

## Docker Alternative

If you prefer running the MCP server locally:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "codealive": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "CODEALIVE_API_KEY=YOUR_API_KEY_HERE",
        "ghcr.io/codealive-ai/codealive-mcp:main"
      ],
      "enabled": true
    }
  }
}
```

## Usage

Once connected, OpenCode can:

* **Search your codebase** semantically across all indexed repositories
* **Answer architecture questions** with full project context
* **Find patterns and implementations** across multiple services

```
"Find all error handling patterns in the payment service"
"Explain how the user registration flow works"
"Search for database migration code across services"
```

## Troubleshooting

> [accordion] MCP server not detected
>
> 1. Verify the config file is named `opencode.json`
> 2. Check that `type` is set to `"remote"` (not `"http"`)
> 3. Ensure `"enabled": true` is set
> 4. Restart OpenCode

> [accordion] Authentication errors
>
> 1. Run `opencode mcp auth codealive`
> 2. Inspect discovery with `opencode mcp debug codealive`
> 3. If you intentionally use the API-key fallback, verify the key is active and set `"oauth": false`

> [accordion] Connection timeouts
>
> 1. Check your network connection
> 2. Try the Docker STDIO option for local access
> 3. Verify the URL is `https://mcp.codealive.ai/api`

> [!TIP]
>
> For more solutions, see the [Troubleshooting Guide](https://docs.codealive.ai/troubleshooting.md).

## Related Resources

* [MCP Overview](https://docs.codealive.ai/integrations/mcp.md)
* [Installation Guide](https://docs.codealive.ai/installation.md)
* [Self-Hosting Guide](https://docs.codealive.ai/integrations/mcp/self-hosting.md)
* [Agent Skills](https://docs.codealive.ai/integrations/skills.md)

## Instruct Your Agent

Connecting CodeAlive makes its tools available, but the agent may still default to its built-in search. For reliable results, add a short instruction in the agent's native format telling it to prefer `semantic_search` and `grep_search` when exploring indexed code. See [Instructing Coding Agents](https://docs.codealive.ai/guides/instructing-agents.md).


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