> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rootly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostHog AI Connector

> Connect Rootly AI to PostHog for read-only error, log, feature-flag, dashboard, and product analytics context.

The **PostHog** AI connector gives Rootly AI permission-scoped access to current product and operational signals during an investigation. Rootly AI can inspect errors, logs, feature-flag activity, dashboards, saved insights, and product analytics without changing your PostHog project.

<Info>
  Rootly fixes the connection to PostHog's read-only mode and a reviewed tool set. Rootly excludes project switching, arbitrary SQL, data creation, updates, and deletion.
</Info>

## Before You Start

You need:

* A PostHog account with access to the project Rootly AI should query.
* Permission in PostHog to approve the requested OAuth access.
* Permission in Rootly to manage AI connectors.

Choose the PostHog project that contains the errors, logs, feature flags, and analytics used during incident response. One Rootly team can have one active PostHog connection, and each connection operates in one active PostHog organization and project.

<Warning>
  Select a specific project during authorization. Organization-wide approval does not make Rootly query every project at once, and Rootly does not expose PostHog's organization or project switching tools. To use a different project, disconnect PostHog and connect it again with that project selected.
</Warning>

Rootly requests these OAuth scopes:

| Capability                           | OAuth scopes                                                          |
| ------------------------------------ | --------------------------------------------------------------------- |
| Identity and active context          | `openid`, `profile`, `email`, `user:read`, `project:read`             |
| Product analytics and saved insights | `query:read`, `insight:read`, `action:read`                           |
| Errors and logs                      | `error_tracking:read`, `logs:read`                                    |
| Feature flags and changes            | `feature_flag:read`, `activity_log:read`                              |
| Dashboards and data schema           | `dashboard:read`, `event_definition:read`, `property_definition:read` |

PostHog applies the authorizing user's permissions in addition to these scopes. Rootly AI cannot retrieve a project, dashboard, flag, or event that the user cannot access.

## Connect PostHog

Authorize the PostHog project Rootly AI should use.

<Steps>
  <Step title="Open AI Connectors">
    In Rootly, go to **AI & Agents → Connectors** and find the **PostHog** card.
  </Step>

  <Step title="Start the Connection">
    Click **Connect**. Rootly opens PostHog's authorization flow. You do not need to create an API key, client ID, or client secret.
  </Step>

  <Step title="Choose the PostHog Project">
    Sign in to the correct PostHog account, select the organization and project Rootly AI should query, and review the requested read scopes.

    Select a project rather than organization-wide access. Rootly's read-only tool set operates against the connection's active project and cannot switch projects later.
  </Step>

  <Step title="Approve Access">
    Approve the request in PostHog. PostHog routes the connection to the account's US or EU data region automatically.
  </Step>

  <Step title="Confirm the Connection">
    Return to **AI & Agents → Connectors**. The PostHog card shows **Connected** after Rootly validates the OAuth grant and approved tool catalog.
  </Step>
</Steps>

Rootly uses OAuth 2.0 with Dynamic Client Registration and Proof Key for Code Exchange (PKCE). The access and refresh credentials are encrypted at rest.

## What Rootly AI Can Read

Rootly exposes reviewed PostHog tools across six investigation categories.

| Category           | Available tools                                                                                                | What Rootly AI can inspect                                                                        |
| ------------------ | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Project and schema | `project-get`, `read-data-schema`                                                                              | Active project metadata, events, actions, properties, and property values.                        |
| Error tracking     | `query-error-tracking-issues-list`, `query-error-tracking-issue`, `query-error-tracking-issue-events`          | Error groups, issue details, affected events, and occurrence context.                             |
| Logs               | `query-logs`, `logs-count`, `logs-count-ranges`, `logs-patterns`, `logs-patterns-diff`, `logs-services-create` | Bounded log searches, counts, time ranges, recurring patterns, pattern changes, and top services. |
| Product analytics  | `insight-get`, `insights-list`, `query-trends`, `query-funnel`, `query-retention`                              | Saved insights, event trends, conversion funnels, and retention behavior.                         |
| Feature flags      | `feature-flag-get-all`, `feature-flag-get-definition-by-key`, `feature-flags-activity-retrieve`                | Flag definitions and activity history for change correlation.                                     |
| Dashboards         | `dashboard-get`, `dashboards-get-all`, `dashboard-insights-run`                                                | Dashboard metadata and current results from its insights.                                         |

The `logs-services-create` name comes from PostHog's API. In this connection it calculates and returns a read-only top-services aggregation; it does not create a PostHog resource.

Rootly sends both a fixed `readonly=true` restriction and the exact tool list to PostHog. Rootly also enforces the same allowlist before every call. Tools added by PostHog later do not become available automatically.

## Questions To Ask

Name the PostHog signal and a bounded time range when possible. These prompts work in Rootly AI SRE and the Slack agent:

* "What are the top unresolved PostHog errors affecting checkout in the last 24 hours? Include occurrence and affected-user counts."
* "Show the dominant error and fatal log patterns for `payment-api` since the incident began."
* "Compare this week's checkout failure log patterns with the previous week. What changed?"
* "Did any feature flag change in the 30 minutes before conversion dropped?"
* "Compare the signup funnel for the last seven days with the prior seven days. Which step regressed?"
* "Run the current insights on the payments dashboard and summarize the signals relevant to this incident."
* "Which events and properties are available for investigating failed subscription renewals?"

If a broad question returns irrelevant results, add the service, event, flag, dashboard, issue, and time window. For example, change *"What broke?"* to *"Find new fatal log patterns for `checkout-api` between 14:00 and 15:00 UTC and compare them with the preceding hour."*

## Data Handling and Permissions

* **On-demand queries.** Rootly AI calls PostHog when an investigation or direct question needs the data. The connection does not run a background ingestion job.
* **One active project.** Each Rootly team has one PostHog connection with one active organization and project.
* **PostHog permissions apply.** Results are limited by the authorizing user's access and the approved OAuth scopes.
* **Read-only allowlist.** Rootly exposes only the tools listed on this page and blocks every write-capable tool or tool that Rootly has not reviewed.
* **No arbitrary SQL.** Rootly excludes PostHog's SQL execution tools. Analytics use structured trends, funnel, retention, insight, and dashboard operations.
* **Encrypted credentials.** Rootly encrypts OAuth credentials at rest and removes them when you disconnect the AI connector.
* **AI traces may contain results.** PostHog responses can appear in Rootly AI model and observability traces. See [Data Privacy for Rootly AI](/ai/data-privacy-for-rootly-ai) for retention details.

PostHog's hosted MCP server proxies requests to the account's US or EU region and does not store the analytics results. PostHog API rate limits still apply to MCP calls.

## Manage the Connection

Open **AI & Agents → Connectors** and find the PostHog card.

* Click **Disconnect** to remove the stored OAuth credentials and stop future PostHog queries.
* Click **Connect** after disconnecting to authorize a different account, organization, or project.

Disconnecting does not change or delete data in PostHog.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The PostHog authorization page doesn't open" icon="triangle-exclamation">
    Confirm that your browser allows redirects from Rootly and that you can reach `mcp.posthog.com`. Sign in to PostHog in the same browser, then click **Connect** again.
  </Accordion>

  <Accordion title="Authorization completes but the card isn't Connected" icon="plug-circle-xmark">
    Rootly validates the OAuth grant by listing PostHog's approved tools. Disconnect any failed connection, confirm your PostHog access is active, and connect again. If the problem continues, contact Rootly support with the time of the failed attempt.
  </Accordion>

  <Accordion title="Results come from the wrong PostHog project" icon="diagram-project">
    A connection uses the active project selected during authorization. Disconnect PostHog, click **Connect**, and select the intended project. Rootly does not expose PostHog's project-switching tool.
  </Accordion>

  <Accordion title="A known error, flag, dashboard, or event is missing" icon="magnifying-glass">
    Sign in to PostHog as the authorizing user and confirm the item exists in the connected project and is visible to that user. Then retry with its exact name or key and a bounded time range.
  </Accordion>

  <Accordion title="PostHog queries start returning authorization errors" icon="key">
    The OAuth grant may have been revoked, the user's project access may have changed, or the refresh credential may have expired. Disconnect the AI connector and authorize it again.
  </Accordion>

  <Accordion title="A broad question returns irrelevant results" icon="filter">
    Add the signal type, service or event name, and time range. Ask separate questions for errors, logs, flags, and product analytics when the investigation spans several PostHog products.
  </Accordion>
</AccordionGroup>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Can Rootly AI change feature flags or PostHog data?" icon="shield">
    No. Rootly forces PostHog's read-only mode, requests read scopes, filters the hosted catalog to the reviewed tools listed on this page, and enforces that allowlist before each call.
  </Accordion>

  <Accordion title="Why should I select a project instead of the whole organization?" icon="diagram-project">
    One MCP connection has one active organization and project. Rootly excludes the switching tools, so selecting the intended project keeps every investigation in a predictable context. Organization-wide approval does not query all projects together.
  </Accordion>

  <Accordion title="Can I connect multiple PostHog projects?" icon="layer-group">
    A Rootly team supports one active PostHog connection. To use another project, disconnect the current connection and authorize the replacement project.
  </Accordion>

  <Accordion title="Do I need a PostHog personal API key?" icon="key">
    No. Rootly uses PostHog's OAuth flow and stores the resulting credentials encrypted. Do not paste a personal API key into Rootly.
  </Accordion>

  <Accordion title="Which PostHog data region does Rootly use?" icon="globe">
    PostHog routes the hosted MCP connection to the US or EU region associated with the account you authorize.
  </Accordion>
</AccordionGroup>

## Related Pages

<CardGroup cols={2}>
  <Card title="AI Connectors" icon="sparkles" href="/ai/connectors/overview">
    Browse every data source Rootly AI can use during an investigation.
  </Card>

  <Card title="Rootly AI Data Privacy" icon="shield" href="/ai/data-privacy-for-rootly-ai">
    Review encryption, retention, trace handling, and model controls.
  </Card>

  <Card title="PostHog MCP Overview" icon="arrow-up-right-from-square" href="https://posthog.com/docs/model-context-protocol">
    Review PostHog's hosted MCP server and authentication behavior.
  </Card>

  <Card title="PostHog MCP Tools" icon="arrow-up-right-from-square" href="https://posthog.com/docs/model-context-protocol/tools">
    Browse PostHog's complete upstream tool catalog.
  </Card>
</CardGroup>
