MCP Server for Langfuse Prompt Management
Manage and access Langfuse prompts with the MCP server for streamlined Model Context Protocol-based prompt management and control.
npx -y @langfuse/mcp-server-langfuseOverview
This MCP (Model Context Protocol) server exposes Langfuse-managed prompts through the MCP Prompts specification so external LLM clients and tooling can discover, retrieve, and compile prompts programmatically. It translates Langfuse prompt artifacts (text and chat prompts) into MCP prompt objects and provides both MCP-compliant endpoints and convenience tools for environments that do not implement the prompts capability.
Using this server helps centralize prompt management: prompt authors can keep prompts and variables in Langfuse while runtime systems (LLM apps, inspector tools, desktop clients) fetch, list, or compile prompts on-demand. That reduces duplication of prompt text across projects and enables prompt versioning and controlled rollout from a single source of truth.
Features
- MCP Prompts implementation
- prompts/list — paginated discovery of available prompts
- prompts/get — fetch and (optionally) compile a single prompt with provided variables
- Tool compatibility for non-MCP clients
- get-prompts and get-prompt tools mirror MCP prompt functionality
- Transforms Langfuse prompt formats (text/chat) into standard MCP prompt objects
- Cursor-based pagination for lists
- Environment-driven configuration for Langfuse base URL and API keys
Installation / Configuration
Install dependencies and build:
Run locally (example):
# POSIX
LANGFUSE_PUBLIC_KEY="your-public-key" \
LANGFUSE_SECRET_KEY="your-secret-key" \
LANGFUSE_BASEURL="https://cloud.langfuse.com" \
Add the server to an MCP-aware client such as Claude Desktop by configuring a command that starts the built server. Example Claude Desktop configuration snippet:
Cursor (or other command-based clients) can use a single-line invocation:
LANGFUSE_PUBLIC_KEY="your-public-key" LANGFUSE_SECRET_KEY="your-secret-key" LANGFUSE_BASEURL="https://cloud.langfuse.com"
For local debugging with the MCP inspector:
Available Tools
The server exposes MCP endpoints and also exports two tools to increase compatibility with clients that don’t implement the prompts capability.
Tool summary:
| Tool / Endpoint | Purpose | Key parameters |
|---|---|---|
| prompts/list | List available prompts (MCP) | optional cursor, page size |
| prompts/get | Retrieve and compile a prompt (MCP) | name, optional variables |
| get-prompts (tool) | List prompts for non-MCP clients | cursor |
| get-prompt (tool) | Retrieve and compile prompt for non-MCP clients | name (required), arguments (JSON object, optional) |
Example get-prompt tool payload (as JSON, client-specific):
Returned MCP prompt objects include prompt text or chat messages and a best-effort variables list. Note: Langfuse variables do not include rich descriptions, so argument metadata is minimal.
Use Cases
- Centralized prompt discovery inside a multi-LLM deployment: an orchestration layer lists available production prompts via prompts/list and fetches them on demand to build model inputs.
- Desktop LLM assistants (Claude Desktop, Cursor): add the server as an external MCP server so the assistant can offer published Langfuse prompts for reuse, templating, or prompt chaining.
- CI / testing: automated tests fetch compiled prompts with test variables to validate prompt outputs or ensure templates render as expected.
- Prompt audit and provenance: fetch the exact prompt text used in a given release or environment to reproduce a model run or review changes.
Concrete example — list prompts and compile one:
- Call prompts/list (or get-prompts) to retrieve prompt names.
- Select “product-launch-email”.
- Call prompts/get with arguments {“recipient_name”:“Jordan”,“product”:“Atlas”} to receive the rendered prompt text or chat messages to send to the LLM.
Limitations and Notes
- Only prompts labeled as production in Langfuse are returned by default.
- Variable metadata is minimal: arguments are treated as optional and lack descriptions because Langfuse does not expose variable specifications.
- Listing all prompts requires fetching each prompt to extract arguments; this is functional but not highly efficient for very large prompt catalogs.
- The project is open source — contributions, issues, and PRs are welcome at the repository: https://github.com/langfuse/mcp-server-langfuse
If you are new to MCP, consult the Model Context Protocol docs for details on how prompts are represented and how MCP clients invoke server capabilities.