Skip to main content
Cursor agent tracing visualization
Cursor is an AI-powered code editor with built-in agent capabilities. With Keywords AI integration, you get hierarchical traces of every agent interaction including thinking blocks, file edits, shell commands, and MCP tool calls.

How It Works

Cursor provides hooks that fire during agent execution. Our integration captures these events in real-time and sends them to Keywords AI as hierarchical traces. The hook captures thinking blocks, file edits, shell commands, and MCP tool calls as child spans under a root agent span.
For details on trace structure and span types, see the Observability Data Model.

Prerequisites

Installation

1. Set Environment Variables

Add these to your shell profile (.bashrc, .zshrc, or PowerShell $PROFILE):

2. Download the Hook Script

Download the hook script to your Cursor hooks directory:

3. Configure Cursor Hooks

Create ~/.cursor/hooks.json with the following configuration:

4. Restart Cursor

Restart Cursor IDE to apply the hooks configuration.

Hooks Reference

Span Types

Trace Fields

Debugging

Check the log file for issues:

Common Issues

Example Output

After setup, you’ll see traces in Keywords AI with full hierarchy:

Source Code

The full source code is available on GitHub: Keywords-AI/keywordsai-example-projects/cursor

References