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

# Claude Code

> Set up and use the OpenCX MCP server in Claude Code — CLI commands, environment variables, scope, and automation.

Claude Code manages <Tooltip tip="An open standard that lets AI assistants interact with external tools and data sources.">MCP</Tooltip> servers through CLI commands instead of JSON config files. Servers can be scoped globally (all projects) or per-project.

## Setup

<Steps>
  <Step title="Set your API key">
    Add your [OpenCX API key](https://platform.open.cx/settings/access) to your shell profile so it persists across sessions:

    <Tabs>
      <Tab title="zsh (macOS)">
        ```bash theme={"dark"}
        echo 'export OPENCX_API_KEY="your-api-key-here"' >> ~/.zshrc
        source ~/.zshrc
        ```
      </Tab>

      <Tab title="bash (Linux)">
        ```bash theme={"dark"}
        echo 'export OPENCX_API_KEY="your-api-key-here"' >> ~/.bashrc
        source ~/.bashrc
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Add the MCP server">
    ```bash theme={"dark"}
    claude mcp add opencx -- npx -y @opencx/mcp
    ```

    This registers the server at user scope (available in all projects) by default.

    <Tip>
      Prefer zero install? Connect to the [hosted endpoint](/mcp/install#remote-server-no-install) instead — same tools, nothing to keep updated:

      ```bash theme={"dark"}
      claude mcp add --transport http opencx https://api.open.cx/mcp \
        --header "Authorization: Bearer $OPENCX_API_KEY"
      ```
    </Tip>
  </Step>

  <Step title="Verify">
    Start Claude Code and ask: *"List my recent chat sessions."*

    You can also confirm the server is registered:

    ```bash theme={"dark"}
    claude mcp list
    ```
  </Step>
</Steps>

## Scope

Claude Code supports two scopes for MCP servers:

| Scope              | Flag              | Stored in                | Shared with team      |
| ------------------ | ----------------- | ------------------------ | --------------------- |
| **User** (default) | `--scope user`    | `~/.claude/`             | No                    |
| **Project**        | `--scope project` | `.mcp.json` in repo root | Yes (commit the file) |

Add at project scope when your team should share the same MCP setup:

```bash theme={"dark"}
claude mcp add opencx --scope project -- npx -y @opencx/mcp
```

<Note>
  Project-scoped servers read environment variables from the shell of whoever
  runs Claude Code. Each team member sets `OPENCX_API_KEY` in their own shell
  profile.
</Note>

## Managing Servers

```bash theme={"dark"}
claude mcp list                    # List all registered servers
claude mcp remove opencx           # Remove the server
claude mcp add opencx -- npx -y @opencx/mcp  # Re-add after removal
```

## CI and Automation

Claude Code can use MCP servers in non-interactive contexts. Pass the API key through CI secrets:

```bash theme={"dark"}
OPENCX_API_KEY=${{ secrets.OPENCX_API_KEY }} claude --print "List unresolved sessions from the last 24 hours"
```

For headless use, Claude Code's `--print` flag outputs the response to stdout without an interactive session.

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Claude Desktop" icon="message-bot" href="/mcp/clients/claude-desktop">
    JSON config and app restart flow
  </Card>

  <Card title="Get Started" icon="download" href="/mcp/install">
    API key setup and all client configs
  </Card>

  <Card title="Prompt Library" icon="message" href="/mcp/prompts">
    Ready-to-use prompts by domain
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/mcp/troubleshooting">
    Common issues and fixes
  </Card>
</CardGroup>
