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

# OpenCode

> Connect Corsair to OpenCode via MCP, or use the Corsair CLI directly.

<Tabs>
  <Tab title="MCP">
    Use `runStdioMcpServer` to expose Corsair as a local MCP server that OpenCode spawns on demand.

    ## Install

    ```bash theme={null}
    npm install @corsair-dev/mcp
    ```

    ## Create the server script

    ```ts mcp-server.ts theme={null}
    import 'dotenv/config';
    import { runStdioMcpServer } from '@corsair-dev/mcp';
    import { corsair } from './corsair';

    runStdioMcpServer({ corsair }).catch((err) => {
        console.error('[corsair-mcp] Fatal:', err);
        process.exit(1);
    });
    ```

    ## Configure OpenCode

    Add a local MCP server to your `opencode.json`. OpenCode reads it when you open the project.

    ```json opencode.json theme={null}
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "corsair": {
          "type": "local",
          "command": ["npx", "tsx", "mcp-server.ts"],
          "enabled": true
        }
      }
    }
    ```

    If your credentials aren't loaded from a `.env` file, pass them under `environment`:

    ```json opencode.json theme={null}
    {
      "mcp": {
        "corsair": {
          "type": "local",
          "command": ["npx", "tsx", "mcp-server.ts"],
          "enabled": true,
          "environment": {
            "CORSAIR_KEK": "your-key-here"
          }
        }
      }
    }
    ```

    Restart OpenCode after editing the config so it picks up the new server.

    ## Usage

    Once connected, OpenCode can call Corsair tools directly:

    ```
    Setup corsair, then list all Slack channels.
    ```

    OpenCode calls `list_operations` to discover available endpoints, `get_schema` to inspect parameters, then `run_script` to execute.
  </Tab>

  <Tab title="CLI">
    <CodeGroup>
      ```bash npm theme={null}
      npm install @corsair-dev/cli
      ```

      ```bash yarn theme={null}
      yarn add @corsair-dev/cli
      ```

      ```bash pnpm theme={null}
      pnpm install @corsair-dev/cli
      ```

      ```bash bun theme={null}
      bun add @corsair-dev/cli
      ```
    </CodeGroup>

    Copy and paste this prompt into OpenCode to give it everything it needs to work with Corsair:

    ```
    Run `pnpm corsair` to access Corsair's integrations.
    ```
  </Tab>
</Tabs>
