langfuse — Claude Code MCP server: what it does, how to install
This MCP server lets an agent inspect Langfuse traces and observations. Use it to debug LLM pipelines and review cost or latency data.
claude mcp add --env LANGFUSE_SECRET_KEY=<LANGFUSE_SECRET_KEY> --env LANGFUSE_PUBLIC_KEY=<LANGFUSE_PUBLIC_KEY> --env LANGFUSE_BASE_URL=<LANGFUSE_BASE_URL> --transport stdio langfuse -- npx -y langfuse-observability-mcp-serverWhat langfuse does
langfuse exposes read-only tools for exploring Langfuse data. An agent can filter traces by name, user, session, tags, time, or environment, then open a trace with its nested observations and scores. Observation searches can narrow results by type, model, or level.
Strings longer than 1000 characters are shortened in the response, while the complete value is saved under /tmp/langfuse_*.txt. The returned path lets an agent search the file with grep instead of loading the whole payload. Setup requires LANGFUSE_SECRET_KEY and LANGFUSE_PUBLIC_KEY; LANGFUSE_BASE_URL can point the server at another API endpoint. Without the two key variables, the connection will not work.
What it helps with
- filter Langfuse traces by user and session
- inspect every observation inside a trace
- compare model usage with cost and latency
- search oversized payloads through
grep
Example prompts for the agent
- Find traces for user
user-123and group the results by session. - Open the complete trace with ID
trace-idand locate the source of its latency. - List
GENERATIONobservations for the selected model and report their costs.
How to install langfuse
Platform CLI
claude mcp add --env LANGFUSE_SECRET_KEY=<LANGFUSE_SECRET_KEY> --env LANGFUSE_PUBLIC_KEY=<LANGFUSE_PUBLIC_KEY> --env LANGFUSE_BASE_URL=<LANGFUSE_BASE_URL> --transport stdio langfuse -- npx -y langfuse-observability-mcp-serverReplace <…> with your own values
Platform CLI
codex mcp add langfuse --env LANGFUSE_SECRET_KEY=<LANGFUSE_SECRET_KEY> --env LANGFUSE_PUBLIC_KEY=<LANGFUSE_PUBLIC_KEY> --env LANGFUSE_BASE_URL=<LANGFUSE_BASE_URL> -- npx -y langfuse-observability-mcp-serverReplace <…> with your own values
Config file
{
"mcpServers": {
"langfuse": {
"command": "npx",
"args": [
"-y",
"langfuse-observability-mcp-server"
],
"env": {
"LANGFUSE_SECRET_KEY": "<LANGFUSE_SECRET_KEY>",
"LANGFUSE_PUBLIC_KEY": "<LANGFUSE_PUBLIC_KEY>",
"LANGFUSE_BASE_URL": "<LANGFUSE_BASE_URL>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"langfuse": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"langfuse-observability-mcp-server"
],
"env": {
"LANGFUSE_SECRET_KEY": "<LANGFUSE_SECRET_KEY>",
"LANGFUSE_PUBLIC_KEY": "<LANGFUSE_PUBLIC_KEY>",
"LANGFUSE_BASE_URL": "<LANGFUSE_BASE_URL>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e LANGFUSE_SECRET_KEY=<LANGFUSE_SECRET_KEY> -e LANGFUSE_PUBLIC_KEY=<LANGFUSE_PUBLIC_KEY> -e LANGFUSE_BASE_URL=<LANGFUSE_BASE_URL> langfuse npx -y langfuse-observability-mcp-serverReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about langfuse
How do I install langfuse in Claude Code?
Run `claude mcp add --env LANGFUSE_SECRET_KEY=<LANGFUSE_SECRET_KEY> --env LANGFUSE_PUBLIC_KEY=<LANGFUSE_PUBLIC_KEY> --env LANGFUSE_BASE_URL=<LANGFUSE_BASE_URL> --transport stdio langfuse -- npx -y langfuse-observability-mcp-server`.
What does langfuse do?
It gives an agent read-only access to Langfuse traces and observations, with filters and detail views for models, scores, costs, and latency.
What credentials does langfuse need?
Set LANGFUSE_SECRET_KEY and LANGFUSE_PUBLIC_KEY. Use LANGFUSE_BASE_URL when the API should use a different endpoint.