PostHog MCP FAQ and advanced setup
Contents
Everything you need to know about authentication, scoping, filtering, safety, and billing for the PostHog MCP server. If you're just getting started, head to the overview or the use cases page first.
Be mindful of prompt injection – LLMs can be tricked into following untrusted commands, so always review tool calls before executing them.
Frequently asked questions
What is the PostHog MCP server?
The PostHog MCP server is a hosted Model Context Protocol endpoint that exposes PostHog's products – feature flags, product analytics, error tracking, experiments, SQL queries, CDP, surveys, and more – as function-calling tools to any MCP-compatible AI agent.
How much does it cost?
It's free. Connecting to the MCP server and calling its tools doesn't incur any charges on your PostHog bill. Standard PostHog usage and billing still apply to the underlying data your queries consume.
Which AI clients and editors are supported?
Anything that speaks MCP works. We've tested and documented setup for Claude Code, Claude Desktop, Cursor, Codex, VS Code, Windsurf, and Zed. The PostHog Wizard can install the server into most of these in one command.
Do I need to create an API key?
No, OAuth is the recommended path and works out of the box with the wizard. If your client doesn't support OAuth, you can use a personal API key with the MCP Server preset – see the API key authentication section below.
Where is my data sent?
The MCP server acts as a proxy to your PostHog instance and is automatically routed to the correct region (US or EU) based on the account you sign in with. It does not store your analytics data – queries are executed against your PostHog project and results are returned directly to your AI client.
Is it safe to let an agent write to my project?
Be mindful of prompt injection – LLMs can be tricked into following untrusted commands, so always review tool calls before executing them. You can also restrict the session to specific tools or feature categories using tool filtering, and pin the agent to a specific organization or project to limit blast radius.
Advanced configuration
Using an API key instead of OAuth
If your MCP client doesn't support OAuth, you can authenticate manually:
- Create a personal API key using the MCP Server preset (this scopes access to a specific project)
- Add the
Authorization: Bearer YOUR_API_KEYheader to your MCP configuration
Example for Cursor (add to .cursor/mcp.json):
Pinning to a specific organization or project
If you're building a programmatic integration or want to restrict the MCP session to a specific organization or project, you can pin the context using headers or query parameters.
When you pin the context, the switch-organization and switch-project tools are automatically excluded from the available tool list:
- When
projectIdis provided: bothswitch-organizationandswitch-projectare excluded - When only
organizationIdis provided: onlyswitch-organizationis excluded
Headers:
x-posthog-organization-id- Pin to a specific organizationx-posthog-project-id- Pin to a specific project
Query parameters:
organization_id- Pin to a specific organizationproject_id- Pin to a specific project
Example for Cursor (add to .cursor/mcp.json):
Filtering available tools
You can limit which tools are available using two query parameters, individually or together.
Filter by feature category
The features parameter exposes all tools belonging to one or more feature categories:
Available features:
| Feature | Description |
|---|---|
workspace | Organization and project management |
actions | Action definitions |
activity_logs | Activity log viewing |
alerts | Alert management |
annotations | Annotation management |
cohorts | Cohort management |
conversations | Support ticket management |
dashboards | Dashboard creation and management |
data_schema | Data schema exploration |
data_warehouse | Data warehouse management |
debug | Debug and diagnostic tools |
docs | PostHog documentation search |
early_access_features | Early access feature management |
error_tracking | Error monitoring and debugging |
events | Event and property definitions |
experiments | A/B testing experiments |
flags | Feature flag management |
hog_functions | CDP function management |
hog_function_templates | CDP function template browsing |
insights | Analytics insights |
llm_analytics | LLM analytics evaluations |
prompts | LLM prompt management |
logs | Log querying |
notebooks | Notebook management |
persons | Person and group management |
reverse_proxy | Reverse proxy record management |
search | Entity search across the project |
sdk_doctor | SDK health diagnostics |
sql | SQL query execution |
surveys | Survey management |
workflows | Workflow management |
Note: Hyphens and underscores are treated as equivalent in feature names (e.g.,
error-trackinganderror_trackingboth work).
Filter by tool name
The tools parameter exposes specific tools by their exact name. Use the tools reference to find the names you need:
Combining both parameters
When both features and tools are provided, they act as a union — a tool is exposed if it matches a feature category or is listed by name. This lets you select a whole feature group and surgically add individual tools from other categories:
If neither parameter is specified, all tools are available.
Example for Cursor (add to .cursor/mcp.json):
Prompts and resources
The MCP server provides resources, including framework-specific documentation and example code, to help agents build great PostHog integrations. You can try these yourself using the posthog:posthog-setup prompt, available via a slash command in your agent. Just hit the / key.
Currently we support Next.js, with more frameworks in progress.
Privacy and support
- Privacy Policy: posthog.com/privacy
- Terms of Service: posthog.com/terms
- Support: posthog.com/questions or in-app support
The MCP server acts as a proxy to your PostHog instance. It does not store your analytics data – all queries are executed against your PostHog project and results are returned directly to your AI client.
Keep exploring
- Use cases – example prompts and multi-step recipes
- Tools reference – every tool the MCP server exposes
- Overview – back to the MCP overview and install instructions