Skip to main content

PostHog for coding agents

PostHog exposes a hosted Model Context Protocol (MCP) server at:
Use it when an agent needs to inspect analytics, error groups, feature flags, or dashboards while investigating a product question. The MCP connection is separate from Overdeck’s anonymous product telemetry; it accesses your PostHog account with the permissions you grant.

Connect with OAuth

OAuth is the recommended authentication path because it avoids copying a long-lived personal key into agent configuration. For Claude Code:
The first connection opens a browser login. The hosted endpoint routes the session to the correct PostHog region. PostHog also provides an interactive installer for supported clients:
For investigation-only sessions, restrict the exposed tools and writes:
You can also pin organization_id, project_id, features, or individual tools in the MCP URL. These filters reduce the agent’s available surface; they do not replace account permissions.

Clients without OAuth

Create a PostHog personal API key with the MCP Server preset, scope it to the smallest project and permissions the task needs, and send it as a Bearer token:
Do not use the public project ingestion key for MCP access. Do not commit a personal key to a repository, agent prompt, or shared context file.

PostHog CLI

Overdeck pins @posthog/cli for release source-map uploads. The CLI requires a personal API key, rather than the public ingestion key:
Create the key with the Source map upload preset or grant only error_tracking:write. POSTHOG_CLI_PROJECT_ID is the numeric project or environment ID accessible to that key. Use https://eu.posthog.com or your self-hosted URL when applicable. The release pipeline runs the equivalent of:
Injection and upload run against the exact dashboard bundle built by the npm release job. Overdeck removes source maps locally after the command, including when POSTHOG_CLI_API_KEY is absent, so maps cannot enter the published package. A missing key prints a warning and lets the release continue without a network call.

Safe agent-use pattern

  1. Start with OAuth and readonly=true for analytics or error investigation.
  2. Pin the PostHog project and expose only the feature families or tools the task needs.
  3. Grant a write scope only for an explicit write task, such as managing a feature flag, and remove it afterward.
  4. Keep CLI and MCP credentials in environment variables or the client’s secure credential store, never in repository files.
  5. Review any agent-proposed dashboard, flag, or experiment mutation before it reaches PostHog.
See the PostHog MCP documentation, MCP authentication and restrictions, and @posthog/cli documentation for the current tool and scope reference.