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

# OpenCode

> Connect OpenCode, the terminal-native AI coding assistant, to Control Plane to operate your infrastructure without leaving your shell.

## Prerequisites

<CardGroup cols={2}>
  <Card title="OpenCode" icon="https://mintcdn.com/controlplanecorporation/rFQpIcXts1y-5L7u/icons/opencode.svg?fit=max&auto=format&n=rFQpIcXts1y-5L7u&q=85&s=f58ee6d5c9eb2828f371a72d7ba8c8fc" width="512" height="512" data-path="icons/opencode.svg">
    Install [OpenCode](https://opencode.ai)
  </Card>

  <Card title="Control Plane account" icon="user">
    Sign up at [console.cpln.io](https://console.cpln.io) if you don't have an account yet
  </Card>
</CardGroup>

## Add the MCP server

<Steps>
  <Step title="Run the add wizard">
    ```bash theme={null}
    opencode mcp add
    ```

    Answer the prompts:

    | Prompt                                         | Value                     |
    | ---------------------------------------------- | ------------------------- |
    | Location                                       | **Global**                |
    | MCP server name                                | `cpln`                    |
    | MCP server type                                | **Remote**                |
    | MCP server URL                                 | `https://mcp.cpln.io/mcp` |
    | Does this server require OAuth authentication? | **Yes**                   |
    | Do you have a pre-registered client ID?        | **No**                    |

    <Note>
      Connecting to the bare URL uses the default **`core`** toolset profile — a focused set that already covers the whole build-and-operate workflow (it can read and delete any resource kind generically, and reach anything else through the raw-API tool), which is the right fit for this client. Append `?toolsets=mk8s` to add BYOK Kubernetes tools, or `?toolsets=full` for everything. See [toolset profiles](/ai/mcp#toolset-profiles).
    </Note>

    OpenCode writes the entry to `~/.config/opencode/opencode.jsonc`.
  </Step>

  <Step title="Authenticate">
    ```bash theme={null}
    opencode mcp auth cpln
    ```

    Your browser opens:

    1. Sign in to Control Plane (Google, GitHub, Microsoft, or SAML).
    2. Select the orgs you want OpenCode to access.
    3. Click **Authorize**.

    Your browser shows a success page — close the tab and return to the terminal. OpenCode prints **Authentication successful!**.
  </Step>

  <Step title="Use it">
    Launch OpenCode and ask "list GVCs in org `<your-org>`" (using one of the orgs you authorized) to confirm.
  </Step>
</Steps>

## Example conversation

<Steps>
  <Step title="Set Context">
    ```
    Use org "my-org" and gvc "my-gvc" for context.
    ```
  </Step>

  <Step title="Deploy a Workload">
    ```
    Create a publicly accessible workload called "my-api" using nginx:latest on port 80.
    ```
  </Step>

  <Step title="Get the Endpoint">
    ```
    Monitor the readiness of my-api and give me the public endpoint once it's ready.
    ```
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Need to change which orgs are authorized">
    Re-run `opencode mcp auth cpln`. Sign in again and adjust your org selections on the consent screen.
  </Accordion>
</AccordionGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Usage Examples" icon="lightbulb" href="/ai/examples">
    Practical prompts for common Control Plane workflows
  </Card>

  <Card title="Template Catalog" icon="grid" href="/template-catalog/overview">
    30+ production-ready templates your AI can deploy on request
  </Card>
</CardGroup>
