Langfuse MCP

io.github.avivsinai由 GitHub 账号 avivsinai 发布v0.14.0更新于 Oct 25, 2026

Langfuse MCP server for accessing and analyzing telemetry data via natural language

概览

AI 生成的概览

面向 Langfuse 的本地 MCP 服务器,让助手调试 trace、会话与异常,查询指标,并管理提示词、数据集和标注队列。

可以做什么
  • 获取 trace、observation 与会话,并深入查看单条记录
  • 按文件、类型或名称查找并归类错误级异常,统计错误数量并查看详情
  • 查询成本、延迟、token 用量和评分等聚合指标,并获取指标查询结构
  • 列出、获取并创建提示词版本,更新提示词标签
  • 列出、创建、更新和删除数据集条目与数据集运行
  • 管理标注队列、队列条目与用户分配,读取评分和数据模式
适用场景
适合在本地 MCP 客户端中借助助手调试 Langfuse 里的 LLM 应用遥测数据:排查失败的 trace、查找近一天的异常、分析缓慢的会话,或进行提示词与数据集相关工作。README 将其定位为本地调试用途,而非托管的完整 API 访问。
运行要求
通过 uvx 在本地运行(需要 uv 和 Python 3.10 及以上),也可使用 Docker 镜像。需要 Langfuse API 凭据,即 LANGFUSE_PUBLIC_KEY 和 LANGFUSE_SECRET_KEY,自建实例还需设置 LANGFUSE_HOST。需要能访问 Langfuse 实例的网络;另可选 HTTP 传输模式和 profiles 配置文件。
安装前请注意
需要 Langfuse API 密钥,可访问项目遥测数据。写入类工具会创建、更新和删除提示词、数据集条目、数据集运行和标注队列;delete_dataset_item 为永久删除,删除数据集运行时若设置 delete_traces=True 还会一并删除 observation 和相关评分。只读模式(LANGFUSE_MCP_READ_ONLY)可禁用写入。在 HTTP 模式下,凭据通过 Authorization 头传输,若绑定到所有网络接口且没有 TLS 代理,默认项目可能被未认证调用者使用。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Langfuse MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Langfuse MCP Server

[PyPI] [GitHub stars] [PyPI downloads] [Downloads] [Python 3.10–3.14] [License: MIT]

Usage: 12,518 PyPI downloads last month (pypistats, 2026-08-19). v0.10.1.

Local MCP server and skill for Langfuse. Debug traces, sessions, and exceptions from Claude Code, Codex, Cursor, or any MCP client.

Why this instead of native Langfuse MCP?

Use this for local debug: first-class traces, sessions, and exceptions; route-decision tools; compact / file-dump output; plus the included langfuse skill.

Use official Langfuse MCP for hosted, zero-install access to the broader API (score writes, comments, models, media).

As of June 2026:

langfuse-mcpNative Langfuse MCP
Primary fitLocal debug: traces, sessions, exceptionsHosted, zero-install API surface
DeploymentLocal stdio or HTTP, via the Langfuse Python SDKNative streamable HTTP at /api/public/mcp
Trace / session / exception toolsFirst-classObservation/API-oriented access
Route-decision toolsYesNo
Token & output controlCompact summaries, truncation, file-dump mode, tool-group gatingHosted tool response + client
Metrics & dataset runsYesYes
Prompt, dataset, queue & score readsYesYes
Score writes, comments, models, mediaNoYes

langfuse-mcp for local debug. Native MCP for hosted breadth.

See a failing trace in 2 minutes

Install is uvx langfuse-mcp plus Langfuse API keys — Quick Start for Claude Code, Codex, Cursor, or Docker.

After the client restarts, ask:

text
find exceptions in the last day

That maps to existing tools:

text
find_exceptions(age=1440, group_by="file")find_exceptions_in_file(filepath="<file from the grouping>", age=1440)get_exception_details(trace_id="<trace_id from the file results>")

find_exceptions returns {group, count, observation_id, trace_id} (top 50 groups) — each group carries a representative observation/trace ID, and find_exceptions_in_file also yields full error records. Then optionally:

text
fetch_trace(trace_id="<trace_id>", include_observations=true)

The exception tools detect errors by observation level == "ERROR" (strict; a non-empty status_message alone does not count). Counts describe error-level observations, not individual exception events — get_error_count.exception_count is the same error-observation total reported by find_exceptions.metadata.observation_count (including groups beyond the top 50). Exception details come from recorded metadata (exception.type / exception.message / exception.stacktrace, top-level or under metadata.attributes); absent values are null. Results are not a point-in-time snapshot.

Project Links

Quick Start

Requires uv (for uvx) and Python 3.10 or newer. CI verifies Python 3.10 through 3.14.

Get credentials from Langfuse Cloud → Settings → API Keys. If self-hosted, use your instance URL for LANGFUSE_HOST.

bash
# Claude Code (project-scoped, shared via .mcp.json)claude mcp add \  -e LANGFUSE_PUBLIC_KEY=pk-... \  -e LANGFUSE_SECRET_KEY=sk-... \  -e LANGFUSE_HOST=https://cloud.langfuse.com \  --scope project \  langfuse -- uvx langfuse-mcp
# Codex CLI (user-scoped, stored in ~/.codex/config.toml)codex mcp add langfuse \  --env LANGFUSE_PUBLIC_KEY=pk-... \  --env LANGFUSE_SECRET_KEY=sk-... \  --env LANGFUSE_HOST=https://cloud.langfuse.com \  -- uvx langfuse-mcp

To pin a CI-verified interpreter explicitly, add --python 3.14 before langfuse-mcp.

Restart your CLI, then verify with /mcp (Claude Code) or codex mcp list (Codex).

Agent Skill

This repo ships a first-party langfuse skill for Claude Code and Codex. The skill gives agents concrete playbooks for trace debugging, exception triage, latency analysis, prompt management, and dataset work.

Install it when you want the agent to know when to reach for Langfuse and which MCP tools to call first.

Via skills (recommended):

bash
npx skills add avivsinai/langfuse-mcp -g -y

Via skild:

bash
npx skild install @avivsinai/langfuse -t claude -y

Manual install:

bash
cp -r skills/langfuse ~/.claude/skills/   # Claude Codecp -r skills/langfuse ~/.codex/skills/    # Codex CLI

After installing the skill, try:

text
help me debug langfuse tracesfind exceptions in the last daywhy was this user's session slow?

The MCP server provides the tools; the skill provides the agent-facing workflow. See skills/langfuse/SKILL.md, skills/langfuse/references/setup.md, and skills/langfuse/references/tool-reference.md.

Tools (48 total)

CategoryTools
Tracesfetch_traces, fetch_trace
Observationsfetch_observations, fetch_observation
Routingfind_route_decisions, get_route_decision, summarize_route_decisions, find_low_confidence_route_decisions
Sessionsfetch_sessions, get_session_details, get_user_sessions
Exceptionsfind_exceptions, find_exceptions_in_file, get_exception_details, get_error_count
Promptslist_prompts, get_prompt, get_prompt_unresolved, create_text_prompt, create_chat_prompt, update_prompt_labels
Datasetslist_datasets, get_dataset, list_dataset_items, get_dataset_item, create_dataset, create_dataset_item, delete_dataset_item, list_dataset_runs, get_dataset_run, list_dataset_run_items, create_dataset_run_item, delete_dataset_run
Annotation Queueslist_annotation_queues, create_annotation_queue, get_annotation_queue, list_annotation_queue_items, get_annotation_queue_item, create_annotation_queue_item, update_annotation_queue_item, delete_annotation_queue_item, create_annotation_queue_assignment, delete_annotation_queue_assignment
Scoreslist_scores_v2, get_score_v2
Metricsquery_metrics, get_metrics_schema
Schemaget_data_schema

On Observations API v2, traces are built from root observations. fetch_traces omits traces without a root observation, and fetch_trace cannot find traces with no observations.

Dataset-run reads use the experiments API when the installed Langfuse SDK exposes it (Python SDK 4.13.1+). The older routes remain a fallback for self-hosted servers that do not serve experiments. delete_dataset_run uses the legacy delete route while it works; after that route is removed, it deletes the run's traces only when you pass delete_traces=True. Trace deletion also removes observations and related scores. create_dataset_run_item still uses the legacy link API; when that API is gone, create experiment data through the SDK experiment runner or OTel ingestion.

Dataset Item Updates (Upsert)

Langfuse uses upsert for dataset items. To edit an existing item, call create_dataset_item with item_id. If the ID exists, it updates; otherwise it creates a new item.

python
create_dataset_item(dataset_name="qa-test-cases", item_id="item_123", input={"question": "What is 2+2?"}, expected_output={"answer": "4"})

Metrics Queries

query_metrics aggregates telemetry server-side (cost, latency, tokens, counts, score values) so agents can answer "what did inference cost?" or "what's p95 latency by model?" without pulling raw traces. Call get_metrics_schema for the full view/dimension/measure catalog.

python
query_metrics(    view="observations",    metrics=[{"measure": "totalCost", "aggregation": "sum"}, {"measure": "latency", "aggregation": "p95"}],    dimensions=["providedModelName"],    age=1440,  # last 24h; or pass from_timestamp / to_timestamp)

High-cardinality fields (id, traceId, userId, sessionId) must be used in filters, not dimensions. The v2 metrics endpoint is Langfuse Cloud-only; self-hosted instances may return 404.

Selective Tool Loading

Load only the tool groups you need to reduce token overhead:

bash
langfuse-mcp --tools traces,prompts

Available groups: traces, observations, routing, sessions, exceptions, prompts, datasets, annotation_queues, scores, metrics, schema

The routing group is router-neutral. It reads Langfuse span observations with metadata.schema_version: "mcp.route_decision.v1" and filters on route-decision fields stored in observation metadata, such as decision_id, router_name, provider, and capability_id.

Read-Only Mode

Disable all write operations for safer read-only access:

bash
langfuse-mcp --read-only# Or via environment variableLANGFUSE_MCP_READ_ONLY=true langfuse-mcp

This disables: create_text_prompt, create_chat_prompt, update_prompt_labels, create_dataset, create_dataset_item, delete_dataset_item, create_dataset_run_item, delete_dataset_run, create_annotation_queue, create_annotation_queue_item, update_annotation_queue_item, delete_annotation_queue_item, create_annotation_queue_assignment, delete_annotation_queue_assignment

Default Output Mode

Set the MCP-exposed default output_mode so clients that omit the parameter automatically use your preferred mode:

bash
langfuse-mcp --default-output-mode full_json_file# Or via environment variableLANGFUSE_MCP_DEFAULT_OUTPUT_MODE=full_json_file langfuse-mcp

Supported values: compact, full_json_string, full_json_file

This updates the default shown in MCP tool schemas. Clients can still override it per call by passing output_mode explicitly.

Other Clients

Cursor

Create .cursor/mcp.json in your project (or ~/.cursor/mcp.json for global):

json
{  "mcpServers": {    "langfuse": {      "command": "uvx",      "args": ["langfuse-mcp"],      "env": {        "LANGFUSE_PUBLIC_KEY": "pk-...",        "LANGFUSE_SECRET_KEY": "sk-...",        "LANGFUSE_HOST": "https://cloud.langfuse.com",        "LANGFUSE_MCP_DEFAULT_OUTPUT_MODE": "full_json_file"      }    }  }}

Docker (single project)

bash
docker run --rm -i \  -e LANGFUSE_PUBLIC_KEY=pk-... \  -e LANGFUSE_SECRET_KEY=sk-... \  -e LANGFUSE_HOST=https://cloud.langfuse.com \  ghcr.io/avivsinai/langfuse-mcp:latest

Multiple projects with profiles (stdio)

For local clients (Claude Code, Codex, Cursor), keep the credentials of each Langfuse project in a profiles file and register one MCP server per project. Each server starts with --profile <name>.

The file is TOML at $XDG_CONFIG_HOME/langfuse-mcp/profiles.toml (or ~/.config/langfuse-mcp/profiles.toml when XDG_CONFIG_HOME is not set). Use --profiles-file PATH or LANGFUSE_MCP_PROFILES_FILE to read a different file.

toml
[profiles.prod]host = "https://cloud.langfuse.com"public_key = "pk-lf-..."secret_key_env = "LANGFUSE_PROD_SECRET_KEY"   # read the secret from this env var
[profiles.staging]host = "https://langfuse.staging.example.com"public_key = "pk-lf-..."secret_key = "sk-lf-..."                       # or give the value directly

Each of public_key, secret_key and host takes a literal value, or a <field>_env key that names the environment variable that holds the value. host defaults to https://cloud.langfuse.com.

bash
claude mcp add langfuse-prod -- uvx langfuse-mcp --profile prodclaude mcp add langfuse-staging -- uvx langfuse-mcp --profile staging
json
{  "mcpServers": {    "langfuse-prod": {      "command": "uvx",      "args": ["langfuse-mcp", "--profile", "prod"]    },    "langfuse-staging": {      "command": "uvx",      "args": ["langfuse-mcp", "--profile", "staging"]    }  }}

Precedence is CLI flags (--public-key, --secret-key, --host) > environment variables (LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST) > the selected profile > defaults. When an environment variable overrides a profile value, the server logs a warning. An unknown profile name or a missing profiles file stops the server with an error that names the file and the available profiles. LANGFUSE_MCP_PROFILE selects a profile when --profile is not given.

HTTP transport — shared server for multiple projects

Run one persistent server instance and route each MCP client to its own Langfuse project by passing credentials in the Authorization header.

bash
# Start a shared server (binds to localhost by default)docker run -d -p 127.0.0.1:8000:8000 \  -e LANGFUSE_HOST=https://cloud.langfuse.com \  ghcr.io/avivsinai/langfuse-mcp:latest \  --transport streamable-http --bind-host 0.0.0.0

Security note: --bind-host 0.0.0.0 exposes the port on all interfaces. In production, place the server behind a TLS-terminating reverse proxy (nginx, Caddy, Cloudflare Tunnel) that enforces HTTPS. The Authorization header containing your keys is transmitted in plaintext over plain HTTP. If startup credentials are set, the proxy must enforce authentication; otherwise unauthenticated callers without an Authorization header can use the default project. For shared public HTTP deployments, omit default LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY credentials unless the fronting proxy authenticates every request.

Register each project separately in your MCP client, passing its credentials as a Basic auth header (base64(public_key:secret_key)):

bash
# Generate the header value for each project:echo -n "pk-lf-YOURKEY:sk-lf-YOURSECRET" | base64# cGstbGYtWU9VUktFWTpzay1sZi1ZT1VSU0VDUkVU
# Register in Claude Code (one entry per project):claude mcp add langfuse-audit \  --transport http http://localhost:8000/mcp \  -H "Authorization: Basic cGstbGYtWU9VUktFWTpzay1sZi1ZT1VSU0VDUkVU"
claude mcp add langfuse-staging \  --transport http http://localhost:8000/mcp \  -H "Authorization: Basic <base64 for staging project>"

Auth semantics: Basic here carries Langfuse API keys, not user passwords. An absent header falls back to startup env credentials (LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY). Any malformed header is rejected outright — there is no silent fallback to a different project.

Optional environment variables

VariableDefaultDescription
LANGFUSE_MAX_AGE_DAYS7Caps the lookback window for time-based tools (fetch_traces, fetch_observations, etc.). Set to match your Langfuse instance's data retention — e.g. 30 if your retention is 30 days.
LANGFUSE_MCP_PROFILEunsetProfile to load from the profiles file; same as --profile. See Multiple projects with profiles.
LANGFUSE_MCP_PROFILES_FILE$XDG_CONFIG_HOME/langfuse-mcp/profiles.tomlPath of the profiles file; same as --profiles-file.
LANGFUSE_MCP_TRACE_TIMEOUT_SECONDS120Per-request read timeout (seconds) for single-trace fetches (fetch_trace). Raise it if large traces with include_observations=True time out. Must be a positive integer.

Development

bash
uv venv --python 3.14 .venv && source .venv/bin/activateuv pip install -e ".[dev]"pytest

License

MIT

来源:README.md,提交 82608a2

工具

48

list_annotation_queues

List annotation queues with pagination.

输入参数pagelimit

create_annotation_queue

Create an annotation queue.

输入参数name必填descriptionscore_config_ids

get_annotation_queue

Get a single annotation queue by ID.

输入参数queue_id必填

list_annotation_queue_items

List items in an annotation queue.

输入参数pagelimitqueue_id必填

get_annotation_queue_item

Get a specific annotation queue item by queue and item ID.

输入参数item_id必填queue_id必填

create_annotation_queue_item

Create an annotation queue item.

输入参数statusqueue_id必填object_id必填object_type必填

update_annotation_queue_item

Update the status of an annotation queue item.

输入参数status必填item_id必填queue_id必填

delete_annotation_queue_item

Delete an annotation queue item.

输入参数item_id必填queue_id必填

create_annotation_queue_assignment

Assign a user to an annotation queue.

输入参数user_id必填queue_id必填

delete_annotation_queue_assignment

Unassign a user from an annotation queue.

输入参数user_id必填queue_id必填

list_datasets

List all datasets in the project with pagination. Returns metadata about datasets including name, description, item count, and timestamps. Args: ctx: Context object containing lifespan context with Langfuse client page: Page number for pagination (starts at 1) limit: Maximum items per page (max 100) Returns: A dictionary containing: - data: List of dataset metadata objects - metadata: Pagination info (page, limit, total)

输入参数pagelimit

get_dataset

Get a specific dataset by name. Retrieves dataset details including metadata and item count. Args: ctx: Context object containing lifespan context with Langfuse client name: The name of the dataset to fetch Returns: A dictionary containing dataset details: - id: Unique dataset identifier - name: Dataset name - description: Dataset description - metadata: Custom metadata - items: List of dataset items (if included by the API) - runs: List of dataset runs (if included by the API)

输入参数name必填

list_dataset_items

List items in a dataset with pagination and optional filtering. Returns dataset items with their input, expected output, and metadata. Args: ctx: Context object containing lifespan context with Langfuse client dataset_name: The name of the dataset to list items from source_trace_id: Optional filter by source trace ID source_observation_id: Optional filter by source observation ID page: Page number for pagination (starts at 1) limit: Maximum items per page (max 100) output_mode: How to format the response data Returns: A dictionary containing: - data: List of dataset item objects - metadata: Pagination info (page, limit, total, dataset_name)

输入参数pagelimitoutput_modedataset_name必填source_trace_idsource_observation_id

get_dataset_item

Get a specific dataset item by ID. Retrieves the full dataset item including input, expected output, metadata, and linked traces. Args: ctx: Context object containing lifespan context with Langfuse client item_id: The ID of the dataset item to fetch output_mode: How to format the response data Returns: A dictionary containing the dataset item details: - id: Unique item identifier - datasetId: Parent dataset ID - input: Input data for the item - expectedOutput: Expected output data - metadata: Custom metadata - sourceTraceId: Linked trace ID (if any) - sourceObservationId: Linked observation ID (if any) - status: Item status (ACTIVE or ARCHIVED)

输入参数item_id必填output_mode

create_dataset

Create a new dataset in the project. Datasets are used to store evaluation test cases with input/expected output pairs. Args: ctx: Context object containing lifespan context with Langfuse client name: Name for the new dataset (must be unique) description: Optional description metadata: Optional custom metadata Returns: A dictionary containing the created dataset details: - id: Unique dataset identifier - name: Dataset name - description: Dataset description - metadata: Custom metadata - createdAt: Creation timestamp

输入参数name必填metadatadescription

create_dataset_item

Create a new item in a dataset, or update if item_id already exists. Dataset items store input/expected output pairs for evaluation. If item_id is provided and already exists, the item will be updated (upsert behavior). Args: ctx: Context object containing lifespan context with Langfuse client dataset_name: Name of the target dataset input: Input data for the item expected_output: Expected output for evaluation metadata: Optional custom metadata source_trace_id: Optional linked trace ID source_observation_id: Optional linked observation ID item_id: Optional custom ID (enables upsert) status: Item status (ACTIVE or ARCHIVED) Returns: A dictionary containing the created/updated item details

输入参数inputstatusitem_idmetadatadataset_name必填expected_outputsource_trace_idsource_observation_id

delete_dataset_item

Delete a dataset item by ID. This is a permanent deletion and cannot be undone. Args: ctx: Context object containing lifespan context with Langfuse client item_id: The ID of the dataset item to delete Returns: A dictionary confirming the deletion

输入参数item_id必填

list_dataset_runs

List runs for a dataset by dataset name.

输入参数pagelimitdataset_name必填

get_dataset_run

Get a dataset run, including any run items returned by the SDK.

输入参数run_name必填output_modedataset_name必填

list_dataset_run_items

List dataset run items by dataset ID and run name.

输入参数pagelimitrun_name必填dataset_id必填output_mode

create_dataset_run_item

Create a dataset run item and flush the ingestion write. If this legacy API is gone, use the SDK experiment runner or OTel ingestion; neither can link an existing trace through this API.

输入参数metadatarun_name必填trace_idobservation_iddataset_item_id必填run_description

delete_dataset_run

Delete a run through the legacy route, or explicitly delete its traces after removal. Trace deletion also removes observations and related scores. Set delete_traces=True to allow this broader replacement.

输入参数run_name必填dataset_name必填delete_traces

find_exceptions

Get error-level observations grouped by file path, function, type, name, or observation type. Args: ctx: Context object containing lifespan context with Langfuse client age: Number of minutes to look back; capped by the configured maximum group_by: How to group errors - "file" groups by recorded code.filepath, "function" by code.function, "type" by recorded exception.type, "name" by observation name, or "observation_type" by observation type Returns: List of error-observation counts grouped by the specified category. A group entry carries a representative observation_id and trace_id. Counts describe error-level observations, NOT individual exception events (which the standard observation listing does not expose).

输入参数age必填group_by

find_exceptions_in_file

Get detailed error info for a specific file (recorded code.filepath match). Args: ctx: Context object containing lifespan context with Langfuse client filepath: Path to the file as recorded in Langfuse metadata (code.filepath) age: Number of minutes to look back; capped by the configured maximum output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: List of summarized error records (top 10 newest after the full scan) - full_json_string: String containing the full JSON response - full_json_file: List of summarized error records with file save info

输入参数age必填filepath必填output_mode

get_exception_details

Get detailed error info for a trace/observation. Args: ctx: Context object containing lifespan context with Langfuse client trace_id: The ID of the trace to analyze for errors (unique identifier string) span_id: Optional observation ID to filter by (applies across all observation types) output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: List of summarized error records - full_json_string: String containing the full JSON response - full_json_file: List of summarized error records with file save info

输入参数span_idtrace_id必填output_mode

get_error_count

Get number of traces with error-level observations in last N minutes. Args: ctx: Context object containing lifespan context with Langfuse client age: Number of minutes to look back; capped by the configured maximum Returns: Dictionary with error statistics: trace_count (distinct traces), observation_count (error-level observations), and exception_count (the same error-observation total as find_exceptions, not a count of individual exception events; see metadata.note).

输入参数age必填

query_metrics

Query aggregated metrics (cost, latency, token usage, counts, score values) from Langfuse. Wraps the Langfuse v2 metrics endpoint. Use this for analytics questions — "what did inference cost in the last 24h grouped by model", "p95 latency per prompt", "score distribution by name" — instead of pulling raw observations and aggregating client-side. Per-parameter contracts live in the Field descriptions above. Notes: - The v2 metrics endpoint is Langfuse Cloud-only; self-hosted instances may return 404. - Recently-ingested data can lag (OTEL ingestion delay up to ~10 minutes). - High-cardinality fields (id, traceId, userId, sessionId) must be filters, not dimensions.

输入参数ageview必填filtersmetrics必填order_bydimensionsoutput_modeto_timestampfrom_timestamptime_granularity

get_metrics_schema

Get the query schema for the metrics API (views, dimensions, measures, aggregations). Companion to query_metrics: describes which views exist, the dimensions and measures available on each, the supported aggregations/operators, and the query-object shape. ``dummy`` is unused and exists only for MCP API compatibility.

输入参数dummy

fetch_observations

Get observations filtered by type and other criteria. Args: ctx: Context object containing lifespan context with Langfuse client type: The observation type to filter by (SPAN, GENERATION, EVENT, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING or GUARDRAIL) age: Minutes ago to start looking (e.g., 1440 for 24 hours) name: Optional name filter (string pattern to match) user_id: Optional user ID filter (exact match) trace_id: Optional trace ID filter (exact match) parent_observation_id: Optional parent observation ID filter (exact match) page: Page number for pagination (starts at 1) limit: Maximum number of observations to return per page output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: List of summarized observation objects - full_json_string: String containing the full JSON response - full_json_file: List of summarized observation objects with file save info

输入参数age必填namepagetypelimituser_idtrace_idoutput_modeparent_observation_id

fetch_observation

Get a single observation by ID. Args: ctx: Context object containing lifespan context with Langfuse client observation_id: The ID of the observation to fetch (unique identifier string) output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: Summarized observation object - full_json_string: String containing the full JSON response - full_json_file: Summarized observation object with file save info

输入参数output_modeobservation_id必填

get_prompt

Fetch a specific prompt by name with resolved dependencies. Retrieves a prompt from Langfuse with all dependency tags resolved. Uses the SDK's built-in caching for optimal performance. Args: ctx: Context object containing lifespan context with Langfuse client name: The name of the prompt to fetch label: Optional label to fetch (e.g., 'production'). Cannot be used with version. version: Optional specific version number. Cannot be used with label. Returns: A dictionary containing the prompt details: - id: Unique prompt identifier - name: Prompt name - version: Version number - type: 'text' or 'chat' - prompt: The prompt content (string for text, list for chat) - labels: List of labels assigned to this version - tags: List of tags - config: Model configuration (temperature, model, etc.) Raises: ValueError: If both label and version are specified LookupError: If prompt not found

输入参数name必填labelversion

get_prompt_unresolved

Fetch a specific prompt by name WITHOUT resolving dependencies. Returns raw prompt content with dependency tags intact (e.g., @@@langfusePrompt:name=xxx@@@) when the SDK supports resolve=false. Otherwise returns the resolved prompt and marks metadata.resolved=True. Useful for analyzing prompt composition and debugging dependency chains. Args: ctx: Context object containing lifespan context with Langfuse client name: The name of the prompt to fetch label: Optional label to fetch. Cannot be used with version. version: Optional specific version number. Cannot be used with label. Returns: A dictionary containing the raw prompt details with dependency tags preserved. Raises: ValueError: If both label and version are specified LookupError: If prompt not found

输入参数name必填labelversion

list_prompts

List and filter prompts in the project. Returns metadata about prompts including versions, labels, tags, and last updated time. Args: ctx: Context object containing lifespan context with Langfuse client name: Optional filter by exact prompt name label: Optional filter by label on any version tag: Optional filter by tag page: Page number for pagination (starts at 1) limit: Maximum items per page (max 100) Returns: A dictionary containing: - data: List of prompt metadata objects - metadata: Pagination info (page, limit, total)

输入参数tagnamepagelabellimit

create_text_prompt

Create a new text prompt version in Langfuse. Prompts are immutable; creating a new version is the only way to update prompt content. Labels are unique across versions - assigning a label here will move it from other versions.

输入参数name必填tagsconfiglabelsprompt必填commit_message

create_chat_prompt

Create a new chat prompt version in Langfuse. Chat prompts are arrays of role/content messages. Prompts are immutable; create a new version to update content. Labels are unique across versions.

输入参数name必填tagsconfiglabelsprompt必填commit_message

update_prompt_labels

Update labels for a specific prompt version. This is the only supported mutation for existing prompts. Provided labels are added to the version (existing labels are preserved). Labels are unique across versions, and the 'latest' label is managed by Langfuse.

输入参数name必填labels必填version必填

find_route_decisions

Find generic agent route decisions emitted as Langfuse SPAN observations. This tool is router-neutral. It only treats observations with metadata.schema_version == "mcp.route_decision.v1" as route decisions, and it filters on fields inside observation metadata rather than display output.

输入参数agepagelimitprovidertrace_idsession_iddecision_idoutput_moderouter_namecapability_id

get_route_decision

Fetch one route decision by metadata decision_id.

输入参数agedecision_id必填output_mode

summarize_route_decisions

Summarize generic route decisions for a trace, session, router, provider, or capability.

输入参数agepagelimitprovidertrace_idsession_idrouter_namecapability_idmax_confidence

find_low_confidence_route_decisions

Find route decisions that are low-confidence or explicitly uncallable.

输入参数agepagelimitprovidertrace_idsession_idoutput_moderouter_namecapability_idmax_confidenceinclude_uncallable

get_data_schema

Get schema of trace, span and event objects. Args: ctx: Context object containing lifespan context with Langfuse client dummy: Unused parameter for API compatibility (can be left empty) Returns: String containing the detailed schema definitions for traces, spans, events, and other core Langfuse data structures

输入参数dummy

list_scores_v2

List scores via Scores API v3 with optional filters (GET /v2/scores where v3 is not served). With operator ``=`` and a value, v3 defaults an omitted data_type to NUMERIC; pass BOOLEAN for boolean scores. Strict ``>``/``<`` can return fewer than limit rows on a page after boundary rows are dropped; next_page shows whether more rows exist.

输入参数namepagelimitvaluesourceuser_idoperatorqueue_idtrace_idconfig_iddata_typescore_ids另有 5 个

get_score_v2

Get a score by ID from Scores API v3 (the v2 route where v3 is not served).

输入参数score_id必填

fetch_sessions

Get a list of sessions in the current project. Args: ctx: Context object containing lifespan context with Langfuse client age: Minutes ago to start looking (e.g., 1440 for 24 hours) page: Page number for pagination (starts at 1) limit: Maximum number of sessions to return per page output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: List of summarized session objects - full_json_string: String containing the full JSON response - full_json_file: List of summarized session objects with file save info

输入参数age必填pagelimitoutput_mode

get_session_details

Get detailed information about a specific session. Args: ctx: Context object containing lifespan context with Langfuse client session_id: The ID of the session to retrieve (unique identifier string) include_observations: If True, fetch and include the full observation objects instead of just IDs. Use this when you need access to system prompts, model parameters, or other details stored within observations. Significantly increases response time but provides complete data. output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: Summarized session details object - full_json_string: String containing the full JSON response - full_json_file: Summarized session details object with file save info Usage Tips: - For quick browsing: use include_observations=False with output_mode="compact" - For full data but viewable in responses: use include_observations=True with output_mode="compact" - For complete data dumps: use include_observations=True with output_mode="full_json_file"

输入参数session_id必填output_modeinclude_observations

get_user_sessions

Get sessions for a user within a time range. Args: ctx: Context object containing lifespan context with Langfuse client user_id: The ID of the user to retrieve sessions for (unique identifier string) age: Minutes ago to start looking (e.g., 1440 for 24 hours) include_observations: If True, fetch and include the full observation objects instead of just IDs. Use this when you need access to system prompts, model parameters, or other details stored within observations. Significantly increases response time but provides complete data. output_mode: Controls the output format and detail level Returns: Based on output_mode: - compact: List of summarized session objects - full_json_string: String containing the full JSON response - full_json_file: List of summarized session objects with file save info Usage Tips: - For quick browsing: use include_observations=False with output_mode="compact" - For full data but viewable in responses: use include_observations=True with output_mode="compact" - For complete data dumps: use include_observations=True with output_mode="full_json_file"

输入参数age必填user_id必填output_modeinclude_observations

fetch_traces

Find traces based on filters. All filter parameters are optional. On Observations API v2, each trace is built from its root observation; traces without a root observation do not appear.

输入参数age必填namepagetagslimituser_idmetadatasession_idoutput_modeinclude_observations

fetch_trace

Get a single trace by ID with full details. On Observations API v2, a trace is built from its root observation; a trace with no observations is not found. Args: ctx: Context object containing lifespan context with Langfuse client trace_id: The ID of the trace to fetch (unique identifier string) include_observations: If True, fetch and include the full observation objects. If False, the observations field group is dropped entirely to avoid expensive per-observation IO. Use True when you need access to system prompts, model parameters, or other details stored within observations. Significantly increases response time but provides complete data. output_mode: Controls the output format and detail level Returns: One of the following based on output_mode: - For 'compact' and 'full_json_file': A response dictionary with the structure: { "data": Single trace object, "metadata": { "file_path": Path to saved file (only for full_json_file mode), "file_info": File save details (only for full_json_file mode) } } - For 'full_json_string': A string containing the full JSON response Usage Tips: - For quick browsing: use include_observations=False with output_mode="compact" - For full data but viewable in responses: use include_observations=True with output_mode="compact" - For complete data dumps: use include_observations=True with output_mode="full_json_file"

输入参数trace_id必填output_modeinclude_observations

版本历史

3
  1. v0.14.0最新Oct 25, 2026
  2. v0.13.0Oct 11, 2026
  3. v0.12.1Sep 25, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分