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.

17.2 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 mcp_analytics
# Add one: pnpm --filter=@posthog/mcp run scaffold-yaml -- --add <operationId> --product mcp_analytics
# To keep an operation off on purpose, set enabled: false and give a disabled_reason.
category: MCP analytics
feature: mcp_analytics
url_prefix: /mcp-analytics
ui_apps: {}
tools:
    mcp-analytics-intent-clusters-recompute:
        operation: mcp_analytics_intent_clusters_recompute
        enabled: true
        scopes:
            - mcp_analytics:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Recompute intent clusters
        description: >
            Trigger an asynchronous recompute of the intent-cluster snapshot: sample recent sessions, attribute each
            tool call to its own agent intent, embed and cluster the intents, and derive the tool pivot (capture rates,
            discovery rates, description fit, overlaps). Returns immediately with status 'computing'; poll
            mcp-analytics-intent-clusters-retrieve for progress (status becomes 'idle' or 'error').
        requires_ai_consent: true
        feature_flag: mcp-analytics-intent-routing
    mcp-analytics-intent-clusters-retrieve:
        operation: mcp_analytics_intent_clusters_retrieve
        enabled: true
        scopes:
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Get intent cluster snapshot
        description: >
            Return the most recent intent-clustering snapshot for the project: clusters of similar agent intents (tool
            distribution, error rate, routing entropy, journey paths, error switches) plus a tool-centric pivot (per
            tool: the intent clusters it serves with capture share and rank, discovery rate against the advertised
            tools-list catalog, description-to-intent fit, contested score) and tool-overlap pairs competing for the
            same intents. computed_with carries sample-coverage percentages; treat counts as sample statistics. Returns
            an empty idle snapshot when no clustering run has happened yet — trigger one with
            mcp-analytics-intent-clusters-recompute.
        feature_flag: mcp-analytics-intent-routing
    mcp-analytics-sessions-generate-intent:
        operation: mcp_analytics_sessions_generate_intent
        enabled: true
        scopes:
            - mcp_analytics:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: true
        title: Generate session intent summary
        description: >
            Generate (or return the cached) LLM summary of the agent's goal for a session, derived from the session's
            recorded intents. The first call summarises and persists the result; subsequent calls return the stored
            summary.
        requires_ai_consent: true
    mcp-analytics-sessions-list:
        operation: mcp_analytics_sessions_list
        enabled: true
        scopes:
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        list: true
        title: List MCP sessions
        description: >
            List an MCP project's agent sessions — one row per $mcp_session_id, aggregated from that session's
            $mcp_tool_call events. Use it to see who is connecting and how active, long-lived, and tool-heavy sessions
            are: "which clients are most active this week?", "which sessions called tool X?", "how long do sessions
            usually run?", "which person's sessions made the most calls?", "which sessions hit errors?". Each row has
            session_id, tool_calls, error_calls (errored calls among those counted in tool_calls), session_start,
            session_end, tools_used, mcp_client_name, distinct_id (plus the resolved person_email / person_name when the
            distinct_id maps to a Person), distinct_id_count, and intent (empty until generated), newest session first.
            Sort with `order_by`, but note its keys are the underlying column names: sort tool_calls as
            `tool_call_count`, and `duration_seconds` (session length) is sortable even though it is not returned as a
            field; an unrecognised key silently falls back to newest-first. Also supports a case-insensitive `search`,
            `has_errors` (true for sessions with at least one errored call, false for sessions with none), a
            `date_from`/`date_to` window (default last 7 days), and `limit`/`offset` paging — see each parameter for the
            specifics. To then summarise a single session's goal, follow up with mcp-analytics-sessions-generate-intent.
    mcp-analytics-sessions-tool-calls:
        operation: mcp_analytics_sessions_tool_calls
        enabled: true
        scopes:
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        list: true
        title: List session tool calls
        description: >
            List a single session's $mcp_tool_call events in chronological order — the drill-down for a session found
            via mcp-analytics-sessions-list. Pass the session's session_id (the {id} path param); for sessions older
            than the default 7-day lookback, also pass its session_start as date_from so the event scan reaches them.
            Each call has tool_name, intent, timestamp, duration_ms, and is_error / error_message. Pages with limit
            (defaults to 500 — the whole page, since sessions rarely have more — max 500) and offset; the response's
            has_next flag indicates whether more calls remain.
    mcp-missing-capability-report:
        operation: mcp_analytics_missing_capabilities_create
        enabled: true
        scopes:
            - mcp_analytics:write
        annotations:
            readOnly: false
            destructive: false
            idempotent: false
        title: Report missing capability
        description: >
            Report that the current MCP tools are insufficient for the user's goal. Use this when a missing tool,
            missing workflow support, or missing explanation blocks progress. Describe the gap without personal data or
            sensitive query content. This records feedback for the PostHog team; continue with a fallback when possible.
        include_params:
            - goal
            - missing_capability
            - blocked
            - attempted_tool
wrappers:
    query-mcp-harness-breakdown:
        schema_ref: MCPHarnessBreakdownQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Break down MCP tool calls by harness
        description: >
            Group this project's MCP tool-call activity by the resolved client harness — the friendly product label for
            the MCP client (Claude Agent SDK, Claude Code, OpenAI Codex, Cursor, Claude.ai, …). Returns calls, error
            count, error rate, and session count per harness. Accepts the same dateRange / properties /
            filterTestAccounts filters as the dashboard and resolves the harness server-side over the same query runner,
            so results match the UI exactly. Use to answer "which harnesses use our MCP, and how reliably?".
        system_prompt_hint: MCP client/harness breakdown — calls, error rate, sessions per harness
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-stats:
        schema_ref: MCPToolStatsQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Summarise one MCP tool
        description: >
            Return the headline numbers for a single MCP tool over the window: total calls, error count, p50 and p95
            latency, unique users, unique sessions, and how many calls carried an intent. Pass toolName (the effective
            tool name — the inner tool is resolved server-side for single-exec wrapper calls, matching the tool-detail
            UI). Use to answer "how is tool X doing overall?" before drilling into failures, users, or neighbours.
        system_prompt_hint: One MCP tool's headline stats — calls, errors, p50/p95, users, sessions, intents
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-daily-stats:
        schema_ref: MCPToolDailyStatsQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Daily trend for one MCP tool
        description: >
            Return a day-by-day time series for a single MCP tool: calls, errors, p50/p95 latency, unique users, and
            unique sessions per day. Pass toolName (effective tool name, resolved server-side) and a dateRange. Use to
            answer "how has tool X trended?" — spotting error spikes, latency regressions, or adoption changes over
            time.
        system_prompt_hint: One MCP tool's day-by-day series — calls, errors, p50/p95, users, sessions
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-failures:
        schema_ref: MCPToolFailuresQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Top errors for one MCP tool
        description: >
            Return the most common failure buckets for a single MCP tool, each with the resolved client harness it came
            from. Failures are the errored $mcp_tool_call events ($mcp_is_error = true) — the same source as the error
            rate — grouped by $mcp_error_type and HTTP $mcp_error_status. Each bucket carries the raw error_type and
            error_status, which you can pass to query-mcp-tool-failure-occurrences to see individual errored calls with
            their error messages. Pass toolName (effective tool name, resolved server-side, matching the other
            tool-detail tools) and a dateRange. Use to answer "why is tool X failing?" or "what errors does tool X
            throw, and on which clients?".
        system_prompt_hint: One MCP tool's top failure buckets, by harness (error type + HTTP status)
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-failure-occurrences:
        schema_ref: MCPToolFailureOccurrencesQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Individual errored calls in one failure bucket
        description: >
            Return individual errored $mcp_tool_call events for a single MCP tool within one failure bucket, newest
            first (up to 50). Each occurrence carries the timestamp, distinct_id, session id, resolved harness, the
            agent's stated intent, the captured error message ($mcp_error_message — empty on events that predate message
            capture), and the HTTP status. Pass toolName plus the errorType (raw $mcp_error_type; "unknown" for events
            without one) and optional errorStatus exactly as returned by query-mcp-tool-failures — when errorStatus is
            omitted, only events without a status match. Use to answer "show me the actual errors" after a failure
            bucket looks suspicious.
        system_prompt_hint: Individual errored calls (with error messages) for one MCP tool's failure bucket
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-top-users:
        schema_ref: MCPToolTopUsersQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Top callers of one MCP tool
        description: >
            Return the top callers of a single MCP tool: per caller, the call count, error rate, resolved harness
            labels, last-seen time, and the caller's display name and email. Pass toolName (effective tool name,
            resolved server-side) and a dateRange. Use to answer "who uses tool X the most, and how reliably for them?".
        system_prompt_hint: One MCP tool's top callers — calls, error rate, harnesses, person email/name
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-neighbors:
        schema_ref: MCPToolNeighborsQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Tools called alongside one MCP tool
        description: >
            Return the tools most often called immediately before or after a single MCP tool within the same
            conversation. Pass toolName (effective tool name, resolved server-side), a dateRange, and neighborDirection
            ('before' or 'after'). Use to answer "what does an agent call around tool X?" — revealing common tool
            sequences and which tools pair up.
        system_prompt_hint: Tools co-occurring before/after one MCP tool in a conversation
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-sample-intents:
        schema_ref: MCPToolSampleIntentsQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Sample intents for one MCP tool
        description: >
            Return recent sample agent intents recorded for a single MCP tool, each with its resolved client harness.
            Pass toolName (effective tool name, resolved server-side) and a dateRange. Use to answer "what are agents
            actually trying to do when they call tool X?" — qualitative context behind the usage numbers.
        system_prompt_hint: Recent sample agent intents for one MCP tool, with harness
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-tool-descriptions:
        schema_ref: MCPToolDescriptionsQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: Descriptions seen for one MCP tool
        description: >
            Return the distinct effective tool-description strings seen for a single MCP tool over the window. Pass
            toolName (effective tool name, resolved server-side) and a dateRange. Use to spot description drift or a
            tool registered with more than one description across clients or versions.
        system_prompt_hint: Distinct effective descriptions seen for one MCP tool
        exclude_properties:
            - response
            - modifiers
            - version
            - tags
    query-mcp-missing-capabilities:
        schema_ref: MCPMissingCapabilitiesQuery
        enabled: true
        scopes:
            - query:read
            - mcp_analytics:read
        annotations:
            readOnly: true
            destructive: false
            idempotent: true
        title: List MCP missing-capability reports
        description: >
            Return capabilities that agents asked this MCP server for but could not access. Each row contains one
            $mcp_missing_capability report from the SDK's get_more_tools tool, including the report text, timestamp,
            client label, conversation id, and person. Results are chronological because exact-text grouping would split
            similar free-form requests. The query accepts a dateRange, case-insensitive text search, limit, and offset.
            Set filterTestAccounts to true to exclude the project's internal and test users. The response's has_next
            field indicates whether more results remain. Use this tool to identify capabilities that agents need or to
            prioritize new MCP tools.
        system_prompt_hint: MCP missing capabilities that agents reported, newest first
        exclude_properties:
            - response
            - modifiers
            - version
            - tags