PostHog MCP Server Cursor IDE Setup 2026
Connect PostHog's official remote MCP server to Cursor IDE with a personal API key and mcp-remote — query analytics, manage feature flags, and pull real error data into chat.
PostHog MCP Server Cursor IDE Setup 2026
How do you connect PostHog to Cursor IDE? Create a personal API key in PostHog scoped to the "MCP Server" preset, add a posthog entry to ~/.cursor/mcp.json that runs mcp-remote against https://mcp.posthog.com/mcp with that key in an Authorization: Bearer header, then restart Cursor. Once connected, Cursor can query product analytics, create and toggle feature flags, inspect error tracking issues, and pull experiment results directly into chat — without you tabbing over to the PostHog dashboard mid-conversation.
PostHog bundles product analytics, session replay, feature flags, A/B experiments, and error tracking into one product, and its MCP server exposes most of that surface as callable tools rather than just analytics queries. That's the actual pitch here: this isn't a read-only dashboard mirror, it's close enough to a full PostHog client that Cursor can flip a feature flag or check an error's stack trace in the same conversation where you're debugging the code that triggered it.
What the PostHog MCP Server Can Do
Once connected, typical prompts include:
The stripe_api_read-style breadth here comes from PostHog exposing a general SQL/HogQL query tool alongside its narrower, purpose-built ones — so questions that don't map to a pre-built tool ("compare retention between free and paid users who signed up in March") often still work, routed through the query tool instead of failing outright.
Prerequisites
node --version), with npx on your PATH (which npx) — the local bridge process needs this even though PostHog's server itself is remoteStep 1: Create a Personal API Key Scoped to MCP
1. Log in to PostHog and go to Settings → Personal API keys
2. Click Create personal API key
3. Choose the MCP Server preset if it's offered — this scopes the key to a sane default set of permissions instead of granting full account access
4. Restrict it to a specific project if you only need one, rather than leaving it account-wide
5. Copy the key immediately — PostHog shows it once
Treat this key like any other bearer credential: it's not a read-only token by default under the MCP preset, since flag creation and other write actions are part of the point. Keep it out of anything you commit to git.
Step 2: Confirm Your Region
PostHog runs two separate cloud regions with different API hosts:
https://mcp.posthog.com/mcphttps://mcp-eu.posthog.com/mcpCheck which region your account is on under Settings → Project → General before configuring the URL below — pointing a US-region key at the EU endpoint (or vice versa) fails authentication in a way that looks identical to a bad API key, which wastes time if you don't check this first.
Step 3: Add the Server to ~/.cursor/mcp.json
PostHog's server speaks Streamable HTTP directly, but the most broadly-compatible way to wire it into Cursor today is through mcp-remote, a small bridge that runs locally via npx and forwards to the remote endpoint with your auth header attached:
{
"mcpServers": {
"posthog": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://mcp.posthog.com/mcp",
"--header",
"Authorization:${POSTHOG_AUTH_HEADER}"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer YOUR_PERSONAL_API_KEY_HERE"
}
}
}
}
Swap the URL for the EU endpoint if that's your region. If your Cursor version supports native url-based remote MCP entries, you can also point directly at the endpoint with an Authorization header instead of routing through mcp-remote — but the bridge approach above works consistently across current and slightly older Cursor builds, which is why it's the safer default to document.
Step 4: Restart Cursor and Verify
Quit and reopen Cursor. Check Settings → MCP to confirm posthog shows as connected, then test in chat:
List the feature flags currently active in my PostHog project
Real flag names and rollout percentages coming back means the key and region are both correct. An empty list with no error usually means the key is valid but scoped to a project with no flags yet — try a broader analytics query instead to double-check.
Practical Workflows
Debug a Production Error Without Leaving the Editor
Show me the details and stack trace for the top unresolved error tracking
issue in PostHog from the last 24 hours, then help me find the matching
code path in this repo.
Ship Behind a Flag
Create a feature flag called checkout-redesign-v2, set it to roll out to
5% of users, and show me the code snippet for checking this flag in a
Next.js server component.
Check Whether a Feature Is Actually Moving the Needle
Pull the results for the onboarding-v2 experiment — is the treatment
group's activation rate meaningfully different from control yet, or is
it still too early to tell?
Answer a One-Off Analytics Question with SQL
Run a HogQL query against PostHog for daily active users by plan tier
over the last 30 days, and tell me if there's a clear trend before I
build a full dashboard for it.
Troubleshooting
Authentication fails even though the API key looks correct
Check your region first — a US-region key against the EU endpoint (or the reverse) fails auth the same way a wrong key does. Confirm under Settings → Project → General, then match the URL in your config.
mcp-remote process starts but nothing happens in Cursor
Confirm Node.js 18+ and that npx resolves on your PATH. Run the command manually in a terminal — npx -y mcp-remote@latest https://mcp.posthog.com/mcp --header "Authorization:Bearer YOUR_KEY" — and read whatever error it prints before assuming Cursor is the problem.
Feature flag tools work but analytics queries return nothing
Personal API keys can be scoped to a single project. If your analytics data lives in a different PostHog project than the one the key is scoped to, queries against it will come back empty rather than erroring — check the key's project scope in Settings → Personal API keys.
Write actions (creating flags, updating experiments) are rejected
The MCP Server preset generally includes write scopes, but if you created the key with a narrower custom scope, flag creation and experiment updates will fail with a permissions error even though read queries work fine. Recreate the key with the MCP Server preset rather than trying to patch scopes after the fact.
When Not to Use This
If you only need a handful of static metrics checked occasionally, embedding a PostHog dashboard link in your team wiki is simpler than wiring up MCP — the setup overhead isn't worth it for infrequent, predictable lookups. Where this earns its keep is the opposite pattern: ad hoc questions during active development ("did that last deploy change our error rate?"), where tabbing to a dashboard and building a one-off insight is slower than just asking. Also be deliberate about write access — a personal API key with the MCP preset can create and modify feature flags that gate real production behavior, so don't hand this connection to an agent running unattended without reviewing what it's about to toggle.
Frequently Asked Questions
Q: Do I need a paid PostHog plan to use the MCP server?
A: No — connecting to the MCP server and calling its tools is free. You're still bound by your existing PostHog plan's usage limits and billing for the underlying analytics events, session replays, or feature flag evaluations your queries touch.
Q: Why does my setup use mcp-remote instead of connecting directly to the URL?
A: PostHog's server speaks Streamable HTTP natively, and Cursor versions that support url-based remote MCP entries can connect directly with an Authorization header. mcp-remote is a compatibility bridge that works reliably across a wider range of Cursor versions, which is why it's the safer default — if you're on a recent build, a direct url entry works too.
Q: Can this MCP server modify production feature flags, or is it read-only?
A: It can modify them — creating and updating feature flags is one of the more commonly-used tools, not an oversight. That's useful for shipping behind flags conversationally, but it also means the personal API key behind this connection should be treated as a credential that can change real production behavior, not a read-only analytics viewer.
Q: I'm on PostHog's EU Cloud — does the setup change?
A: Only the URL. Use https://mcp-eu.posthog.com/mcp instead of the US endpoint in your mcp.json. Everything else — the personal API key creation, the mcp-remote bridge, the header format — is identical.
Q: Does this replace the PostHog SDK I use in my application code?
A: No. This is a development-time tool for querying and managing PostHog from your editor — checking flags, inspecting errors, running ad hoc analytics. Your application still captures events and evaluates flags through the regular PostHog SDK at runtime; that's a separate integration from this one.
Related Guides
---