- Trace Cursor sessions to record session, turn, model call, tool, and subagent spans in Braintrust.
- Connect to Braintrust MCP to work with Braintrust projects, experiments, logs, and other data from Cursor.
bt v0.26.0 or later and supports the Cursor CLI and desktop app on macOS, Linux, and Windows.Trace Cursor sessions
The Braintrust plugin for Cursor usesbt to trace your Cursor agent sessions to Braintrust.
Set up tracing
Install Cursor
Install and authenticate bt
bt CLI quickstart to install bt, authenticate, and set your active context.Enable tracing
- Capture hooks in
~/.cursor/hooks.json. Each hook passes a Cursor event tobt, which traces it. Other hooks in the file are preserved. - Tracing settings in
~/.cursor/braintrust.json, which record whether tracing is enabled and which project receives traces. The file doesn’t store credentials. The settings apply to every Cursor workspace, except in sessions started withbt trace run. - The Braintrust plugin in
~/.cursor/plugins/local/trace-cursor, which adds the Braintrust MCP server. Withbtv0.27.0 or later, the command uses Git to install the latest published version, replacing any earlier version. If Git isn’t on yourPATH, it installs the version bundled withbtand prints a warning.
bt trace enable.Reload Cursor
Log a test trace
What Braintrust traces
Cursor traces in Braintrust include:- Session spans with the session ID, local username, operating system, workspace, Cursor and plugin versions, and Git repository metadata when available.
- Turn spans with prompts, final responses, and token metrics for the turn when Cursor reports them.
- Model call spans with conversation input reconstructed from hook events and Cursor’s transcript, response output, tool calls, and the model when Cursor reports it.
- Tool spans named after Cursor’s tool, with inputs, outputs, errors, and denied approvals, including shell commands, MCP tool calls, and file edits.
- Subagent spans nested under the
Tasktool call that started the subagent, with the subagent’s task as input. - Compaction spans when Cursor requests a context compaction.
null.
Approximate data
- Token usage: Cursor reports it for each turn, not for each model call.
- Model inputs: Reconstructed rather than captured as raw provider requests.
- Model call start times: Estimated.
Common workflows
Use different tracing settings for one session
Use different tracing settings for one session
bt trace run to trace a single Cursor CLI invocation without changing the saved tracing configuration:agent) from the terminal. Set CURSOR_BIN to launch a different executable. The run must be interactive: bt trace run cursor rejects -p and --print, and requires a terminal for input and output, because Cursor’s print mode does not emit the hooks needed for a complete trace.To change the saved destination, profile, or organization, rerun bt trace enable cursor with the corresponding options. Running bt switch does not change the saved tracing configuration.To add root-span metadata, pass --additional-metadata '<JSON>' to bt trace run for one invocation or to bt trace enable for future sessions. Standard session metadata takes precedence when keys conflict.Pass --tag ci --tag release-validation to either command to tag session spans.Trace a saved Cursor session
Trace a saved Cursor session
bt trace import with cursor and the session ID to import a past session, even if tracing was not enabled when it ran. Pass --attach to keep importing new turns from an active session until you press Ctrl-C.Imports contain less information than live tracing. They include conversation text and the final status of the last turn, but not tool activity or token usage. Cursor transcripts have no timestamps, so every imported span uses the transcript file’s last-modified time. Cursor might keep only the latest turn in a transcript.Stop tracing Cursor sessions
Stop tracing Cursor sessions
bt trace disable cursor to remove the plugin, its hook entries in ~/.cursor/hooks.json, and its tracing configuration. Other plugins and hooks, and saved bt profiles and credentials, are preserved. Reload Cursor afterward.Update the tracing plugin
bt uses Git to install the latest published version of the plugin, along with the capture hooks that match your bt version. If Git isn’t on your PATH, it installs the plugin bundled with bt.
Update bt
bt to the latest version and complete the applicable migrations. bt update can also update the Cursor plugin, but run the next step to make sure the plugin and its hooks are current.Update the tracing plugin
bt trace update updates the installed plugin and its hook entries without changing your saved tracing configuration.Reload and verify Cursor
Troubleshooting tracing
First, runbt trace doctor cursor. Then, review the following:
Doctor reports that the capture hooks are missing
Doctor reports that the capture hooks are missing
bt trace doctor cursor reports that the Cursor user capture hooks are missing, run:hooks.json and whether the installed plugin is out of date, not whether Cursor loaded them. It doesn’t report a missing plugin. Tracing doesn’t depend on Cursor loading the plugin, but the Braintrust MCP server does.Traces do not appear after setup
Traces do not appear after setup
bt is on the PATH of the environment that launches Cursor.Run bt trace doctor cursor and confirm that tracing is enabled and routed to the intended project.If authentication succeeds but traces do not appear, confirm that your account has permission to write logs to the selected project.For authentication, tracing destination, or endpoint problems, see bt trace troubleshooting and the CLI migration troubleshooting guide.Tracing failures do not interrupt the Cursor session.Cursor blocks prompts after you install Claude Code tracing
Cursor blocks prompts after you install Claude Code tracing
trace-claude-code earlier than v3.0.4, Cursor runs the imported tracing hooks incorrectly and blocks your prompts. Update the Claude Code plugin to v3.0.4 or later:A temporary tracing run fails to start
A temporary tracing run fails to start
bt trace run cursor requires an interactive terminal. Remove -p or --print from the agent arguments, and run the command from a terminal rather than with redirected input or output.When the Cursor CLI runs non-interactively, such as with -p or --print or from a script, it doesn’t report prompts, responses, or when each turn ends. Braintrust can’t fully trace these runs, even with bt trace enable cursor.Cursor uses an unexpected configuration directory
Cursor uses an unexpected configuration directory
- Hooks:
bt trace enable cursoradds its hook entries tohooks.jsonin the directory set byBRAINTRUST_CURSOR_CONFIG_DIR, thenCURSOR_CONFIG_DIR, or in~/.cursorwhen neither is set. - Plugin: Installed in
trace-cursorunder the directory set byBRAINTRUST_CURSOR_PLUGIN_DIR, or under~/.cursor/plugins/localwhen it isn’t set. - Tracing settings: Saved in the file set by
BRAINTRUST_DAEMON_CONFIG, or in~/.cursor/braintrust.jsonwhen it isn’t set.
BRAINTRUST_DAEMON_CONFIG sets one tracing settings file for every coding agent, not only Cursor. If you set it:- Set it in every environment where you run
btor launch Cursor. Otherwise, Cursor’s hooks look for~/.cursor/braintrust.jsonand don’t trace. - After you run
bt update, runbt trace update cursor. Because every agent shares the settings file,bt updatecan’t tell which agents have tracing enabled, so it doesn’t update their plugins.
Traces use unexpected settings
Traces use unexpected settings
bt trace run take precedence over the saved tracing configuration. For normal sessions, the integration does not use TRACE_TO_BRAINTRUST, BRAINTRUST_PROJECT, or BRAINTRUST_ADDITIONAL_METADATA from the agent’s environment to override the saved tracing settings.For environment variables accepted by the bt commands themselves, see bt trace.Connect to Braintrust MCP
The Braintrust MCP server lets Cursor’s agent query and update Braintrust data. You can connect Cursor to it in two ways:- Braintrust plugin: The plugin adds the server for you and authenticates with a Braintrust API key. It works for organizations on the US data plane.
- Manual configuration: You add the server to Cursor’s MCP configuration yourself. Manual configuration works for organizations on any data plane, including EU and self-hosted, and supports OAuth or an API key.
bt trace enable cursor installed the Braintrust plugin, which includes the MCP server. However, setting up tracing doesn’t authenticate the server, because tracing uses your bt login. To use MCP, follow one of the options below.Use the Braintrust plugin
The Braintrust plugin adds the MCP server and authenticates with a Braintrust API key. It connects tohttps://api.braintrust.dev/mcp, so it works only for organizations on the US data plane. For EU or self-hosted organizations, or to sign in with OAuth, configure the server manually.
Install the plugin
bt trace enable cursor installed the plugin. Check for Braintrust in Cursor’s plugins. If it isn’t there, install it from the Marketplace.To install the plugin from the Cursor Marketplace, use /add-plugin in Cursor and search for Braintrust.Set your API key
Reload Cursor
Configure the server manually
Manual configuration works for organizations on any data plane. It supports OAuth, which signs you in with your own Braintrust account, and API keys, which suit shared or non-interactive setups.- OAuth (recommended)
- API key
Add the server
- Add the Braintrust MCP server for the US data plane
- Add the Braintrust MCP server for the EU data plane
~/.cursor/mcp.jsonmakes the server available in all your projects..cursor/mcp.jsonin a project makes it available only in that project. Cursor adds a project’s server turned off, so turn it on before you use it.
braintrust entry inside the existing mcpServers object. For the EU data plane, use https://api-eu.braintrust.dev/mcp. For a self-hosted deployment, use the MCP URL from Settings > Data plane.Restart Cursor
Sign in to Braintrust
- In the Cursor app: Ask Cursor’s agent to connect to the Braintrust MCP server.
- In the Cursor CLI: Run
agent mcp login braintrust.
Use MCP tools
To verify the connection, ask Cursor's agent to list your recent Braintrust projects. If it can’t connect, see Braintrust MCP troubleshooting. Cursor's agent can query logs, compare experiments, work with datasets, and use other Braintrust tools. For example:- “Show me my recent Braintrust experiments.”
- “Query the last 10 logged requests with errors.”
- “Compare accuracy scores between my two latest experiments.”
Troubleshooting MCP
Next steps
- Learn the CLI: See the full
bt tracereference. - Run evaluations: Follow the evaluation guide.
- Explore MCP tools: See the Braintrust MCP tool reference.
- Browse the source: View the coding-agent plugins repository.