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

# Cursor

> Trace Cursor IDE and CLI conversations, shell commands, MCP tools, and file operations in Arize AX using the Arize Coding Harness Tracing.

> Trace Cursor IDE and CLI conversations, shell commands, MCP tools, and file operations in Arize AX for full observability.

[Cursor](https://cursor.com/) is an AI code editor for agentic software development. The [Arize Coding Harness Tracing](https://github.com/Arize-ai/coding-harness-tracing) instruments Cursor IDE and CLI hook events and exports [OpenInference](https://github.com/Arize-ai/openinference) spans to Arize AX or Phoenix. A Cursor conversation maps to a session, and each message turn maps to a trace.

## Launch Arize AX

To get started, sign up for a free [Arize AX account](https://app.arize.com/auth/join) and get your Space ID and API Key:

1. Log in at [app.arize.com](https://app.arize.com)
2. Click **Settings** and copy the **Space ID**
3. Open the **API Keys** tab and create or copy an API key

## Install

### Curl installer

**macOS / Linux:**

```bash theme={null}
curl -sSL https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.sh | bash -s -- cursor
```

**Windows (PowerShell):**

```powershell theme={null}
iwr -useb https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.bat -OutFile $env:TEMP\install.bat
& $env:TEMP\install.bat cursor
```

### Local clone

```bash theme={null}
git clone https://github.com/Arize-ai/coding-harness-tracing.git
cd coding-harness-tracing
./install.sh cursor        # macOS / Linux
install.bat cursor         # Windows
```

The installer prompts for your backend (Phoenix or Arize AX) and project name, writes credentials to `~/.arize/harness/config.yaml`, and registers the hooks in `~/.cursor/hooks.json`. Both Cursor IDE and Cursor CLI sessions are instrumented from the same configuration.

## Configuration

Credentials live in `~/.arize/harness/config.yaml`. Environment variables override values in `config.yaml` and can be set in your shell profile so they apply to Cursor IDE and Cursor CLI sessions.

### Phoenix (self-hosted)

```bash theme={null}
export PHOENIX_ENDPOINT="http://localhost:6006"
export ARIZE_PROJECT_NAME="cursor"
export ARIZE_TRACE_ENABLED="true"
```

### Arize AX (cloud)

```bash theme={null}
export ARIZE_API_KEY="<your-api-key>"
export ARIZE_SPACE_ID="<your-space-id>"
export ARIZE_PROJECT_NAME="cursor"
export ARIZE_TRACE_ENABLED="true"
```

### Redaction controls

Each `ARIZE_LOG_*` flag accepts `"true"` or `"false"` and defaults to `"true"`. Set to `"false"` to opt out per category:

```bash theme={null}
export ARIZE_LOG_PROMPTS="false"
export ARIZE_LOG_TOOL_DETAILS="false"
export ARIZE_LOG_TOOL_CONTENT="false"
```

| Flag                     | Redacts                                                             |
| :----------------------- | :------------------------------------------------------------------ |
| `ARIZE_LOG_PROMPTS`      | User prompt and assistant response text                             |
| `ARIZE_LOG_TOOL_DETAILS` | Tool names and arguments                                            |
| `ARIZE_LOG_TOOL_CONTENT` | Tool call output content (shell output, MCP results, file contents) |

## Observe

Once tracing is enabled, Cursor activity is streamed to Arize AX. You'll see:

* **Session grouping** by `conversation_id` for each Cursor conversation
* **Turn traces** by `generation_id` for each message turn
* **User prompt spans** for submitted prompts
* **Agent response spans** with model output
* **Agent thinking spans** when Cursor emits reasoning/thought events
* **Shell spans** with command input and command output merged into a single tool span
* **MCP spans** named `MCP: {tool}` with tool input and result
* **File read and edit spans** for file operations, including tab reads and edits

The default project name is `cursor` unless you set `ARIZE_PROJECT_NAME`.

### Hooks Captured

Cursor IDE fires the full set of hooks. Cursor CLI fires a subset (no prompt/response, MCP, or file-read events).

| Hook                   | IDE | CLI | Captured Data                                            |
| :--------------------- | :-: | :-: | :------------------------------------------------------- |
| `sessionStart`         |  ✓  |  ✓  | Session boundary, state init                             |
| `sessionEnd`           |  ✓  |  ✓  | Session teardown                                         |
| `beforeSubmitPrompt`   |  ✓  |     | User prompt span for the turn root                       |
| `afterAgentResponse`   |  ✓  |     | Agent response text and model metadata                   |
| `afterAgentThought`    |  ✓  |     | Agent thinking output and duration                       |
| `beforeShellExecution` |  ✓  |  ✓  | Shell command state used for merge                       |
| `afterShellExecution`  |  ✓  |  ✓  | One `Shell` span with command, cwd, output, and duration |
| `beforeMCPExecution`   |  ✓  |     | MCP tool state used for merge                            |
| `afterMCPExecution`    |  ✓  |     | One `MCP: {tool}` span with input, result, and duration  |
| `beforeReadFile`       |  ✓  |     | Read file span                                           |
| `afterFileEdit`        |  ✓  |  ✓  | File edit span                                           |
| `beforeTabFileRead`    |  ✓  |     | Tab read file span                                       |
| `afterTabFileEdit`     |  ✓  |     | Tab file edit span                                       |
| `postToolUse`          |  ✓  |  ✓  | Generic tool span for non-shell, non-MCP tools           |
| `stop`                 |  ✓  |  ✓  | Stop span and state cleanup for the turn                 |

## How Shell and MCP Merge Works

Cursor emits separate `before*` and `after*` hook events for shell commands and MCP tools. The Arize AX hooks keep a small disk-backed state entry for the `before` event, then create a single span on the corresponding `after` event. That gives you one span with both the input and the output instead of two partial spans.

On `stop`, the hook handler cleans up any saved state for that turn so the state directory does not keep growing over time.

## Reference

For the full list of environment variables, default file paths, and troubleshooting steps, see the [Cursor tracing README](https://github.com/Arize-ai/coding-harness-tracing/blob/main/tracing/cursor/README.md).

## Fail-Open Behavior

If the tracing hook errors, Cursor continues running. The hook handler always returns the permissive response Cursor expects, so tracing failures do not block the editor or agent workflow.

## Uninstall

```bash theme={null}
curl -sSL https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.sh | bash -s -- uninstall cursor
```

## Resources

<CardGroup>
  <Card icon="github" href="https://github.com/Arize-ai/coding-harness-tracing" title="Arize Coding Harness Tracing" horizontal />

  <Card icon="github" href="https://github.com/Arize-ai/openinference" title="OpenInference" horizontal />

  <Card icon="book-open" href="https://cursor.com/" title="Cursor" horizontal />
</CardGroup>
