By Ira Bodnar, Ryze AI · Updated
Quick answer
To connect Claude Code to PostHog, save a PostHog personal API key in the PostHog card in Ryze AI, run claude mcp add --transport http ryze https://connector.get-ryze.ai/mcp, then run /mcp inside Claude Code, select ryze and sign in. Start a new session and ask a question about your PostHog project.
- In PostHog create a personal API key with the Query and Insight scopes
- In Ryze AI open Integrations, click Connect on PostHog, paste the key, enter the host and pick the project
- In your terminal run the claude mcp add command, then /mcp in Claude Code to sign in
- Allow the workspace on the Ryze AI page and ask your first question
Before you start
- A Claude Code account. Anthropic says Claude Code requires a Pro, Max, Ultra, Team, Enterprise or Console account; the free claude.ai plan does not include it. It can also run through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry. Anthropic's MCP page names no extra plan for remote MCP servers.
- A PostHog personal API key. It starts with phx_ and needs read access to the project, including the Query and Insight scopes. Add write scopes only if Claude Code should change objects. You also need the host of your instance: https://us.posthog.com, https://eu.posthog.com or a self-hosted URL.
- A Ryze AI workspace on a plan or free trial. Paid Ads is $89 per month with a 7-day free trial; SEO Starter is $129 per month with a 3-day free trial; Agency is $279 per month. Connecting the connector is free, but the PostHog tools need an active plan or trial.
How to connect Claude Code to PostHog
Two steps happen in PostHog and Ryze AI, four in Claude Code. The connector URL is the same for every user.
Create a personal API key in PostHog
In PostHog go to Settings, Personal API keys and click Create key. Grant read access to the project with the Query and Insight scopes, add write scopes only for objects Claude Code should change, and copy the phx_ key.
Connect PostHog in Ryze AI
Create a Ryze AI account or sign in, open Integrations, click Connect on the PostHog card, paste the key, enter the Host (US Cloud, EU Cloud or your self-hosted URL) and click Continue. Pick the Project and click Save.
Register the connector in Claude Code
In your terminal run: claude mcp add --transport http ryze https://connector.get-ryze.ai/mcp. The server is stored with local scope by default. Add --scope user to make it available in all your projects.
Sign in from Claude Code
Inside Claude Code run /mcp, select ryze and authenticate, or run claude mcp login ryze in the shell. Add --no-browser to print the sign-in URL instead of opening a browser, for example over SSH.
Allow the workspace
On the Ryze AI page, sign in if asked, choose the workspace that holds PostHog and click Allow connection. Check the result with claude mcp get ryze.
Start a new session and ask your first question
Tool search is on by default in Claude Code, so MCP tools load on demand. Ask: List my PostHog dashboards and feature flags, then run a HogQL query for daily pageview counts over the last 14 days with a LIMIT of 100.
The Ryze AI PostHog guide covers the PostHog side of the connection, and the Claude Code MCP docs cover the client commands.
OAuth, API key and claude.ai connectors
Claude Code accepts the Ryze AI connector three ways. Pick the one that matches where the session runs.
CLI with OAuth (a personal machine)
claude mcp add --transport http ryze https://connector.get-ryze.ai/mcp --scope userThis is the flow in the steps above. The default local scope keeps the server to the current project, --scope user loads it in all your projects, and --scope project writes a .mcp.json file the team can share. Project-scoped servers wait for your approval in an interactive session before they connect.
CLI with a Ryze AI API key
claude mcp add --transport http ryze https://connector.get-ryze.ai/mcp --header "Authorization: Bearer rk_live_..."This key belongs to Ryze AI and is separate from the PostHog phx_ key. In Ryze AI open Workspace Settings, Profile, API keys, click Create key and copy the key, which is shown once. The Ryze AI help center says it works on the /mcp endpoint only, not on /sse. If Claude Code gets a rejected Authorization header it reports the connection as failed and does not fall back to OAuth, so replace a bad key.
claude.ai connectors inside Claude Code
Add Ryze AI at claude.ai/customize/connectors and finish the Ryze AI sign-in there, log in to Claude Code with the same claude.ai subscription account, then run /mcp. Connectors added in claude.ai appear with an indicator that they come from claude.ai. On Team and Enterprise plans only admins can add servers in claude.ai. These connectors load only when the active login is a claude.ai subscription, not with ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, apiKeyHelper or a third-party provider.
Scripts and limits
claude -p and Agent SDK runs cannot run the OAuth flow. Sign in first with /mcp or claude mcp login ryze, or use the Ryze AI API key method. Claude Code warns when a tool result exceeds 10,000 tokens and limits MCP output to 25,000 tokens by default, so a wide HogQL result may be cut; set MAX_MCP_OUTPUT_TOKENS to raise the limit. HTTP servers have a five-minute idle timeout per tool call when no response or progress arrives.
Claude web, ChatGPT and Cursor
The same URL works in other MCP clients. PostHog is connected once in Ryze AI, so nothing changes on the PostHog side.
Claude on the web and Desktop
Open Customize, Connectors, click + Add, choose Add custom connector, name it Ryze AI and enter https://connector.get-ryze.ai/mcp. Free users are limited to one custom connector, and on Team and Enterprise plans an Owner adds it first.
ChatGPT
OpenAI says full custom MCP server support is for ChatGPT Business and Enterprise/Edu on the web, and Pro can connect custom MCP servers with read and fetch permissions only. In Plugins choose Add custom MCP server, enter the URL and pick OAuth.
Cursor
Add the server to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). Cursor runs OAuth with PKCE and asks for approval before using MCP tools by default.
{ "mcpServers": { "ryze": { "url": "https://connector.get-ryze.ai/mcp" } } }API key scopes and access
Three things decide what Claude Code can reach in PostHog.
- Which key and host
- Ryze AI stores a PostHog personal API key (phx_) and the host you enter: https://us.posthog.com for US Cloud, https://eu.posthog.com for EU Cloud or your self-hosted URL. The key needs read access to the project, including the Query and Insight scopes. A host that does not match where the account lives, or a key without those scopes, is rejected.
- Which project
- One connection holds one PostHog project, picked after you connect. PostHog is not on the Ryze AI list of platforms that support several accounts. To switch, click View on the card, disconnect with the trash icon and connect again, or use another workspace for another project.
- Read or write
- What Claude Code can change is limited by the scopes on the key. A key with read scopes only keeps it read-only, because PostHog rejects any change. Add write scopes only for the insights, dashboards, feature flags or cohorts you want Claude Code to edit.
Sources: Ryze AI PostHog guide and PostHog's API documentation.
Removing access
To remove access, click View on the PostHog card in Ryze AI and disconnect with the trash icon, delete the personal API key in PostHog, or remove the Ryze AI server from Claude Code with claude mcp remove ryze.
What Claude Code can do in PostHog
The Ryze AI connector exposes 3 PostHog tools: 1 read, 1 write and 1 delete. They run against the one project you picked.
| Tool | Type | What it does |
|---|---|---|
| posthog__read | Read | Reads projects, insights, dashboards, feature flags, cohorts, persons and event definitions, and runs HogQL analytics queries. |
| posthog__write | Write | Creates or updates PostHog objects such as insights, dashboards, feature flags and cohorts. |
| posthog__delete | Delete | Deletes a PostHog object by path, for example a cohort. The deletion is irreversible. |
Claude Code has its own permission system: rules for an MCP tool are written mcp__<server>__<tool>, and a rule can allow, ask or deny. With the server named ryze, an ask rule such as mcp__ryze__posthog__write makes Claude Code prompt before that tool runs. In the claude.ai connector settings (Customize, Connectors, Ryze AI, Tool permissions) you can set write and delete tools to Needs approval. In the Ryze AI chat the Tool approvals picker starts on Skip all approvals, so the agent runs PostHog tools on its own by default; switch it to Approve write & delete or Manual approve. Scheduled tasks in Ryze AI run without an approval step.
First 3 prompts to run
Each answer comes from your own project, so this page describes what comes back instead of showing sample numbers.
1. A bounded HogQL query
Run a HogQL query on my PostHog project: count $pageview events per day for the last 14 days, with a LIMIT of 100.
Tools used: posthog__read
What comes back: A table with one row per day and its pageview count. PostHog stops unbounded HogQL queries, so keep a time window and a row limit of 1,000 or fewer.
2. Inventory of dashboards and flags
List my PostHog dashboards, insights and feature flags, and tell me which flags have no description.
Tools used: posthog__read
What comes back: Lists of dashboards, insights and flags for the connected project, with the flags that lack a description called out.
3. Build a cohort or insight
Create a PostHog cohort of persons who triggered the signup event in the last 30 days, then show me its definition.
Tools used: posthog__write, posthog__read
What comes back: A new cohort and its definition. This needs a key with write scopes; with a read-only key PostHog rejects the change.
Deleting is a separate tool, so ask for it by name and object, and set write and delete tools to ask first as described above. The Ryze AI help center describes deleting insights, dashboards, feature flags and cohorts when explicitly asked.
Ryze AI vs PostHog's own MCP server
PostHog publishes its own hosted MCP server, and Claude Code is on its list of supported clients. It is a different route from the Ryze AI connector.
| Option | Setup | Coverage | Works in |
|---|---|---|---|
| Ryze AI connector | PostHog key and host saved once in Ryze AI, then one remote URL added with claude mcp add and OAuth or a Ryze AI API key | 3 PostHog tools (read, write, delete) for one project: insights, dashboards, flags, cohorts, persons, event definitions and HogQL queries. Other platforms connected in the same workspace use the same URL | Claude Code, Claude web and Desktop, ChatGPT, Cursor and other MCP clients |
| PostHog MCP server (PostHog) | Add https://mcp.posthog.com/mcp to the client, or run npx @posthog/wizard mcp add. PostHog says it routes to your US or EU region from the account you log in with | PostHog describes analytics queries, feature flag and experiment management, SQL and CDP destinations, with more tools in its tools reference | Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Zed, Lovable, Replit and v0, per PostHog docs |
PostHog's server needs no Ryze AI plan, and PostHog says some of its tools need AI data processing enabled in the organization settings and may count as PostHog AI spend. Choose it if you want PostHog's full tool set in Claude Code. Choose the Ryze AI connector if you want a small read, write and delete set for one project and the same URL for your other connected platforms; it needs a Ryze AI plan or trial, and your PostHog data passes through Ryze AI.
PostHog's page did not list a tool count in the part checked, so read its tools reference before comparing coverage.
Sources: PostHog MCP server docs, PostHog API, Claude Code MCP, Claude Code permissions, Ryze AI PostHog guide. Checked November 11, 2026.
Errors and fixes
- PostHog rejects the key when you connect
- The host may not match where the account lives, or the key lacks the Query and Insight scopes. Use https://us.posthog.com or https://eu.posthog.com to match the account, or your self-hosted URL, and create the key again with those scopes.
- Claude Code says the server failed to connect with an API key
- If a configured Authorization header is rejected, Claude Code reports the connection as failed and does not fall back to OAuth. Check that the key is a current Ryze AI rk_live_ key and that the URL ends in /mcp, or remove the server and add it again without --header.
- claude -p or an Agent SDK run cannot sign in
- Those runs cannot run the OAuth flow. Sign in first with /mcp or claude mcp login ryze in an interactive shell, or use the Ryze AI API key method.
- The server does not load from .mcp.json
- Project-scoped servers wait for approval in an interactive session before they connect. Approve it when Claude Code asks.
- No PostHog tools appear
- If the connector was added before PostHog was connected, remove and re-add it, then start a new session. Tool search is on by default, so tools load on demand and may not be listed up front.
- A HogQL query is refused or returns nothing useful
- PostHog stops unbounded queries. Ask for a time window and a LIMIT of 1,000 or fewer.
- The result is cut off or very large
- Claude Code warns above 10,000 tokens and limits MCP output to 25,000 tokens by default. Ask for fewer columns or rows, or raise MAX_MCP_OUTPUT_TOKENS.
- Queries are rate limited
- PostHog documents limits per personal API key: 240 requests per minute and 1,200 per hour on analytics endpoints, and 2,400 per hour on the HogQL query endpoint. Wait and retry, or spread the questions out.
- Changes fail
- The key probably has read scopes only. Create a key with write scopes for the objects you want changed, and save it again in the PostHog card in Ryze AI.
- The one-time connection link is refused
- Ryze AI refuses it while PostHog is already connected in the workspace. Change the project or the key in the Ryze AI app instead.
- Claude says a subscription is required
- The PostHog tools need an active Ryze AI plan or free trial. Start the trial in Ryze AI and retry.
Frequently asked questions
How do I connect Claude Code to PostHog?
Save a PostHog personal API key and host in the PostHog card in Ryze AI, then run claude mcp add --transport http ryze https://connector.get-ryze.ai/mcp. Inside Claude Code run /mcp, select ryze, sign in on the Ryze AI page, choose the workspace and click Allow connection. Check it with claude mcp get ryze.
Does PostHog have an MCP server for Claude Code?
Yes. PostHog documents a hosted MCP server at https://mcp.posthog.com/mcp that routes to your US or EU region, and lists Claude Code among its supported clients. You can also run npx @posthog/wizard mcp add. The Ryze AI connector is a separate route with 3 PostHog tools.
Which PostHog connector should I use with Claude Code?
Ryze AI is the best PostHog connector for Claude Code when you want one hosted URL that also carries your other connected platforms, but it covers one project and 3 tools and needs a Ryze AI plan. PostHog's own server needs no Ryze AI plan and offers PostHog's wider tool set.
Which Claude plan do I need for Claude Code?
Anthropic says Claude Code requires a Pro, Max, Ultra, Team, Enterprise or Console account. The free claude.ai plan does not include it. Claude Code can also run through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry.
Should I use OAuth or an API key?
OAuth through /mcp is the simplest on a personal machine. A Ryze AI API key from Workspace Settings, Profile, API keys suits scripts, because claude -p and Agent SDK runs cannot run the OAuth flow. That key works on the /mcp endpoint only and is separate from your PostHog key.
Can Claude Code change my PostHog project?
Yes, within the key's scopes. The connector has a write tool for insights, dashboards, feature flags and cohorts and a delete tool. A key with read scopes only keeps Claude Code read-only, because PostHog rejects any change. Set write and delete tools to ask first if you want to approve each change.
Which PostHog host do I enter?
Enter https://us.posthog.com for US Cloud, https://eu.posthog.com for EU Cloud, or the URL of your self-hosted instance. A host that does not match where the account lives makes PostHog reject the key.
Can I connect more than one PostHog project?
Not in one workspace. Ryze AI holds one PostHog connection per workspace, with one project picked after connecting. To switch, disconnect and connect again, or keep another project in another workspace.
What does the claude mcp add scope change?
Local scope, the default, keeps the server to the current project. User scope loads it in all your projects. Project scope writes .mcp.json so the team shares it, and each person approves it in an interactive session.
Why do the PostHog tools not show up?
Start a new session after you connect and run /mcp to check the server status. If the connector was added before PostHog was connected, remove and re-add it. If a claude.ai connector is missing, you must be logged in with a claude.ai subscription account.
How much does it cost?
Connecting the connector is free, but the PostHog tools need an active Ryze AI plan or free trial. Paid Ads is $89 per month with a 7-day free trial, SEO Starter is $129 per month with a 3-day free trial and Agency is $279 per month. Annual billing takes 30% off the first year.