> ## 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.

# Use Contexity with Codex via MCP Server Integration

> Connect Contexity to Codex through MCP so Codex retrieves bounded context, maps impact, and captures external sources automatically during every task.

Contexity integrates with Codex through an MCP server. Once configured, Codex calls Contexity tools automatically at each stage of a task — you don't need to type Contexity commands during normal work. The integration keeps context bounded, relevant, and traceable without adding friction to your workflow.

## Install the Host Config

Run the following steps to register Contexity as an MCP server inside Codex.

<Steps>
  <Step title="Preview the config (dry run)">
    Run the installer with `--dry-run` to see exactly what changes will be written before committing anything:

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

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

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

  <Step title="Verify the setup">
    Run the doctor command to confirm that Codex and the MCP server are correctly connected:

    ```bash theme={null}
    contexity --project /path/to/project doctor
    ```
  </Step>
</Steps>

<Tip>
  If Codex is not calling Contexity tools, check the host status with `contexity --project /path/to/project host status` and reinstall the config.
</Tip>

## Expected Codex Behavior

After setup, Codex should automatically call the following MCP tools at each stage of a task:

| Tool                     | When Codex calls it            |
| ------------------------ | ------------------------------ |
| `context_start_run`      | At the beginning of every task |
| `context_retrieve_pack`  | Before making any edits        |
| `context_search_project` | Before broad repo exploration  |
| `context_impact`         | Before edits to known files    |
| `context_detect_changes` | After every meaningful edit    |
| `context_close_run`      | At task closeout               |

When metrics display is enabled, Codex also shows the heuristic value summary after relevant tool calls. You can control this behavior — see [Manage Metrics Display](/guides/manage-metrics).

## Capturing External Sources

When you share a Slack update, issue comment, repository link, docs link, or inspiration link with Codex, Codex should call `context_capture_external_reference` — not paste the raw external content into model instructions.

The call should include:

* **Source locator** — the URL or identifier pointing to the original source
* **Source type** — for example, `slack_thread`, `github_issue`, or `docs_link`
* **Short reason or summary** — why this source matters for the current task
* **Extracted signals** — structured takeaways with stable signal keys
* **Trust state hints** — when you can indicate the reliability of the source

This ensures external information is stored as traceable, structured references rather than unverified text injected directly into the agent's context.
