Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

7.9 KB
Raw Blame
# MCP tool definitions. Tools are opt-in: an operation is exposed only when it has an entry here.
# List operations without an entry: pnpm --filter=@posthog/mcp run scaffold-yaml -- --candidates --product tracing
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product tracing
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: Tracing
feature: tracing
url_prefix: /tracing
ui_apps:
    trace-span:
        type: detail
        view_prop: data
    trace-span-list:
        type: list
        detail_tool: apm-trace-get
        detail_args: '{ trace_id: item.trace_id }'
        item_name_field: name
        click_prop: onSpanClick
tools:
    apm-attribute-breakdown:
        operation: tracing_spans_attribute_breakdown_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Break down spans by attribute value
        description_file: ./prompts/apm-attribute-breakdown.md
        feature_flag: tracing
        response:
            include:
                - results
                - compare
    apm-attribute-values-list:
        operation: tracing_spans_values_retrieve
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: List tracing attribute values
        description: >
            List values for a specific span or resource attribute key. Use to discover what values exist for a given
            attribute before building filters.
        feature_flag: tracing
        response:
            include:
                - results
    apm-attributes-list:
        operation: tracing_spans_attributes_retrieve
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: List tracing span attributes
        description: >
            List available span or resource attribute names. Use attribute_type "span_attribute" for span-level
            attributes or "span_resource_attribute" for resource-level attributes (e.g. k8s labels). Use this to
            discover available attribute keys before building filters.
        feature_flag: tracing
        response:
            include:
                - results
                - count
    apm-service-health:
        operation: tracing_spans_service_health_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Service health against a baseline
        description_file: ./prompts/apm-service-health.md
        feature_flag: tracing
    apm-services-list:
        operation: tracing_spans_service_names_retrieve
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: List tracing service names
        description: >
            List distinct service names that have emitted trace spans. Use to discover available services before
            filtering spans by service name.
        param_overrides:
            dateRange:
                cast: object-json-string
        feature_flag: tracing
        response:
            include:
                - results
    apm-spans-aggregate:
        operation: tracing_spans_aggregate_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Aggregate span statistics
        description_file: ./prompts/apm-spans-aggregate.md
        feature_flag: tracing
        response:
            include:
                - results
                - compare
                - has_more
                - next_offset
    apm-spans-count:
        operation: tracing_spans_count_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Count spans
        description_file: ./prompts/apm-spans-count.md
        feature_flag: tracing
        response:
            include:
                - count
                - traceCount
    apm-spans-duration-histogram:
        operation: tracing_spans_duration_histogram_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Trace duration distribution (histogram)
        description_file: ./prompts/apm-spans-duration-histogram.md
        feature_flag: tracing
        response:
            include:
                - results
    apm-spans-latency-heatmap:
        operation: tracing_spans_latency_heatmap_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Latency over time (heatmap)
        description_file: ./prompts/apm-spans-latency-heatmap.md
        feature_flag: tracing
        response:
            include:
                - results
    apm-spans-sparkline:
        operation: tracing_spans_sparkline_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Span counts over time (sparkline)
        description_file: ./prompts/apm-spans-sparkline.md
        feature_flag: tracing
        response:
            include:
                - results
    apm-spans-tree:
        operation: tracing_spans_tree_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Aggregate span call tree
        description_file: ./prompts/apm-spans-tree.md
        feature_flag: tracing
        response:
            include:
                - results
                - compare
    apm-trace-get:
        operation: tracing_spans_trace_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        enrich_url: ?trace={params.trace_id}
        title: Retrieve trace spans
        description: >
            Fetch all spans for a specific trace by its hex trace ID. Returns the full span tree for the trace including
            parent-child relationships, timing, status information, and each span's attributes map. Each span carries
            self_time_nano — its duration not covered by child spans — so "where did the wall-clock go" is answered by
            sorting on it: a large self_time_nano on a parent span is an uninstrumented gap, not time in any child. Use
            this to inspect a specific trace in detail after discovering it via the query tool. Set excludeAttributes to
            true to drop the per-span attributes map (which can hold multi-KB values like db.statement) and keep the
            payload compact.
        ui_app: trace-span-list
        feature_flag: tracing
        response:
            include:
                - results
    query-apm-spans:
        operation: tracing_spans_query_create
        enabled: true
        scopes:
            - tracing:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Query tracing spans
        description_file: ./prompts/query-apm-spans.md
        ui_app: trace-span-list
        feature_flag: tracing
        response:
            include:
                - results