Trace Cursor conversations, shell commands, MCP tools, and file operations in Arize AX for full observability.Cursor is an AI code editor for agentic software development. The Arize Cursor tracing hooks instrument Cursor hook events and export spans to Arize AX and/or Arize Phoenix. A Cursor conversation maps to a session, and each message turn maps to a trace.
Launch Arize
To get started, sign up for a free Arize account and get your Space ID and API Key:- Log in at app.arize.com
- Click Settings and copy the Space ID
- Open the API Keys tab and create or copy an API key
Install
Add the Cursor tracing hook files from the Arize Cursor repository to your project. If you are starting from thearize-cursor repo, these files are already included. If you are adding tracing to an existing project, make sure your project contains:
.env file in your project root and configure Arize AX:
.cursor/hooks.json will fire automatically.
Verify
Run the smoke test from your project root:Export OK and a span named cursor-arize-ax-smoke-test. After that, use Cursor and open your Arize project to inspect traces.
Observe
Once tracing is enabled, Cursor activity is streamed to Arize AX. You’ll see:- Session grouping by
conversation_idfor each Cursor conversation - Turn traces by
generation_idfor 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
cursor unless you set ARIZE_PROJECT_NAME or reuse PHOENIX_PROJECT.
Hooks Captured
| Hook | Captured Data |
|---|---|
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 |
stop | Stop span and state cleanup for the turn |
beforeTabFileRead | Tab read file span |
afterTabFileEdit | Tab file edit span |
How Shell and MCP Merge Works
Cursor emits separatebefore* and after* hook events for shell commands and MCP tools. The Arize Cursor 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.
Troubleshooting
| Problem | Fix |
|---|---|
| Traces not appearing in Arize AX | Check ARIZE_API_KEY, ARIZE_SPACE_ID, and ARIZE_TRACE_ENABLED=true in your project .env |
| Smoke test says Python dependencies are missing | Run python3 -m venv .cursor/hooks/scripts/.venv && .cursor/hooks/scripts/.venv/bin/pip install -r .cursor/hooks/scripts/requirements.txt |
| Want to verify export before opening Cursor | Run .cursor/hooks/scripts/test_arize_ax.sh from the project root |
| Traces land in the wrong project | Set ARIZE_PROJECT_NAME explicitly |
| Large prompt or tool payloads are truncated | Increase CURSOR_TRACE_MAX_ATTR_CHARS |
| Want verbose logging | Set ARIZE_VERBOSE=true and launch Cursor from a shell so hook stderr is visible |