Skip to main content
OpenSRE connects to PostHog’s hosted Model Context Protocol (MCP) server, exposing PostHog’s products — product analytics, feature flags, error tracking, experiments, surveys, and HogQL queries — as tools the agent can call while investigating an incident. This is distinct from the PostHog REST integration, which only stores project credentials for the REST API. Use MCP when you want the agent to explore PostHog data directly during investigations. The onboarding wizard lists PostHog (REST) and PostHog (MCP) as separate choices — configure REST credentials with opensre integrations setup posthog.

Tools

The agent typically calls list_posthog_tools first to discover what is available for your project, then call_posthog_tool with the chosen tool name and arguments. The hosted PostHog MCP server exposes 240+ tools, each with a full input schema. Returning all of them at once is far larger than any model’s context window, so list_posthog_tools returns a compact, bounded listing — tool names plus short descriptions, without schemas. To work with it efficiently:
  • Pass name_filter (space- or comma-separated terms, e.g. "events query sql") to narrow the list to relevant tools.
  • Pass include_schema=true on a narrowed list to fetch the full input schema for the specific tool you intend to call.
To query events for a person or across a project, call call_posthog_tool with tool_name="execute-sql" and a HogQL query (e.g. SELECT event, count() FROM events WHERE ... GROUP BY event). There is no search_events tool.

Prerequisites

  • A PostHog account (US or EU — the hosted server routes you automatically)
  • A PostHog personal API key created with the MCP Server preset. See PostHog’s personal API keys docs.
OpenSRE defaults to read-only access (x-posthog-read-only: true) so investigations cannot mutate your PostHog project. Set POSTHOG_MCP_READ_ONLY=false only if you explicitly want the agent to perform writes.

Setup

Option 1: Interactive CLI

Select PostHog (MCP) when prompted, then paste your personal API key. The setup uses the hosted Streamable HTTP transport; keep the default URL unless you have a reason to change it. To run a local server instead, set POSTHOG_MCP_MODE=stdio via environment variables (see below). To skip the menu, name the service directly:

Option 2: Environment variables

Add to your .env:
To run a local PostHog MCP server instead of the hosted endpoint, use stdio mode:

Option 3: Persistent store

Verify

A successful check connects to the MCP server and reports how many tools it discovered. If it fails, the most common cause is a missing or invalid personal API key — confirm the key was created with the MCP Server preset and that outbound HTTPS to mcp.posthog.com is allowed.