跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Langfuse,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
让你的 AI 读取 Langfuse 项目:带成本、token 和延迟的 LLM 追踪、观测和会话,随时间变化的指标,评分和评估,带版本和标签的提示词,数据集、数据集条目和实验。它还可以发布提示词版本、移动标签、添加评分并构建数据集。
试试这样问
Langfuse 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Langfuse、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Langfuse + Meta Muse
让你的 AI 读取 Langfuse 项目:带成本、token 和延迟的 LLM 追踪、观测和会话,随时间变化的指标,评分和评估,带版本和标签的提示词,数据集、数据集条目和实验。它还可以发布提示词版本、移动标签、添加评分并构建数据集。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY
步骤 1 — 获取凭证
设置大约需要 3 分钟。你需要一个位于 Langfuse Cloud(EU、US、日本或 HIPAA)或自托管 Langfuse v4 上的 Langfuse 项目。
- 在 Langfuse 中打开项目,依次进入 Settings、API Keys、Create new API keys。请使用项目密钥,而不是组织密钥。
- 把公钥(
pk-lf-...)复制到LANGFUSE_PUBLIC_KEY,把私钥(sk-lf-...,只显示一次)复制到LANGFUSE_SECRET_KEY。连接器以 HTTP Basic 认证发送它们。 - 把
LANGFUSE_HOST设置为项目所在区域,末尾不要加斜杠:https://cloud.langfuse.com(EU)、https://us.cloud.langfuse.com(US)、https://jp.cloud.langfuse.com(日本)、https://hipaa.cloud.langfuse.com(HIPAA),或你的自托管地址。一个区域的密钥在其他区域无效。 - 安装连接器并运行
langfuse_get_project检查密钥;langfuse_get_health显示服务器版本。
费用:没有任何工具会运行模型。连接器只读写 Langfuse 数据;它显示的成本是 Langfuse 为你的应用的 LLM 调用记录下来的成本。
追踪数据:在 Langfuse v4 中,一条追踪是共享同一个 traceId 的一组观测(span、generation、工具调用、事件),一个会话是共享同一个 sessionId 的一组追踪。连接器从 Observations API v2 和 Metrics API v2 读取数据,这是实时读取路径;旧的 /traces、/sessions 和 /metrics/daily 端点已弃用(Langfuse Cloud 提供到 2026 年 11 月 16 日)。其他端点可能比数据接收晚约 10 分钟。
langfuse_list_observations按从新到旧列出行,并始终用from_start_time和to_start_time限定范围。过滤条件:type(LLM 调用为 GENERATION)、name、user_id、session_id、trace_id、level(失败为 ERROR)、environment、is_root_observation(true 时每条追踪一行)或结构化的filter。fields选择字段组core、basic、time、io(输入和输出)、metadata、model、usage(token 和成本)、prompt、metrics(延迟)和trace_context;默认为core,basic,usage。langfuse_get_trace返回一条追踪的所有观测,包括输入、输出、模型、用量和延迟;根节点没有parentObservationId,并携带追踪的输入和输出。langfuse_get_session默认为会话中的每条追踪返回一行;root_only: false返回所有观测。langfuse_query_metrics用于聚合。query是一个 JSON 字符串,包含view(observations、scores-numeric、scores-boolean、scores-categorical)、metrics(count、latency、totalTokens、totalCost或timeToFirstToken等度量,以及聚合方式sum、avg、count、max、min、p50、p75、p90、p95、p99)、dimensions(例如providedModelName、traceName、promptName、promptVersion、environment、release)、timeDimension(按分钟、小时、天、周或月)、filters、fromTimestamp和toTimestamp。userId、sessionId这类取值很多的字段可以用于过滤,但不能用于分组。
评分:langfuse_list_scores 可按 name、source(API、ANNOTATION、EVAL)、data_type、追踪、会话、观测、实验、取值范围和时间范围过滤;langfuse_list_score_configs 显示评分定义。langfuse_create_score 为追踪、观测、会话或实验运行添加一个评分(数值、以 0 或 1 表示的布尔值、类别或文本)。评分异步处理(HTTP 202),再次发送相同的 score_id 会覆盖它。
提示词:langfuse_list_prompts 列出名称及其版本、标签和 tag;langfuse_get_prompt 在未指定 version 或 label 时返回带 production 标签的版本。langfuse_create_prompt_version 发布文本提示词(含 {{variables}})或对话提示词的新版本,新名称会创建新提示词;langfuse_update_prompt_labels 把 production、staging 等标签移到某个版本。移动 production 会改变你的应用获取的内容,所以 AI 会先征求你的确认。带文件夹的名称(如 support/greeting)按原样传入。
数据集和实验:langfuse_list_datasets、langfuse_get_dataset 和 langfuse_create_dataset(可为输入和期望输出指定 JSON Schema);langfuse_list_dataset_items、langfuse_get_dataset_item 和 langfuse_upsert_dataset_item(创建条目,若 item_id 已存在则更新;status 设为 ARCHIVED 会让它不再出现在新的运行中)。langfuse_list_experiments 列出数据集运行和实验及其评分;from_start_time 为必填项。
Langfuse 自带的 MCP 服务器:Langfuse 还在 <LANGFUSE_HOST>/api/public/mcp 提供原生 MCP 服务器(使用同一对密钥),主要用于提示词管理。本连接器同样涵盖提示词,并额外提供追踪数据、指标、评分和数据集。
安装时关闭的工具:没有。全部 20 个工具都已启用;写入类工具会新增提示词版本、标签、评分、数据集和数据集条目,没有任何工具会删除数据。
数据格式:时间为 UTC 的 ISO 8601 格式。成本以美元计;在 v2 观测中,inputPrice、outputPrice 和 totalPrice 为字符串以保留小数精度,input 和 output 以 JSON 文本形式返回。指标中的延迟和首 token 时间以毫秒计。
分页:观测、追踪、会话、评分和实验使用游标:AI 会把 meta.cursor 作为 cursor 传回,直到它不再出现(观测默认 50 行,最多 1,000 行)。提示词、数据集、数据集条目和评分配置使用 page(从 1 开始)和 limit(默认 50,最多 100);meta.totalPages 表示总页数。
限制:使用观测和指标工具时,自托管 Langfuse 必须是 v4 或更高版本。Observations API v2 和 Metrics API v2 之外的数据可能延迟约 10 分钟。
常见错误:400 表示参数错误(filter 或 query 的 JSON 格式有误、按取值很多的字段分组、limit 超过上限);401 表示密钥对错误或区域不对;403 表示该密钥无权使用此端点(请使用项目密钥);404 表示提示词、数据集或条目不存在,或自托管版本没有 v2 端点;429 表示触发速率限制(AI 会等待,而不是循环重试)。
该连接器不删除追踪、提示词、数据集或评分,也不发送追踪(这由 Langfuse SDK 通过 OpenTelemetry 完成)。不包括标注队列、LLM 连接以及组织或 SCIM 管理。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Muse 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Muse 以自定义连接器的形式添加远程 MCP 服务器,并通过 OAuth 登录。
- 在 Muse 中打开 Settings → Connectors,选择 Add custom connector。
- 粘贴 MCP 服务器 URL
https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。 - Muse 会打开 AnythingMCP 的登录页面:登录并批准访问。
- 在聊天中,向 Muse 提出需要用到
Langfuse的工具的请求。
你也可以在聊天中完成设置,适用于网页版、iOS 和 Android 应用以及 WhatsApp。给 Muse 发送这条消息:
Create a Custom Connector for a new remote MCP server, then connect to it:
Name: AnythingMCP
Transport: remote streamable HTTP
URL: https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID
Auth: OAuth
自托管?请用你实例的公网 HTTPS 地址替换 https://cloud.anythingmcp.com。Muse 从 Meta 的云端连接,因此 localhost 无法使用。
可用工具
| Tool | What it does |
|---|---|
langfuse_get_project | Show the Langfuse project this key pair belongs to: id, name, organization and retention settings |
langfuse_get_health | Check that the Langfuse server and its database are up and read the Langfuse version (v4 or later is needed for the observation and metrics… |
langfuse_list_observations | List observations (LLM generations, spans, tool calls, events) of the Langfuse project, newest first, with the chosen field groups |
langfuse_get_trace | Read one Langfuse trace: all of its observations with input, output, model, token usage, cost and latency, newest first |
langfuse_get_session | Read one Langfuse session (for example a chat conversation): by default one row per trace, the entry point of each turn, with input, output… |
langfuse_query_metrics | Aggregate Langfuse data (Metrics API v2): counts, tokens, cost, latency percentiles or score values, grouped by dimensions such as model… |
langfuse_list_scores | List Langfuse scores (evaluations, user feedback, annotations) newest first, with name, value, data type, source, comment and the trace… |
langfuse_create_score | Add one score to a Langfuse trace, observation, session or experiment run, e.g. a quality rating or a correctness check |
langfuse_list_score_configs | List the score configs of the Langfuse project: name, data type, numeric range or categories, description and whether archived |
langfuse_list_prompts | List the prompts of the Langfuse project: name, type, versions, labels, tags and last update |
langfuse_get_prompt | Read one Langfuse prompt version: its text or chat messages, config (model, temperature), labels, tags, version and commit message |
langfuse_create_prompt_version | Publish a new version of a Langfuse prompt (a new name creates the prompt) |
langfuse_update_prompt_labels | Set the deployment labels of one Langfuse prompt version, e.g. promote version 4 to production |
langfuse_list_datasets | List the datasets of the Langfuse project with id, name, description, metadata and dates |
langfuse_get_dataset | Read one Langfuse dataset by name: description, metadata, input and expected-output JSON schemas and dates |
langfuse_create_dataset | Create a Langfuse dataset for evaluations and experiments, optionally with JSON schemas that every item's input and expected output must… |
langfuse_list_dataset_items | List the items of Langfuse datasets: input, expected output, metadata, status (ACTIVE or ARCHIVED) and the trace or observation they came… |
langfuse_get_dataset_item | Read one Langfuse dataset item: input, expected output, metadata, status, source trace and observation, dataset and dates |
langfuse_upsert_dataset_item | Add an item to a Langfuse dataset, or update it when item_id already exists: input, expected output, metadata, the source trace or… |
langfuse_list_experiments | List Langfuse experiments and dataset runs with recent activity first: name, dataset, metadata and, with fields scores, their aggregated… |
示例提示
- “过去 7 天里,我们的 LLM 调用按模型和天计算各花了多少钱?”
- “显示昨天 level 为 ERROR 的 generation,包括模型、输入和输出。”
- “显示会话 chat-8f21 的完整对话,以及每一轮的输入和输出。”
- “本周按追踪名称统计的 p95 延迟是多少?哪个变慢了?”
- “为提示词 support/greeting 发布一个语气更友好的新版本,但先不要移动 production 标签。”
FAQ
Muse 在哪些地区可用? Meta 目前在美国和加拿大提供 Muse,可在网页版、iOS 和 Android 应用以及 WhatsApp 中使用。
Meta 会审核这个连接器吗? 不会。Meta 不审核自定义连接器。Muse 只能看到你在 AnythingMCP 中为此 MCP 服务器启用的工具,你也可以随时在 Settings → Connectors 中断开它。
下一步
这份指南对你有帮助吗?