# Langfuse MCP Server

Langfuse includes a native [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that enables AI assistants and agents to interact with your Langfuse data programmatically.

If you have feedback or ideas for new tools, please [share them on GitHub](https://github.com/orgs/langfuse/discussions/10605).

If you are running AI agents in an environment where you can install CLI tools and run bash commands, we recommend using the [Langfuse Agent Skill](/content/docs/api-and-data-platform/features/agent-skill/index.html) instead of the MCP server.

This is the authenticated MCP server for the Langfuse data platform. There is also a public MCP server for the Langfuse documentation ( [docs](/content/docs/docs-mcp/index.html)).

## Configuration

The Langfuse MCP server uses a stateless architecture where each API key is scoped to a specific project. Use the following configuration to connect to the MCP server:

- **Cloud EU**  
  - Endpoint: `https://cloud.langfuse.com/api/public/mcp`  
  - Transport: `streamableHttp`  
  - Authentication: Basic Auth via authorization header

- **Cloud US**  
  - Endpoint: `https://us.cloud.langfuse.com/api/public/mcp`  
  - Transport: `streamableHttp`  
  - Authentication: Basic Auth via authorization header

- **Cloud Japan**  
  - Endpoint: `https://jp.cloud.langfuse.com/api/public/mcp`  
  - Transport: `streamableHttp`  
  - Authentication: Basic Auth via authorization header

- **HIPAA**  
  - Endpoint: `https://hipaa.cloud.langfuse.com/api/public/mcp`  
  - Transport: `streamableHttp`  
  - Authentication: Basic Auth via authorization header

- **Self-Hosted**  
  - Endpoint: `https://your-domain.com/api/public/mcp`  
  - Transport: `streamableHttp`  
  - Authentication: Basic Auth via authorization header

## MCP Reference

The [MCP Reference](https://mcp.reference.langfuse.com/) is the canonical source for current Langfuse MCP servers, setup snippets, tools, input schemas, and generated request examples.

**Both read and write tools are available by default.** If you only want to use read-only tools, configure your MCP client with an allowlist to restrict access to write operations. For a full list of tools, see the [MCP Reference](https://mcp.reference.langfuse.com/).

## Set up

### Get Authentication Header

1. Navigate to your project settings and create or copy a **project-scoped API key**:  
   - Public Key: `pk-lf-...`  
   - Secret Key: `sk-lf-...`

2. Encode the credentials to base64 format:
   
   ```
   echo -n "pk-lf-your-public-key:sk-lf-your-secret-key" | base64
   ```

### Client Setup

#### Claude Code

1. Register the Langfuse MCP server with a single command, replace `{your-base64-token}` with your encoded credentials:

```
   # Langfuse Cloud (EU)
   claude mcp add --transport http langfuse https://cloud.langfuse.com/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   
   # Langfuse Cloud (US)
   claude mcp add --transport http langfuse https://us.cloud.langfuse.com/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   
   # Langfuse Cloud (Japan)
   claude mcp add --transport http langfuse https://jp.cloud.langfuse.com/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   
   # Langfuse Cloud (HIPAA)
   claude mcp add --transport http langfuse https://hipaa.cloud.langfuse.com/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   
   # Self-Hosted (HTTPS required)
   claude mcp add --transport http langfuse https://your-domain.com/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   
   # Local Development
   claude mcp add --transport http langfuse http://localhost:3000/api/public/mcp \
          --header "Authorization: Basic {your-base64-token}"
   ```

2. Verify the connection by asking Claude Code to `list all prompts in the project`. Claude Code should use the `listPrompts` tool to return the list of prompts.

### Additional Configuration Files

You can also configure your MCP server in `mcp.json` as shown below:

#### Example Configuration for EU Cloud:
```json
{
  "mcp": {
    "servers": {
      "langfuse": {
        "url": "https://cloud.langfuse.com/api/public/mcp",
        "headers": {
          "Authorization": "Basic {your-base64-token}"
        }
      }
    }
  }
}
```

Repeat the structure for Cloud US, Japan, and HIPAA with the respective URLs.

## Feedback

We'd love to hear about your experience with the Langfuse MCP server. Share your feedback, ideas, and use cases in our [GitHub Discussion](https://github.com/orgs/langfuse/discussions/10605).
