Model Context Protocol (MCP) Server for Langfuse. This server provides comprehensive access to Langfuse's observability platform through the Model Context Protocol, including prompt management, trace analysis, observation monitoring, and session tracking.
Quick demo of Langfuse Prompts MCP in Claude Desktop (unmute for voice-over explanations):
langfuse-prompts-mcp-server-1080.mp4
This server implements the MCP Prompts specification for prompt discovery and retrieval.
-
prompts/list: List all available prompts- Optional cursor-based pagination
- Returns prompt names and their required arguments, limitation: all arguments are assumed to be optional and do not include descriptions as variables do not have specification in Langfuse
- Includes next cursor for pagination if there's more than 1 page of prompts
-
prompts/get: Get a specific prompt- Transforms Langfuse prompts (text and chat) into MCP prompt objects
- Compiles prompt with provided variables
Enhanced with powerful data fetching capabilities:
- Trace Analysis: Advanced trace filtering with support for time ranges, user IDs, trace names, and custom tags
- Observation Monitoring: Detailed observation queries with type filtering (SPAN, GENERATION, EVENT) and hierarchical navigation
- Session Tracking: User session management and analysis
- Real-time Insights: Access to live observability data with pagination and efficient caching
To increase compatibility with other MCP clients that do not support the prompt capability, the server also exports tools that replicate the functionality of the MCP Prompts.
-
get-prompts: List available prompts- Optional
cursorparameter for pagination - Returns a list of prompts with their arguments
- Optional
-
get-prompt: Retrieve and compile a specific prompt- Required
nameparameter: Name of the prompt to retrieve - Optional
argumentsparameter: JSON object with prompt variables
- Required
-
get-trace: Retrieve Langfuse trace data, optionally filtering by observation name or index- Required
traceIdparameter: The ID of the trace to retrieve - Optional
function_nameparameter: Filter observations by exact name - Optional
indexparameter: Retrieve a specific observation by its trace-level index (0-based) - Caching: Fetched traces are cached locally in the
cache_data/directory (ignored by git) - Size Limit: If no filter provided and the full trace data exceeds 40 KB, returns a summary instead
- Required
-
fetch-traces: List traces with advanced filtering options- Optional
pageparameter: Page number for pagination (1-based) - Optional
limitparameter: Number of traces per page (max 100) - Optional
traceNameparameter: Filter traces by specific trace name - Optional
userIdparameter: Filter traces by user ID - Optional
sessionIdparameter: Filter traces by session ID - Optional
fromTimestampparameter: Filter traces from this timestamp (ISO 8601 format) - Optional
toTimestampparameter: Filter traces until this timestamp (ISO 8601 format) - Optional
orderByparameter: Order traces by "timestamp" or "latency" - Optional
tagsparameter: Filter traces by tags (array of strings)
- Optional
-
fetch-observations: List observations with filtering options and pagination- Optional
pageparameter: Page number for pagination (1-based) - Optional
limitparameter: Number of observations per page (max 100) - Optional
traceIdparameter: Filter observations by trace ID - Optional
nameparameter: Filter observations by name - Optional
userIdparameter: Filter observations by user ID - Optional
typeparameter: Filter observations by type ("SPAN", "GENERATION", "EVENT") - Optional
parentObservationIdparameter: Filter observations by parent observation ID - Optional
fromStartTimeparameter: Filter observations from this start time (ISO 8601 format) - Optional
toStartTimeparameter: Filter observations until this start time (ISO 8601 format)
- Optional
-
fetch-observation: Fetch a single observation by its ID- Required
observationIdparameter: The ID of the observation to retrieve
- Required
-
fetch-sessions: List user sessions with pagination support- Optional
pageparameter: Page number for pagination (1-based) - Optional
limitparameter: Number of sessions per page (max 100)
- Optional
fetch-scores: Fetch evaluation scores (planned for future implementation once SDK supports it)
npm install
# build current file
npm run build
# test in mcp inspector
npx @modelcontextprotocol/inspector node ./build/index.jsnpm install
npm run buildConfigure Claude for Desktop by editing claude_desktop_config.json
{
"mcpServers": {
"langfuse": {
"command": "node",
"args": ["<absolute-path>/build/index.js"],
"env": {
"LANGFUSE_PUBLIC_KEY": "your-public-key",
"LANGFUSE_SECRET_KEY": "your-secret-key",
"LANGFUSE_BASEURL": "https://cloud.langfuse.com"
}
}
}
}Make sure to replace the environment variables with your actual Langfuse API keys. The server will now be available to use in Claude Desktop.
Add new server to Cursor:
- Name:
Langfuse Prompts - Type:
command - Command:
LANGFUSE_PUBLIC_KEY="your-public-key" LANGFUSE_SECRET_KEY="your-secret-key" LANGFUSE_BASEURL="https://cloud.langfuse.com" node absolute-path/build/index.js
The MCP Server is a work in progress and has some limitations:
- Only prompts with a
productionlabel in Langfuse are returned - All arguments are assumed to be optional and do not include descriptions as variables do not have specification in Langfuse
- List operations require fetching each prompt individually in the background to extract the arguments, this works but is not efficient
Contributions are welcome! Please open an issue or a PR (repo) if you have any suggestions or feedback.