Connect Langfuse to Claude Code

Read LLM traces, scores, prompts and datasets, and score or label them, in Langfuse Cloud or a self-hosted Langfuse. Add Toolspoke to Claude Code once and it can use 16 Langfuse actions. Your Langfuse credential stays in Toolspoke, and you choose which actions Claude Code may call.

Set it up in Claude Code

Three steps, the first one once for every toolkit you will ever add.

  1. Add Toolspoke to Claude Code

    Run it in your project, then /mcp to sign in

    claude mcp add --transport http toolspoke https://toolspoke.com/mcp

    The sign-in opens in your browser, and Toolspoke asks you to approve it.

  2. Install Langfuse and connect it

    Add Langfuse to a project in your Toolspoke workspace.

    Public and secret key. You provide it once, when you install the connector. Toolspoke encrypts it at rest and decrypts it only for the length of a single call, and the gateway attaches it to the outbound request itself, so it is never part of the arguments an agent sends.

    Public key and secret key
    Langfuse → your project → Settings → API Keys → Create new API keys. Paste the public key, a colon, then the secret key, with no spaces. A key pair reaches exactly one project.
  3. Choose what Claude Code may do

    All 16 actions start on. Switch off any of the 6 actions that change something in Langfuse, and Claude Code gets a refusal if it tries.

What you can ask Claude Code for

A few of the Langfuse actions that only read, so they are safe to try first.

  • Return the project this key pair belongs to, with its id, name and retention
  • List prompts in the project by name, with their versions, labels and tags
  • Fetch one prompt's text or chat messages and its config
  • List the datasets in the project, used for experiments and evaluations

What Claude Code can do in Langfuse

10 actions read, 4 write and 2 delete or permanently change something.

Reads

  • List projects

    Return the project this key pair belongs to, with its id, name and retention. Takes no arguments, and it fails when the keys are wrong or the host is the wrong region, which is why an install tests itself with it.

  • List observations

    List observations (spans, generations, events, tool calls) newest first, filtered by trace, session, user, name, type or level and a start-time window. This is how to read a trace: pass trace_id. Cursor-paginated; pass the returned cursor to get the next page. The io field group returns prompts and completions, which are your users' content.

  • Query metrics

    Aggregate observations or scores: counts, latency, token use and cost, grouped by dimensions and optionally bucketed over time. Real-time. Example: view observations, dimensions [{"field":"name"}], metrics [{"measure":"totalCost","aggregation":"sum"}]. High-cardinality dimensions such as ids are refused with a 400.

  • List scores

    List scores (evaluations, user feedback, annotations) newest first, filtered by name, source, trace, session or time. Cursor-paginated. Add fields=details for comments and metadata.

  • List prompts

    List prompts in the project by name, with their versions, labels and tags. Filter by name, label (e.g. production) or tag.

  • Get prompt

    Fetch one prompt's text or chat messages and its config. Without version or label you get the version labelled production.

  • List datasets

    List the datasets in the project, used for experiments and evaluations.

  • Get dataset

    Fetch one dataset by name, with its description and metadata.

  • List dataset items

    List the items in a dataset, inputs and expected outputs, often copied from production traces.

  • List comments

    List comments people left on traces, observations, sessions or prompts. Filter by object to read the discussion on one trace.

Writes

  • Create score

    Attach a score to a trace, observation or session, an evaluation result, a label, or a user's thumbs up. Supply the trace_id (plus observation_id to score one step) or a session_id. The score appears in the API after a short delay.

  • Create text prompt

    Create a text prompt, or a new version of one if the name exists. Versions are immutable and old ones stay, so this is not destructive. Be careful with labels: putting production on the new version makes every application that fetches the production label serve it.

  • Update prompt labels

    Set the labels on one prompt version. This is how a version is promoted (add production) or rolled back (move production to an older version). It changes what applications serve at once, but the previous state can be restored with another call.

  • Create dataset item

    Add an item to a dataset, or replace one by passing its id. Link it to the trace it came from with source_trace_id.

Deletes or permanently changes

  • Delete score

    Delete one score permanently. There is no undo, and evaluation dashboards built on it change.

  • Delete trace

    Delete one trace and its observations and scores permanently. Use it to remove data that should never have been logged. There is no undo.

Langfuse in Claude Code: questions

Does Claude Code see my Langfuse credential?

No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. Claude Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.

Can I stop Claude Code from changing things in Langfuse?

Yes. Each of the 16 actions can be switched off for a project. Turn off the 6 that change something and Claude Code can only read.

Will 16 actions crowd Claude Code's context?

No. Toolspoke shows Claude Code five bridge tools, plus a guide where a toolkit has one, and Claude Code searches for the Langfuse action it needs when it needs it. Adding more toolkits does not add more tools to its list.

Can I add it once for every project?

Yes. Add --scope user to the command and Claude Code keeps Toolspoke in every project on this machine. Without it, the server is added to the project you ran the command in.

What does it cost?

Tool calls are free on every plan, and a Langfuse call does not run in a sandbox, so it bills nothing.

Try Langfuse in Claude Code

Free to start, and tool calls cost nothing on any plan.