MCP HubMCP Hub
langfuse

mcp-server-langfuse

by: langfuse

Model Context Protocol (MCP) Server for Langfuse Prompt Management. This server allows you to access and manage your Langfuse prompts through the Model Context Protocol.

52created 15/02/2025
Visit
Langfuse
Protocol

📌Overview

Purpose: The Langfuse Prompt Management MCP Server aims to facilitate access and management of Langfuse prompts via the Model Context Protocol (MCP).

Overview: The server implements MCP specifications to enable prompt discovery and retrieval functionalities. It serves as a bridge between Langfuse prompts and MCP clients, enhancing compatibility and usability.

Key Features:

  • MCP Prompt Implementation: Adheres to MCP Prompts specifications for listing and retrieving prompts.

    • prompts/list: Provides a list of all available prompts with optional cursor-based pagination and relevant arguments.
    • prompts/get: Retrieves specific prompts, transforming and compiling them into MCP prompt objects with specified variables.
  • Compatibility Tools: Exports additional tools for compatibility with MCP clients lacking prompt support.

    • get-prompts: Functions similarly to prompts/list, offering prompt accessibility with pagination capabilities.
    • get-prompt: Allows retrieval and compilation of specific prompts by name and optional arguments.

Langfuse Prompt Management MCP Server

The Model Context Protocol (MCP) Server for Langfuse Prompt Management allows you to access and manage your Langfuse prompts through the Model Context Protocol.

Features

MCP Prompt

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 (all arguments are assumed optional; no descriptions due to Langfuse limitations)
    • Includes next cursor for pagination if more than one page of prompts exists
  • prompts/get: Get a specific prompt

    • Transforms Langfuse prompts (text and chat) into MCP prompt objects
    • Compiles prompt with provided variables

Tools

To support MCP clients that do not support the prompt capability, the server exports tools replicating the MCP Prompts functionality.

  • get-prompts: List available prompts

    • Optional cursor parameter for pagination
    • Returns a list of prompts with their arguments
  • get-prompt: Retrieve and compile a specific prompt

    • Required name parameter: Name of the prompt
    • Optional arguments parameter: JSON object with prompt variables

Development

npm install

# build current file
npm run build

# test in MCP inspector
npx @modelcontextprotocol/inspector node ./build/index.js

Usage

Step 1: Build

npm install
npm run build

Step 2: Add the server to your MCP servers

Claude Desktop

Configure 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"
      }
    }
  }
}

Replace the environment variables with your actual Langfuse API keys. The server will then be available in Claude Desktop.

Cursor

Add a new server to Cursor with the following settings:

  • 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

Limitations

  • Only prompts labeled production in Langfuse are returned
  • All arguments are assumed optional and lack descriptions due to Langfuse specifications
  • List operations require fetching each prompt individually to extract arguments, which is functional but inefficient

Contributions are welcome! Please open an issue or a PR if you have suggestions or feedback (repo).