langfuse-mcp
langfuse-mcp
An MCP server that exposes the Langfuse REST API as tools, so Claude (or any MCP client) can query your traces, observations, sessions, scores, prompts, datasets, and metrics during a conversation.
Useful when you want to ask things like:
"Why did trace
abc123fail? Walk me through its observations.""List the 5 most recent traces with
level=ERRORfor useralice@x.com.""Summarize today's generation cost broken down by model."
"Show me the production version of prompt
customer-support-v2."
…without leaving your assistant.
Requirements
Node.js 20 or newer (
node --version).A Langfuse project with API keys (cloud.langfuse.com → Settings → API Keys on EU cloud, us.cloud.langfuse.com on US cloud, or your self-hosted instance).
Related MCP server: langfuse-mcp
Tools
All tools are read-only and call the Langfuse Public API over HTTPS using your project keys for Basic Auth.
Traces & observations
Tool | Description |
| List traces with filters. Returns summary metadata. |
| Fetch a single trace by id including the full observation tree. |
| List spans, generations, and events with filters. |
| Fetch a single observation by id. |
Sessions
Tool | Description |
| List sessions within a time range. |
| Fetch a session by id, including its traces. |
Scores
Tool | Description |
| List scores with filters. |
| Fetch a single score by id. |
| List score configurations (definitions, ranges, categories). |
| Fetch a score configuration by id. |
Prompts
Tool | Description |
| List prompt definitions, optionally filtered by name, label, or tag. |
| Fetch a prompt by name, optionally pinned to a specific version or label. |
Datasets
Tool | Description |
| List datasets configured in Langfuse. |
| Fetch a dataset by name. |
| List items in a dataset (inputs, expected outputs, metadata). |
| Fetch a single dataset item by id. |
| List evaluation runs for a dataset. |
| Fetch a specific dataset run by name. |
Metrics, models & misc
Tool | Description |
| Run a custom metrics query (counts, latency, cost, token usage). Pass a JSON query string. |
| Daily aggregated usage / cost / count metrics. |
| List models known to Langfuse (for cost / token attribution). |
| Fetch a model definition by id. |
| List projects accessible to the current API key. |
| List comments attached to traces, observations, sessions, or prompts. |
| Fetch a single comment by id. |
| Fetch metadata for a media attachment (image, audio, file). |
| Ping the Langfuse public health endpoint — useful for credential validation. |
Install
Zero install with npx:
npx -y langfuse-mcpOr install globally:
npm i -g langfuse-mcp
langfuse-mcp --versionConfiguration
The server reads three environment variables:
Variable | Required | Description |
| yes | Project public key ( |
| yes | Project secret key ( |
| yes | e.g. |
| no | Optional path to a |
Where do I get my keys? In the Langfuse UI: Settings → API Keys → Create new API keys. Keys are scoped to a single project and a single region (EU vs US are separate accounts — match your
LANGFUSE_BASE_URLto the region you created the keys in).
If a .env file exists in the working directory it will be loaded automatically. See .env.example for a starter file.
Use with Claude Desktop
Edit claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"langfuse": {
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
}
}Restart Claude Desktop after editing. The MCP server icon should appear in the chat input.
Use with Claude Code
Project-level (./.mcp.json):
{
"mcpServers": {
"langfuse": {
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
}
}User-level config lives at ~/.claude.json and uses the same shape.
Use with Cursor
Project-level: .cursor/mcp.json. User-level: ~/.cursor/mcp.json.
{
"mcpServers": {
"langfuse": {
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
}
}Use with Cline (VS Code)
In VS Code settings (settings.json):
{
"cline.mcpServers": {
"langfuse": {
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
}
}Use with Continue
In ~/.continue/config.json:
{
"mcpServers": [
{
"name": "langfuse",
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
]
}Use with Windsurf
In Windsurf's MCP settings, add:
{
"mcpServers": {
"langfuse": {
"command": "npx",
"args": ["-y", "langfuse-mcp"],
"env": {
"LANGFUSE_PUBLIC_KEY": "pk-lf-…",
"LANGFUSE_SECRET_KEY": "sk-lf-…",
"LANGFUSE_BASE_URL": "https://cloud.langfuse.com"
}
}
}
}Use with any other MCP client
The server speaks MCP over stdio. Any MCP client can launch it as a subprocess:
LANGFUSE_PUBLIC_KEY=pk-lf-… \
LANGFUSE_SECRET_KEY=sk-lf-… \
LANGFUSE_BASE_URL=https://cloud.langfuse.com \
npx -y langfuse-mcpTry it
Once wired up, ask your assistant things like:
"Use the
getHealthtool to confirm langfuse-mcp is connected.""List the 5 most recent traces with
level=ERROR.""Show me trace
abc123with all its observations.""What scores did user
alice@example.comreceive this week?""Get the production version of prompt
customer-support.""List dataset runs for
eval-2026-q1and tell me which one had the highest accuracy score."
Troubleshooting
401 Unauthorized on the first call
Wrong region: Langfuse Cloud EU and US are separate accounts. Make sure
LANGFUSE_BASE_URLmatches the region where you created the keys (https://cloud.langfuse.comfor EU,https://us.cloud.langfuse.comfor US).Quoted keys in
.env: this server strips surrounding quotes, but a stray space can still break Basic Auth. Re-paste the key.Use
getHealthfirst to confirm credentials before running other tools.
npx keeps using an old version
npx -y langfuse-mcp@latestnpx caches packages aggressively. The @latest suffix forces a refresh.
LANGFUSE_BASE_URL must be a full URL error
The most common cause is a missing scheme. Use https://cloud.langfuse.com, not cloud.langfuse.com.
Self-hosted Langfuse
Use the full base URL of your deployment without a trailing slash or path. Example: https://langfuse.mycompany.internal. The server normalizes a single trailing slash, but anything else (/api, /public) will break path joining.
MCP server icon doesn't appear in Claude Desktop
Check the Claude Desktop log:
~/Library/Logs/Claude/mcp*.log(macOS) or%APPDATA%\Claude\Logs\(Windows). The server writes alangfuse-mcp v… connectedline to stderr on success.Make sure Node 20+ is on your PATH (Claude Desktop uses your login shell PATH).
Quit Claude Desktop fully (not just close the window) and relaunch.
Cryptic ERR_REQUIRE_ESM / Unexpected token on startup
Your Node version is too old. This package requires Node ≥ 20. Run node --version and upgrade if needed (e.g. via nvm).
Development
git clone https://github.com/hugoles/langfuse-mcp.git
cd langfuse-mcp
npm install
cp .env.example .env # macOS/Linux
copy .env.example .env # Windows cmd
npm run dev # tsx src/index.ts (no build step)Other scripts:
Script | What it does |
| Compile TypeScript to |
| Run the built server. |
|
|
| ESLint. |
| Prettier write / check. |
| Vitest. |
Contributing
See CONTRIBUTING.md. Bug reports and PRs are welcome — please run npm run typecheck && npm run lint && npm test locally before opening one.
Security
Found a vulnerability? Please report it privately as described in SECURITY.md. Do not open a public issue.
License
MIT © Hugoles.
Available Tools
27 toolsgetCommentGet a comment by idA
Fetch a single comment by id.
Inputs: commentId (required).
getDailyMetricsGet daily metrics summaryC
Fetch daily aggregated usage / cost / count metrics for traces and observations.
Inputs: page, limit, traceName, userId, +4 more.
getDatasetGet a dataset by nameC
Fetch metadata for a dataset by its name.
Inputs: datasetName (required).
getDatasetItemGet a dataset item by idC
Fetch a single dataset item by id.
Inputs: itemId (required).
getDatasetRunGet a dataset runB
Fetch a specific dataset run by name.
Inputs: datasetName (required), runName (required).
getHealthCheck Langfuse API healthA
Pings the Langfuse public health endpoint. Useful to validate credentials and connectivity.
Inputs: no named parameters.
getMediaGet a media attachment metadataC
Fetch metadata for a media attachment (image, audio, file) by id.
Inputs: mediaId (required).
getMetricsQuery Langfuse metricsC
Run a metrics query (counts, latency, cost, token usage). Pass a JSON query string per the Langfuse metrics API.
Inputs: query (required).
getModelGet a model by idB
Fetch a single model definition by id.
Inputs: modelId (required).
getObservationGet observation by idA
Fetch a single observation by id.
Inputs: observationId (required).
getPromptGet a prompt (optionally a specific version or label)A
Fetch a prompt by name. Optionally pin to a specific version or label (e.g. 'production').
Inputs: promptName (required), version, label.
getScoreGet a single score by idC
Fetch a single score by id.
Inputs: scoreId (required).
getScoreConfigGet a score configuration by idC
Fetch a single score configuration by id.
Inputs: configId (required).
getSessionGet session with its tracesA
Fetch a session by id, including its traces.
Inputs: sessionId (required).
getTraceGet trace with full observation treeB
Fetch a single trace by id including all nested observations.
Inputs: traceId (required).
listCommentsList commentsC
List comments attached to traces, observations, sessions, or prompts.
Inputs: page, limit, objectType, objectId, +1 more.
listDatasetItemsList dataset itemsC
List items in a dataset (inputs / expected outputs / metadata).
Inputs: page, limit, datasetName, sourceTraceId, +1 more.
listDatasetRunsList dataset runsC
List runs (evaluation rounds) for a dataset.
Inputs: datasetName (required), page, limit.
listDatasetsList datasetsB
List datasets configured in Langfuse.
Inputs: page, limit.
listModelsList modelsB
List models known to Langfuse (for cost / token attribution).
Inputs: page, limit.
listObservationsList observationsC
List observations (spans, generations, events) with filters.
Inputs: page, limit, traceId, name, +7 more.
listProjectsList projectsA
List projects accessible to the current API key (typically a single project).
Inputs: no named parameters.
listPromptsList promptsB
List prompt definitions tracked in Langfuse.
Inputs: page, limit, name, label, +1 more.
listScoreConfigsList score configurationsB
List score configurations (definitions for score names, ranges, and categories).
Inputs: page, limit.
listScoresList scoresC
List scores with filters.
Inputs: page, limit, userId, name, +3 more.
listSessionsList sessionsC
List sessions within a time range.
Inputs: page, limit, fromTimestamp, toTimestamp, +1 more.
listTracesList tracesA
List Langfuse traces with filters. Returns summary metadata (use getTrace for the full observation tree).
Inputs: page, limit, fromTimestamp, toTimestamp, +6 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 27 tools
Each tool targets a distinct resource or operation (e.g., getComment vs. listComments, getMetrics vs. getDailyMetrics). The 'get' vs 'list' prefix clearly differentiates single-item retrieval from multi-item listing. There is no meaningful overlap.
All tools follow a consistent camelCase verb_noun pattern (e.g., getComment, listDatasets). The verbs are limited to 'get' and 'list', making the naming predictable and easy to understand.
27 tools is on the higher side but still reasonable for a platform like Langfuse, which exposes many entity types (traces, observations, datasets, prompts, etc.). The count is not excessive and each tool serves a clear purpose.
The server is entirely read-only; there are no tools for creating, updating, or deleting resources. This is a significant gap for a full-featured MCP server, as agents cannot perform mutations that are likely needed in many workflows.
Maintenance
Related MCP Connectors
MCP observability. Query live traffic, errors, duration, and alerts from your AI agent.
LLM Orchestration Agent (Mcp)
An MCP connector that lets your AI agents ask you questions, request permission approvals, and send alerts as push notifications to your phone and mac notch, so you can unblock and approve your agents from anywhere.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- AlicenseCqualityDmaintenanceAn MCP server implementation that integrates AI assistants with Langfuse workspaces, allowing models to query LLM metrics by time range.110 npm3Apache 2.0
- AlicenseCqualityAmaintenanceMCP server for Langfuse observability. Query traces, debug exceptions, analyze sessions, and manage prompts and datasets for your LLM applications.483,201 PyPI112MIT
- AlicenseAqualityCmaintenanceComprehensive MCP server for Langfuse, enabling AI assistants to access and manage traces, observations, scores, datasets, and sessions for observability.2415 npm1MIT
- AlicenseAqualityDmaintenanceTypeScript MCP server that enables AI agents to manage LangSmith traces, prompts, datasets, experiments, and billing through natural language.15729 npm17MIT