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

# Connect Contexity to Claude Code Using an MCP Server

> Connect Contexity to Claude Code through MCP. Claude Code starts runs, retrieves context packs, and captures external sources automatically during tasks.

Claude Code can use Contexity through the same MCP server as other agent hosts. Once connected, Claude Code calls context tools automatically at each stage of a task — Contexity is the context layer behind the agent, not a separate chat surface. You keep working with Claude Code exactly as you normally would.

## Install the Host Config

Run the following steps to configure Claude Code to launch the Contexity MCP server.

<Steps>
  <Step title="Preview the config (dry run)">
    Inspect the changes before writing anything:

    ```bash theme={null}
    contexity --project /path/to/project host install claude-code --dry-run
    ```
  </Step>

  <Step title="Apply the config">
    When the preview looks correct, write the configuration:

    ```bash theme={null}
    contexity --project /path/to/project --yes host install claude-code
    ```
  </Step>

  <Step title="Confirm the MCP server command">
    The host install command writes the local config needed for Claude Code to launch the MCP server automatically. The server runs on stdio transport:

    ```bash theme={null}
    contexity --project /path/to/project mcp serve --transport stdio
    ```

    You don't need to run this command manually — Claude Code launches it using the config written in the previous step.
  </Step>
</Steps>

<Tip>
  Restart Claude Code after installing the host config for the MCP server connection to take effect.
</Tip>

## Expected Workflow

Claude Code uses Contexity the same way Codex does. At each stage of a task, it should:

1. **Start a run** — open a task-scoped context session with `context_start_run`
2. **Retrieve a pack** — pull bounded, task-relevant context before making edits
3. **Map impact** — call `context_impact` before touching known files
4. **Detect changes** — record meaningful edits with `context_detect_changes`
5. **Capture useful events** — store external sources, decisions, and signals as structured references
6. **Close the run** — finalize the session and surface metrics with `context_close_run`

## User Experience

You interact with Claude Code exactly as you normally would — through conversation and task requests. Contexity runs in the background, keeping context bounded and traceable without changing how you communicate with the agent.

Contexity does not add a separate interface or require you to switch tools. When metrics display is enabled, you'll see a brief heuristic summary at task closeout. Everything else happens invisibly between Claude Code and the MCP server.
