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 分