Langfuse Traces for VS CodeInspect LLM traces, spans, token usage and costs from Langfuse directly inside VS Code or Cursor — without switching tabs. Screenshots
Quick start
The first trace panel opens beside your editor; additional sessions open as tabs in the same editor group. Re-opening an already-open session focuses the existing tab instead of creating a new split. Features
Commands
Configuration
RequirementsA running Langfuse instance with API access:
The extension talks directly to the host you configure. With a local instance, data stays on your machine; with cloud Langfuse, requests go to your cloud project. MCP (Cursor)On activation, the extension registers two MCP servers when running in Cursor:
|
| Tool | Description |
|---|---|
get_session_traces |
Fetch all traces and span summaries for a session |
list_recent_sessions |
List recent sessions (newest first) |
get_span_detail |
Full input/output for a single span |
Resource: langfuse://session/{sessionId} — JSON snapshot of a session.
langfuse-traces-panel (HTTP — active viewer)
Interact with open trace panels in the editor:
| Tool | Description |
|---|---|
open_trace_panel |
Open the viewer for a session (optional traceIndex) |
refresh_open_trace |
Refresh data in an open panel |
get_active_panel_state |
Focused trace, expanded spans, last clicked span |
get_active_span_detail |
Full I/O for the span currently viewed |
list_open_trace_panels |
Session IDs of all open panels |
Resource: langfuse://active — JSON snapshot of the active panel session.
Enable both servers under Cursor Settings → MCP. If they do not appear, run Langfuse: Register MCP Server.
Programmatic API (for extension authors)
Host extensions (e.g. a webchat panel) can open traces without user input:
await vscode.commands.executeCommand('langfuse.openTrace', {
sessionId: '<your-langfuse-session-id>',
traceIndex: 2, // optional — 0-based, oldest message first
});
// Background refresh after a new LLM response (no-op if panel is closed)
vscode.commands.executeCommand('langfuse.autoRefreshIfOpen', {
sessionId: '<your-langfuse-session-id>',
});
sessionId must match the Langfuse sessionId field on your traces (Python/JS SDK or OTel session.id attribute).
How it works
- Your backend instruments LLM calls with the Langfuse SDK and sets
sessionIdon each trace. - This extension queries the Langfuse REST API (
GET /api/public/traces?sessionId=…andGET /api/public/traces/{traceId}per trace). - Traces render in a webview panel beside the editor; the sidebar lists recent sessions from
GET /api/public/sessions.
Development
make setup # install deps, compile, run tests
make dev # open Extension Development Host (Cursor or VS Code)
make package # build langfuse-traces.vsix
make install-local # install .vsix in the current editor window
make test # run unit tests
make doctor # diagnostics when the extension does not show up
Override the editor with make dev IDE=code if you prefer VS Code over Cursor.
License
MIT
