PostHog for coding agents
PostHog exposes a hosted Model Context Protocol (MCP) server at:Connect with OAuth
OAuth is the recommended authentication path because it avoids copying a long-lived personal key into agent configuration. For Claude Code: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:PostHog CLI
Overdeck pins@posthog/cli for release source-map uploads. The CLI requires a
personal API key, rather than the public ingestion key:
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:
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
- Start with OAuth and
readonly=truefor analytics or error investigation. - Pin the PostHog project and expose only the feature families or tools the task needs.
- Grant a write scope only for an explicit write task, such as managing a feature flag, and remove it afterward.
- Keep CLI and MCP credentials in environment variables or the client’s secure credential store, never in repository files.
- Review any agent-proposed dashboard, flag, or experiment mutation before it reaches PostHog.
@posthog/cli documentation
for the current tool and scope reference.