langfuse-mcp
The langfuse-mcp server provides a comprehensive observability and management toolkit for Langfuse through the Model Context Protocol, enabling you to query, debug, and manage AI application data.
Core Capabilities:
Trace & Observation Analysis: Fetch and filter traces by age, name, user ID, session ID, tags, and metadata; query observations by type (SPAN, GENERATION, EVENT), name, and associated IDs; retrieve detailed information with flexible output formats (compact, full JSON string, or file)
Session & User Tracking: List sessions within time ranges, get detailed session information with optional full observation data, and retrieve all sessions for specific users
Exception & Error Tracking: Find exceptions grouped by file, function, or type; get detailed exception information for specific files or traces; count traces with errors over time periods
Prompt Management: List and filter prompts by name, label, or tag; fetch prompts with or without resolved dependencies; create new text and chat prompt versions; update labels across versions
Dataset Management: List, create, and manage datasets for evaluation test cases; create/update dataset items with upsert functionality; delete items; filter by source trace or observation ID
Schema Access: Retrieve detailed schema definitions for Langfuse data structures including traces, spans, and events
Configuration & Control: Selective tool loading to reduce token overhead, read-only mode for safe exploration, pagination support across all list operations, and compatibility with Claude Code, Codex CLI, Cursor, and Docker
Langfuse MCP Server
Agent-facing Model Context Protocol server and skill for Langfuse observability.
Use langfuse-mcp from Claude Code, Codex, Cursor, or any MCP client to query traces, inspect generations, debug exceptions, analyze sessions, manage prompts, browse datasets, and understand what your AI agents did in production.
What You Can Do
Debug failing agent runs from Langfuse traces and observations.
Find exceptions, slow generations, high-latency spans, and affected users.
Inspect sessions and user journeys without leaving your agent workflow.
Manage prompt versions, labels, datasets, annotation queues, and scores.
Install the included
langfuseagent skill for ready-made debugging playbooks.
Project Links
Why langfuse-mcp?
Langfuse is where your traces live. langfuse-mcp makes that telemetry directly usable by agents that need to answer questions like "what failed?", "why was this slow?", "which prompt version ran?", or "what happened in this user's session?"
Comparison with official Langfuse MCP (as of Jan 2026):
langfuse-mcp | Official | |
Traces & Observations | Yes | No |
Sessions & Users | Yes | No |
Exception Tracking | Yes | No |
Prompt Management | Yes | Yes |
Dataset Management | Yes | No |
Annotation Queues | Yes | No |
Scores (v2) | Yes | No |
Selective Tool Loading | Yes | No |
This project provides a full observability toolkit — traces, observations, sessions, exceptions, prompts, datasets, annotation queues, and scores — while the official MCP focuses on prompt management.
Quick Start
Requires uv (for uvx) and Python 3.10 or newer. CI verifies Python 3.10 through 3.14.
Get credentials from Langfuse Cloud → Settings → API Keys. If self-hosted, use your instance URL for LANGFUSE_HOST.
# Claude Code (project-scoped, shared via .mcp.json)
claude mcp add \
-e LANGFUSE_PUBLIC_KEY=pk-... \
-e LANGFUSE_SECRET_KEY=sk-... \
-e LANGFUSE_HOST=https://cloud.langfuse.com \
--scope project \
langfuse -- uvx langfuse-mcp
# Codex CLI (user-scoped, stored in ~/.codex/config.toml)
codex mcp add langfuse \
--env LANGFUSE_PUBLIC_KEY=pk-... \
--env LANGFUSE_SECRET_KEY=sk-... \
--env LANGFUSE_HOST=https://cloud.langfuse.com \
-- uvx langfuse-mcpTo pin a CI-verified interpreter explicitly, add --python 3.14 before langfuse-mcp.
Restart your CLI, then verify with /mcp (Claude Code) or codex mcp list (Codex).
Agent Skill
This repo ships a first-party langfuse skill for Claude Code and Codex. The skill gives agents concrete playbooks for trace debugging, exception triage, latency analysis, prompt management, and dataset work.
Install it when you want the agent to know when to reach for Langfuse and which MCP tools to call first.
Via skills (recommended):
npx skills add avivsinai/langfuse-mcp -g -yVia skild:
npx skild install @avivsinai/langfuse -t claude -yManual install:
cp -r skills/langfuse ~/.claude/skills/ # Claude Code
cp -r skills/langfuse ~/.codex/skills/ # Codex CLIAfter installing the skill, try:
help me debug langfuse traces
find exceptions in the last day
why was this user's session slow?The MCP server provides the tools; the skill provides the agent-facing workflow. See skills/langfuse/SKILL.md, skills/langfuse/references/setup.md, and skills/langfuse/references/tool-reference.md.
Tools (37 total)
Category | Tools |
Traces |
|
Observations |
|
Sessions |
|
Exceptions |
|
Prompts |
|
Datasets |
|
Annotation Queues |
|
Scores |
|
Schema |
|
Dataset Item Updates (Upsert)
Langfuse uses upsert for dataset items. To edit an existing item, call create_dataset_item with item_id. If the ID exists, it updates; otherwise it creates a new item.
create_dataset_item(
dataset_name="qa-test-cases",
item_id="item_123",
input={"question": "What is 2+2?"},
expected_output={"answer": "4"}
)Selective Tool Loading
Load only the tool groups you need to reduce token overhead:
langfuse-mcp --tools traces,promptsAvailable groups: traces, observations, sessions, exceptions, prompts, datasets, annotation_queues, scores, schema
Read-Only Mode
Disable all write operations for safer read-only access:
langfuse-mcp --read-only
# Or via environment variable
LANGFUSE_MCP_READ_ONLY=true langfuse-mcpThis disables: create_text_prompt, create_chat_prompt, update_prompt_labels, create_dataset, create_dataset_item, delete_dataset_item, 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
Set the MCP-exposed default output_mode so clients that omit the parameter automatically use your preferred mode:
langfuse-mcp --default-output-mode full_json_file
# Or via environment variable
LANGFUSE_MCP_DEFAULT_OUTPUT_MODE=full_json_file langfuse-mcpSupported values: compact, full_json_string, full_json_file
This updates the default shown in MCP tool schemas. Clients can still override it per call by passing output_mode explicitly.
Other Clients
Cursor
Create .cursor/mcp.json in your project (or ~/.cursor/mcp.json for global):
{
"mcpServers": {
"langfuse": {
"command": "uvx",
"args": ["langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-...",
"LANGFUSE_SECRET_KEY": "sk-...",
"LANGFUSE_HOST": "https://cloud.langfuse.com",
"LANGFUSE_MCP_DEFAULT_OUTPUT_MODE": "full_json_file"
}
}
}
}Docker
docker run --rm -i \
-e LANGFUSE_PUBLIC_KEY=pk-... \
-e LANGFUSE_SECRET_KEY=sk-... \
-e LANGFUSE_HOST=https://cloud.langfuse.com \
ghcr.io/avivsinai/langfuse-mcp:latestOptional environment variables
Variable | Default | Description |
|
| Caps the lookback window for time-based tools ( |
Development
uv venv --python 3.14 .venv && source .venv/bin/activate
uv pip install -e ".[dev]"
pytestLicense
MIT
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/avivsinai/langfuse-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server