UNPKG

@meltstudio/langfuse-mcp-server

Version:

MCP server for Langfuse prompt management - get and compile prompts directly in Cursor

169 lines (118 loc) 4.47 kB
# Langfuse MCP Server for Cursor Get and compile your Langfuse prompts directly in Cursor. No more copying and pastingjust chat with your prompts. ## Quick Start ### 1. Install ```bash npm install -g @meltstudio/langfuse-mcp-server ``` ### 2. Get Your Langfuse Credentials 1. Go to your [Langfuse project settings](https://cloud.langfuse.com) 2. Copy your **Secret Key** and **Public Key** ### 3. Configure Cursor Add this to your Cursor settings file (`.cursor/mcp.json`): ```json { "mcpServers": { "langfuse": { "command": "melt-langfuse-mcp", "env": { "LANGFUSE_SECRET_KEY": "sk-lf-your-secret-key-here", "LANGFUSE_PUBLIC_KEY": "pk-lf-your-public-key-here" } } } } ``` ### 4. Restart Cursor ### 5. Test Your Integration After Cursor restarts, test that everything is working: 1. **Test with direct prompt execution** (Recommended): - In Cursor chat, type: **`Use the melt-integration-test prompt`** - You should see a welcome message confirming everything works - To test with variables: **`Use the melt-integration-test prompt with my_name='YourName' and task='building AI apps'`** 2. **Test with MCP tools**: - Ask Cursor: *"Show me all my prompts"* - Ask Cursor: *"Get the melt-integration-test prompt"* - Ask Cursor: *"Compile melt-integration-test with my_name='YourName' and task='building AI apps'"* If any of these work, you're all set! 🎉 ## Updating To update to the latest version: ```bash npm update -g @meltstudio/langfuse-mcp-server ``` Or to force reinstall: ```bash npm install -g @meltstudio/langfuse-mcp-server@latest ``` After updating, restart Cursor to use the new version. You can check your installed version with: ```bash melt-langfuse-mcp --version ``` ## Usage The MCP server provides two ways to work with your Langfuse prompts: ### 1. Direct Prompt Integration (Recommended) Use Cursor's prompt selector to browse and use your Langfuse prompts directly in chat: 1. Open Cursor's prompt selector (usually `@` in chat) 2. Browse your available Langfuse prompts 3. Select a prompt to use it directly in your conversation 4. Provide variables if the prompt requires them ### 2. Manual Tool Usage You can also chat naturally with Cursor using these commands: - **"Show me all my prompts"** - Lists your Langfuse prompts - **"Get the movie-critic prompt"** - Fetches a specific prompt - **"Compile movie-critic with movie='Dune 2'"** - Gets prompt ready for use ## Example ``` You: "Get my movie-critic prompt and compile it for Dune 2" Cursor: I'll fetch your movie-critic prompt and compile it for Dune 2. [Gets the prompt from Langfuse and substitutes variables] Here's your compiled prompt: "You are an expert movie critic. Write a detailed review of Dune 2..." ``` ## Available Commands | What you want | Say this | |---------------|----------| | See all prompts | "List my prompts" or "Show me all prompts" | | Get a specific prompt | "Get the [prompt-name] prompt" | | Compile with variables | "Compile [prompt-name] with variable='value'" | | Get prompt details | "Tell me about the [prompt-name] prompt" | ## Configuration Options You can add these optional environment variables to your Cursor config: ```json { "mcpServers": { "langfuse": { "command": "melt-langfuse-mcp", "env": { "LANGFUSE_SECRET_KEY": "sk-lf-...", "LANGFUSE_PUBLIC_KEY": "pk-lf-...", "LANGFUSE_HOST": "https://us.cloud.langfuse.com", "LANGFUSE_DEFAULT_LABEL": "production" } } } } ``` ## Troubleshooting ### "Command not found" error Make sure you installed globally: `npm install -g @meltstudio/langfuse-mcp-server` ### "Authentication failed" error Double-check your Langfuse credentials in the Cursor config. ### "Prompt not found" error - Check the prompt name is correct - Make sure the prompt has the "production" label (or set `LANGFUSE_DEFAULT_LABEL` to match your label) ## Langfuse Regions **US Region (default):** `https://us.cloud.langfuse.com` **EU Region:** `https://cloud.langfuse.com` The server defaults to US region. For EU region or self-hosted, set your host: ```json "LANGFUSE_HOST": "https://cloud.langfuse.com" ``` Or for self-hosted: ```json "LANGFUSE_HOST": "https://your-langfuse-instance.com" ``` --- **Made by [Melt Studio](https://meltstudio.co)** Questions? [Open an issue](https://github.com/MeltStudio/melt-langfuse-mcp/issues) or reach out to us.