Skip to main content
Glama
avivsinai

langfuse-mcp

by avivsinai

fetch_trace

Retrieve a single trace by its ID to inspect full trace details, optionally including observations for debugging LLM applications.

Instructions

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"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trace_idYesThe ID of the trace to fetch (unique identifier string)
output_modeNoControls the output format and action. 'compact' (default): Returns a summarized JSON object optimized for direct agent consumption. 'full_json_string': Returns the complete, raw JSON data serialized as a string. 'full_json_file': Returns a summarized JSON object AND saves the complete data to a file.compact
include_observationsNoIf True, fetch and include the full observation objects. If False, the observations field group is dropped entirely to avoid the expensive per-observation IO that dominates large-trace payloads. 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. Pairs well with output_mode='full_json_file' for complete dumps.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.25.1
    • changedInput schema / properties / include_observations / description
      Previous value: -"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. Pairs well with output_mode='full_json_file' for complete dumps."New value: +"If True, fetch and include the full observation objects. If False, the observations field group is dropped entirely to avoid the expensive per-observation IO that dominates large-trace payloads. 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. Pairs well with output_mode='full_json_file' for complete dumps."
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden, and it does so well. It discloses that a trace without observations is not found, that include_observations=False drops the observations group to avoid expensive IO, that response time can increase significantly, and that output modes can save to a file. These are behavioral details beyond what the schema alone reveals.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with Args, Returns, and Usage Tips, and the core purpose is front-loaded. It is somewhat verbose and repeats schema content, but the repetition is organized and the behavioral context justifies most of the length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the key behavior, the not-found case, performance implications, output format choices, and usage tips. Even with an output schema present, the description goes beyond what structured data provides, making it complete enough for an agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds some value beyond the schema by explaining the output dictionary shape per output_mode and connecting parameter combinations to practical outcomes, but it largely restates the schema's parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Get a single trace by ID with full details,' which names a specific verb, resource, and scope. This clearly distinguishes it from sibling tools like fetch_traces (plural) and fetch_observation(s).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The Usage Tips explicitly map combinations of include_observations and output_mode to different use cases, such as quick browsing versus complete data dumps. However, it does not explicitly say when to prefer fetch_trace over sibling tools like fetch_traces, so the exclusion guidance is implicit rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.