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 Langfuse Prompt Management MCP Server allows you to access and manage your Langfuse prompts through the Model Context Protocol (MCP).

Features

MCP Prompt

  • prompts/list: List all available prompts with optional cursor-based pagination. It returns prompt names and their required arguments (assumed to be optional).
  • prompts/get: Get a specific prompt. This transforms Langfuse prompts into MCP prompt objects and compiles them with provided variables.

Tools

To enhance compatibility with other MCP clients, the server exports tools that replicate MCP Prompts functionality:

  • get-prompts: List available prompts with a cursor parameter for pagination.
  • get-prompt: Retrieve and compile a specific prompt using the name parameter (required) and a JSON object with optional arguments.

Development

npm install

# Build the 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

Edit claude_desktop_config.json to configure Claude for Desktop:

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

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
    

Limitations

  • Only prompts with a production label in Langfuse are returned.
  • All arguments are assumed to be optional and do not have descriptions.
  • List operations require fetching each prompt individually, which is not efficient.

Contributions are welcome! Please open an issue or a PR in the repository for suggestions or feedback.