Skip to main content
Glama
Use-Tusk
by Use-Tusk

get_trace

Retrieve a full distributed trace as a hierarchical tree to debug requests end-to-end, analyze call chains, timing, and dependencies.

Instructions

Get all spans in a distributed trace as a hierarchical tree.

Use this tool to:

  • Debug a specific request end-to-end

  • See the full call chain from HTTP request to database queries

  • Understand timing and dependencies between spans

  • Identify bottlenecks in a request

First use query_spans to find spans, then use the traceId to get the full trace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observableServiceIdNoService ID to query (required if multiple services available)
traceIdYesTrace ID to fetch
includePayloadsNoInclude inputValue/outputValue
maxPayloadLengthNoTruncate payload strings

Implementation Reference

  • Main handler for the get_trace tool. Parses input, calls the API client's getTrace() method, formats the trace tree, and returns the result.
    export async function handleGetTrace(
      client: TuskDriftApiClient,
      args: Record<string, unknown>
    ): Promise<{ content: Array<{ type: "text"; text: string }> }> {
      const input = parseGetTraceInput(args);
      const result = await client.getTrace(input);
    
      if (!result.traceTree) {
        return {
          content: [
            {
              type: "text",
              text: `No trace found for ID: ${input.traceId}`,
            },
          ],
        };
      }
    
      const header = `Trace: ${input.traceId}\nSpan Count: ${result.spanCount}\n\nTrace Tree:\n`;
      const tree = formatTraceTree(result.traceTree, 0, input.includePayloads ?? false);
    
      return {
        content: [
          {
            type: "text",
            text: header + tree,
          },
        ],
      };
    }
  • Tool definition with inputSchema for get_trace, defining observableServiceId, traceId, includePayloads, and maxPayloadLength parameters.
    export const getTraceTool: Tool = {
      name: "get_trace",
      description: `Get all spans in a distributed trace as a hierarchical tree.
    
    Use this tool to:
    - Debug a specific request end-to-end
    - See the full call chain from HTTP request to database queries
    - Understand timing and dependencies between spans
    - Identify bottlenecks in a request
    
    First use query_spans to find spans, then use the traceId to get the full trace.`,
      inputSchema: {
        type: "object",
        properties: {
          observableServiceId: {
            type: "string",
            description: "Service ID to query. Required if multiple services are available.",
          },
          traceId: {
            type: "string",
            description: "The trace ID to fetch",
          },
          includePayloads: {
            type: "boolean",
            description: "Include inputValue/outputValue (can be verbose)",
            default: false,
          },
          maxPayloadLength: {
            type: "number",
            description: "Truncate payload strings to this length",
            default: 500,
          },
        },
        required: ["traceId"],
      },
    };
  • Zod schema (getTraceInputSchema) for validating get_trace input arguments.
    export const getTraceInputSchema = z.object({
      observableServiceId: z.string().optional().describe("Service ID to query (required if multiple services available)"),
      traceId: z.string().describe("Trace ID to fetch"),
      includePayloads: z.boolean().default(false).describe("Include inputValue/outputValue"),
      maxPayloadLength: z.number().min(0).default(500).describe("Truncate payload strings"),
    });
  • parseGetTraceInput function that validates and transforms input args into a protobuf request object.
    export function parseGetTraceInput(args: Record<string, unknown>): GetTraceInput {
      const input: GetTraceArgs = getTraceInputSchema.parse(args);
      return SharedGetTraceSpansRequest.create({
        observableServiceId: input.observableServiceId ?? "",
        traceId: input.traceId,
        includePayloads: input.includePayloads,
        maxPayloadLength: input.maxPayloadLength,
      });
    }
  • src/server.ts:415-464 (registration)
    Registration of the get_trace tool on the MCP server with description, inputSchema, and handler callback.
      // ============================================
      // Tool: get_trace
      // ============================================
      server.registerTool(
        "get_trace",
        {
          description: `Get all spans in a distributed trace as a hierarchical tree.
    
    Use this tool to:
    - Debug a specific request end-to-end
    - See the full call chain from HTTP request to database queries
    - Understand timing and dependencies between spans
    - Identify bottlenecks in a request
    
    First use query_spans to find spans, then use the traceId to get the full trace.`,
          inputSchema: getTraceInputSchema.shape,
        },
        async (args) => {
          const input = parseGetTraceInput(args);
    
          if (input.observableServiceId && !(await checkAccess(input.observableServiceId))) {
            return {
              content: [{ type: "text" as const, text: "Error: Access denied to observable service" }],
              isError: true,
            };
          }
    
          try {
            const result = await provider.getTrace(input);
    
            if (!result.traceTree) {
              return {
                content: [{ type: "text" as const, text: `No trace found for ID: ${input.traceId}` }],
              };
            }
    
            const header = `Trace: ${input.traceId}\nSpan Count: ${result.spanCount}\n\nTrace Tree:\n`;
            const tree = formatTraceTree(result.traceTree, 0, input.includePayloads ?? false);
    
            return {
              content: [{ type: "text" as const, text: header + tree }],
            };
          } catch (error) {
            return {
              content: [{ type: "text" as const, text: `Error executing get_trace: ${error}` }],
              isError: true,
            };
          }
        }
      );
Behavior4/5

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

No annotations provided, so description carries burden. Clearly states it returns a hierarchical tree of spans, indicating read-only behavior. Does not mention side effects, authorization, or rate limits, but main behavioral traits are transparent. Schema covers parameter details.

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?

Description is structured with bullet-pointed use cases and clear workflow. It is reasonably concise, though could be slightly more streamlined. Every sentence adds value.

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

Completeness4/5

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

Given four parameters and no output schema, description provides good contextual completeness: explains purpose, use cases, prerequisite sibling tool, and parameter implications. Lacks details about return format beyond 'hierarchical tree', but sufficient for selection.

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?

Schema description coverage is 100% with per-parameter descriptions. Description adds overall context (e.g., uses traceId to fetch full trace) but does not enhance individual parameter semantics beyond schema. Baseline 3 is appropriate.

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?

Description clearly states it retrieves all spans in a distributed trace as a hierarchical tree, distinguishing it from sibling tools like query_spans. The verb 'get' and specific resource 'spans' with shape 'hierarchical tree' provide exact purpose.

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

Usage Guidelines5/5

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

Explicitly states to use query_spans first to find spans, then use traceId. Lists clear use cases: debug end-to-end, see call chain, understand timing, identify bottlenecks. Provides workflow and context for when to use this tool.

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/Use-Tusk/drift-mcp'

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