SuperAPI AI Directory

langfuse-mcp

Query Langfuse traces, debug exceptions, analyze sessions and manage prompts for LLM applications.

Open website

About this tool

Purpose

langfuse-mcp is a local Model Context Protocol (MCP) server for Langfuse, bundled with a first-party langfuse skill. It enables AI agents to query Langfuse trace data, thereby enhancing debugging and observability capabilities. The official documentation states: use langfuse-mcp for local debugging scenarios, and use the official Langfuse MCP for hosted, zero-install scenarios covering a broader API (score writes, comments, models, media, etc.). As of June 2026, the positioning is "langfuse-mcp for local debugging, native MCP for hosted breadth."

Main capabilities

  • Debug traces, sessions, and exceptions, usable from Claude Code, Codex, Cursor, or any MCP client.
  • Provides route-decision tools and compact / file-dump output.
  • Provides a total of 48 tools, grouped into: traces, observations, routing, sessions, exceptions, prompts, datasets, annotation_queues, scores, metrics, schema.
  • The exceptions tool detects errors via observation level == "ERROR" (strict determination; a non-empty status_message alone does not count). find_exceptions returns {group, count, observation_id, trace_id} (up to 50 groups), each group with a representative observation/trace ID; find_exceptions_in_file also produces full error records. The count describes error-level observations, not individual exception events, so get_error_count returns exception_count: null. Exception details come from the recorded metadata (exception.type / exception.message / exception.stacktrace, located at the top level or under metadata.attributes), with missing values as null. Results are not point-in-time snapshots.
  • Metrics queries: query_metrics aggregates telemetry data server-side (cost, latency, tokens, counts, score values), and can answer questions such as "how much did inference cost" and "what is the p95 latency by model" without pulling raw traces. Call get_metrics_schema to get the complete view/dimension/measure catalog. High-cardinality fields (id, traceId, userId, sessionId) must be used in filters, not as dimensions. The v2 metrics endpoint is limited to Langfuse Cloud; self-hosted instances may return 404.
  • Dataset item updates use upsert: to edit an existing item, call create_dataset_item and pass item_id; if the ID exists it is updated, otherwise a new one is created.
  • Dataset run reads use the experiments API when the installed Langfuse SDK exposes it (Python SDK 4.13.1+); the legacy route serves as a fallback for self-hosted servers. delete_dataset_run uses the legacy delete route when available; after that route is removed, the run's traces are deleted only when delete_traces=True is passed. Deleting traces also removes observations and related scores. create_dataset_run_item still uses the legacy linking API; after that API disappears, experiment data must be created via the SDK experiment runner or OTel ingestion.
  • On the Observations API v2, traces are built from root observations. fetch_traces omits traces without a root observation, and fetch_trace cannot find traces without any observations.

Usage

Install: uvx langfuse-mcp, and configure the Langfuse API key. Requires uv (for uvx) and Python 3.10 or newer; CI verifies Python 3.10 through 3.14. Obtain credentials from Langfuse Cloud → Settings → API Keys; for self-hosting, use the instance URL as LANGFUSE_HOST. To explicitly pin the interpreter verified in CI, you can prepend --python 3.14 before langfuse-mcp. After restarting the CLI, verify with /mcp (Claude Code) or codex mcp list (Codex).

Selective tool loading: load only the tool groups you need to reduce token overhead. Available groups: traces, observations, routing, sessions, exceptions, prompts, datasets, annotation_queues, scores, metrics, schema. The routing group is unrelated to routers; it reads Langfuse span observations with metadata.schema_version: "mcp.route_decision.v1" and filters by the routing decision fields in the observation metadata (such as decision_id, router_name, provider, capability_id).

Read-only mode: all write operations can be disabled for safer read-only access. Disabled operations include: create_text_prompt, create_chat_prompt, update_prompt_labels, create_dataset, create_dataset_item, delete_dataset_item, create_dataset_run_item, delete_dataset_run, create_annotation_queue, create_annotation_queue_item, update_annotation_queue_item, delete_annotation_queue_item, create_annotation_queue_assignment, delete_annotation_queue_assignment.

Default output mode: you can set the default output_mode exposed by MCP so that clients that omit this parameter automaticallyuse the preferred mode. Supported values: compact, full_json_string, full_json_file. This updates the default value shown in the MCP tool schema, and clients can still explicitly pass output_mode in a single call to override it.

Cursor configuration: create .cursor/mcp.json in the project (or globally at ~/.cursor/mcp.json). Docker (single project) and multi-project profiles (stdio) are also supported.

Multi-project profiles: local clients (Claude Code, Codex, Cursor) can put each Langfuse project's credentials in a profiles file and register one MCP server per project, with each server started with --profile <name>. The file is TOML, located at $XDG_CONFIG_HOME/langfuse-mcp/profiles.toml (or ~/.config/langfuse-mcp/profiles.toml when XDG_CONFIG_HOME is not set). You can use --profiles-file PATH or LANGFUSE_MCP_PROFILES_FILE to read another file. public_key, secret_key, and host each take a literal value, or a <field>_env key (naming the environment variable that stores that value). host defaults to https://cloud.langfuse.com。优先级:CLI Precedence (--public-key, --secret-key, --host) > environment variables (LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST) > selected profile > defaults. When environment variables override profile values, the server logs a warning. An unknown profile name or a missing profiles file stops the server with an error that indicates the file and the available profiles. When --profile is not given, LANGFUSE_MCP_PROFILE selects the profile.

HTTP transport (multi-project shared server): run a persistent server instance that routes each MCP client to its own Langfuse project by passing credentials in the Authorization header. Security note: --bind-host 0.0.0.0 exposes the port on all interfaces. In production, the server should be placed behind a reverse proxy that terminates TLS (nginx, Caddy, Cloudflare Tunnel) and enforces HTTPS. The Authorization header containing secrets is transmitted in plaintext over plain HTTP. If startup credentials are set, the proxy must enforce authentication; otherwise, unauthenticated callers without an Authorization header can use the default project. For shared public HTTP deployments, omit the default LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY credentials unless the front proxy authenticates every request. Each project is registered separately in the MCP client, passing its credentials as a Basic authentication header (base64(public_key:secret_key)). Authentication semantics: Basic here carries the Langfuse API key, not a user password. When the header is missing, it falls back to the startup environment credentials (LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY). Any malformed header is rejected outright—there is no silent fallback to another project.

Companion skill: the repository ships a first-party langfuse skill for Claude Code and Codex, giving agents concrete playbooks for trace debugging, exception triage, latency analysis, prompt management, and dataset work.Installation via skills is recommended, but manual installation is also supported. After installation, agents can know when to use Langfuse and which MCP tools to call first. The MCP server provides tools, and the skill provides agent-oriented workflows. Related files: skills/langfuse/SKILL.md, skills/langfuse/references/setup.md, skills/langfuse/references/tool-reference.md.

When to use

  • Debug traces, sessions, and exceptions of LLM applications locally in MCP clients such as Claude Code, Codex, and Cursor.
  • Quickly locate failed traces (officially described as "see failed traces in 2 minutes").
  • Analyze metrics such as latency, cost, and tokens.
  • Manage prompts, datasets, and annotation queues.
  • Multi-project credential isolation and shared HTTP server deployment.

Limitations

  • Requires uv (for uvx) and Python 3.10+.
  • Exception detection strictly depends on observation level == "ERROR"; the count is the number of error-level observations rather than the number of exception events; results are not point-in-time snapshots.
  • The v2 metrics endpoint is limited to Langfuse Cloud; self-hosted deployments may return 404.
  • On the Observations API v2, traces without a root observation are omitted by fetch_traces, and traces without observations cannot be found by fetch_trace.
  • APIs related to dataset runs have version and fallback limitations, and behavior changes after some legacy routes are removed.
  • Shared HTTP deployments carry risks of plaintext transmission and unauthenticated access, requiring a reverse proxy and authentication protection.
  • Official specific pricing and cost information is not provided.