Skip to main content
Glama
CubeAPM MCP Server

CubeAPM MCP Server

search_traces

Search CubeAPM traces by service, environment, time range, and query filters to find slow or failing requests and return key span snippets for investigation.

Instructions

Search for traces in CubeAPM matching the specified criteria. Returns trace snippets with key spans.

IMPORTANT - Required Parameters:

  • query, env, service, start, end are ALL REQUIRED by CubeAPM API

  • Use query="*" for wildcard search

  • Use env="UNSET" if environment is not configured

  • Service names are case-sensitive (e.g., "Kratos-Prod" not "kratos")

TRACE QUERY SYNTAX: The query parameter supports pipe syntax similar to LogsQL: {stream_selector} | pipe1 | pipe2

Stream selectors filter spans: {service="Kratos-Prod"} {service="Kratos-Prod", span_kind="server"} {http_code=~"5.."}

PIPE OPERATORS — same as LogsQL pipes: | copy, | drop, | extract_regexp, | join, | keep, | limit, | math, | rename, | replace, | replace_regexp, | sort, | stats as alias [by (group_fields)], | unpack_json

STATS FUNCTIONS (for aggregate trace analysis): avg(field) — arithmetic mean count() — total matching spans count_uniq(field) — distinct values max(field) — maximum value median(field) — median value min(field) — minimum value quantile(p, field) — p-th quantile (e.g., quantile(0.95, duration)) sum(field) — sum of values

IMPORTANT: Duration in traces is in MILLISECONDS. IMPORTANT: "p95" is NOT a valid function — use quantile(0.95, duration).

Example queries: Wildcard: query="*" P95 latency: query='{service="Kratos-Prod", span_kind="server"} | stats quantile(0.95, duration) as p95_latency' Error count by endpoint: query='{service="Kratos-Prod", status_code="ERROR"} | stats count() as errors by (http_route)' Slow spans: query='{service="Kratos-Prod"} | sort by (duration) desc | limit 20'

Optional filters (applied in addition to query):

  • spanKind: server, client, consumer, producer

  • sortBy: duration (to find slow traces)

To discover available service names, first query metrics: count by (service) (cube_apm_calls_total{env="UNSET"})

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "service": "<service>",
      "start": "<start>",
      "end": "<end>"
    },
    "name": "search_traces"
  }
}

Input Schema

NameRequiredDescriptionDefault
endYesEnd timestamp in RFC3339 format or Unix seconds
envNoEnvironment name (use UNSET if not configured)UNSET
limitNoMaximum number of traces to return
queryNoThe traces search query (use * for wildcard)*
startYesStart timestamp in RFC3339 format or Unix seconds
sortByNoSort results by: duration
serviceYesService name to filter by (REQUIRED, case-sensitive)
spanKindNoFilter by span kind: server, client, consumer, producer

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.1

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It usefully discloses that the backend API demands five values, that duration is in MILLISECONDS, and the rough return shape, but omits pagination/limit semantics, cost or performance characteristics of aggregate queries, and any auth or error behavior. It also asserts 'query, env, service, start, end are ALL REQUIRED by CubeAPM API' while the schema marks only service/start/end as required and gives query and env defaults — an internal inconsistency that can mislead an agent.

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?

Front-loaded with purpose and required-value rules, then organized under clear headings (TRACE QUERY SYNTAX, PIPE OPERATORS, STATS FUNCTIONS, examples) so an agent can skim to the part it needs. It is long — the operator and function inventories read like a reference manual — and the repeated 'IMPORTANT' labels plus duplicated selector syntax in the examples add some bulk, but nearly every line is actionable for query construction.

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?

For an 8-parameter tool with a bespoke query language, no annotations, and no output schema, this covers what an agent needs to formulate a correct call: required values, grammar, units, and worked examples. The remaining gap is the absence of returned-field detail beyond 'trace snippets with key spans' and no statement of limit/pagination behavior, which matters because the description is the only source for return semantics.

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 coverage is 100%, so the baseline would be 3, but the description adds substantial meaning the schema lacks: the query pipe grammar, stream-selector forms, the list of stats functions, the explicit warning that p95 must be written as quantile(0.95, duration), and enum-like values for spanKind and sortBy. The only deduction is the inaccurate required-parameter claim noted above, which partially undercuts the schema it is supplementing.

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?

States a specific verb and resource — 'Search for traces in CubeAPM matching the specified criteria' — plus what comes back ('trace snippets with key spans'). It is unambiguous on its own, but it never mentions the sibling get_trace, so an agent must infer that this is the multi-result search path rather than single-trace retrieval.

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?

There is heavy guidance on HOW to call it (required values, wildcard '*', env='UNSET', case-sensitive service names, a workflow hint to discover services via a metrics count query), but nothing on WHEN to prefer it over get_trace, query_logs, or the metrics tools. Usage is implied by the query-syntax section rather than stated as selection criteria.

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