Skip to main content
Glama
dimonb

Uptrace MCP Server

by dimonb

uptrace_get_trace

Retrieve all spans for a specific trace ID to debug request flows and analyze performance issues. Supports text or JSON output formats.

Instructions

Get all spans for a specific trace ID. Useful for debugging and understanding request flows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trace_idYesTrace ID to retrieve
formatNoOutput format: 'text' for human-readable format, 'json' for structured JSON with all attributestext

Implementation Reference

  • The handler for 'uptrace_get_trace' that parses arguments, calls the client to fetch spans, and returns formatted text or JSON.
    elif name == "uptrace_get_trace":
        trace_id = arguments.get("trace_id")
        output_format = arguments.get("format", "text")  # "text" or "json"
    
        if not trace_id:
            return [TextContent(type="text", text="Error: trace_id is required")]
    
        logger.info(f"Fetching trace: {trace_id}")
        spans = client.get_trace(trace_id)
    
        if not spans:
            return [TextContent(type="text", text=f"No spans found for trace ID: {trace_id}")]
    
        # Return JSON format if requested
        if output_format == "json":
            import json
    
            # Convert spans to dict with all attributes
            spans_data = []
            for span in spans:
                span_dict = {
                    "id": span.id,
                    "parent_id": span.parent_id,
                    "trace_id": span.trace_id,
                    "project_id": span.project_id,
                    "group_id": span.group_id,
                    "type": span.type,
                    "system": span.system,
                    "kind": span.kind,
                    "name": span.name,
                    "display_name": span.display_name,
                    "time": span.time,
                    "duration": span.duration,
                    "status_code": span.status_code,
                    "status_message": span.status_message,
                    "attrs": span.attrs or {},
                    "events": [
                        {"name": event.name, "time": event.time, "attrs": event.attrs or {}}
                        for event in span.events
                    ],
                    "links": span.links or [],
                }
                spans_data.append(span_dict)
    
            result = {"trace_id": trace_id, "total_spans": len(spans), "spans": spans_data}
    
            return [
                TextContent(
                    type="text",
                    text=json.dumps(result, indent=2, ensure_ascii=False, default=str),
                )
            ]
    
        # Return text format (default)
        lines = [
            f"# Trace: {trace_id}",
            f"**Total Spans**: {len(spans)}",
            "",
        ]
    
        # Build tree structure
        root_spans = [s for s in spans if not s.parent_id or s.parent_id == "0"]
    
        def format_tree(span: Any, indent: int = 0) -> None:
            prefix = "  " * indent + ("└─ " if indent > 0 else "")
            duration_ms = round(span.duration / 1000, 2) if span.duration else 0
            status = "❌" if span.status_code == "error" else "✓"
            lines.append(f"{prefix}{status} {span.display_name} ({duration_ms}ms) [{span.id}]")
    
            # Find children
            children = [s for s in spans if s.parent_id == span.id]
            for child in children:
                format_tree(child, indent + 1)
    
        lines.append("## Span Tree")
  • The MCP tool definition and input schema for 'uptrace_get_trace'.
    Tool(
        name="uptrace_get_trace",
        description="Get all spans for a specific trace ID. Useful for debugging and understanding request flows.",
        inputSchema={
            "type": "object",
            "properties": {
                "trace_id": {
                    "type": "string",
                    "description": "Trace ID to retrieve",
                },
                "format": {
                    "type": "string",
                    "enum": ["text", "json"],
                    "description": "Output format: 'text' for human-readable format, 'json' for structured JSON with all attributes",
                    "default": "text",
                },
            },
            "required": ["trace_id"],
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It fails to indicate whether this is a read-only operation, what happens if the trace_id is not found, or performance implications of retrieving 'all spans' (which could be thousands). Only the use case context is provided.

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

Conciseness5/5

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

Two sentences with zero waste: the first states the core action, the second provides usage context. It is appropriately front-loaded and sized for the tool's complexity.

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

Completeness3/5

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

Given the absence of an output schema, the description adequately identifies that 'spans' are returned, but lacks detail on the structure, nesting, or volume of returned data. For a simple 2-parameter retrieval tool, it meets minimum viability but leaves gaps in explaining the return value structure.

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

Parameters3/5

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

With 100% schema description coverage, the structured fields already document both parameters thoroughly. The description mentions 'specific trace ID' which aligns with the required parameter, but adds no additional semantic detail about the format parameter's implications or trace_id format requirements beyond what the schema already provides.

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

Purpose4/5

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

The description uses a specific verb ('Get') and resource ('spans') with clear scoping ('for a specific trace ID'). However, it does not explicitly differentiate from sibling tool 'uptrace_search_spans', which likely searches across traces rather than retrieving a complete trace by ID.

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

Usage Guidelines3/5

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

The phrase 'Useful for debugging and understanding request flows' provides implied context for when to use the tool. However, it lacks explicit guidance on when NOT to use it (e.g., when to use search_spans instead) or prerequisites like obtaining the trace_id first.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dimonb/uptrace-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server