Set up PostHog in Metorial for Claude, ChatGPT and Cursor
Share PostHog with your team in Claude, ChatGPT and Cursor through Metorial: OAuth or personal API key sign-in, 56 tools (30 read-only).
To give your team PostHog in Claude, ChatGPT, Cursor and other AI clients, an admin shares the PostHog integration in a Metorial portal, and each person signs in to PostHog with their own account. Agents can capture and analyze product usage events, manage feature flags, run A/B test experiments, and create user surveys. The integration has 56 tools, 30 read-only, 17 write and 9 destructive, plus 3 triggers.
What you'll learn
- How an admin shares PostHog in a portal and how each person connects
- The 31 OAuth scopes PostHog can request, and what each one allows
- How to keep the 30 read-only tools and reject the other 26
Before you start
- A portal with at least one access group
- An account with PostHog for each person who connects
- For the CLI steps: the Metorial CLI, signed in to your portal
Sign-in methods
| Method | Type | What a person provides |
|---|---|---|
| OAuth 2.0 (default) | OAuth | Signs in to PostHog after entering instanceUrl and projectToken |
| Personal API Key | API token | apiKey and projectToken |
Also available: OAuth 2.0 (Client Metadata URL).
The portal and metorial setup use OAuth 2.0 unless someone picks another method.
OAuth 2.0
Before the sign-in, setup asks for:
instanceUrl(optional): PostHog instance URL (leave empty for US cloud)projectToken(optional): Project API key/token for event capture and flag evaluation
People sign in to PostHog and approve the scopes you allow. The integration can request:
| Scope | Name | What it allows |
|---|---|---|
openid | OpenID | OpenID Connect authentication |
profile | Profile | Access user profile information |
action:read | Read Actions | Read actions |
action:write | Write Actions | Create and update actions |
activity_log:read | Read Activity Log | Read activity log entries |
annotation:read | Read Annotations | Read annotations |
annotation:write | Write Annotations | Create and update annotations |
cohort:read | Read Cohorts | Read cohorts |
cohort:write | Write Cohorts | Create and update cohorts |
dashboard:read | Read Dashboards | Read dashboards |
dashboard:write | Write Dashboards | Create and update dashboards |
experiment:read | Read Experiments | Read experiments (A/B tests) |
experiment:write | Write Experiments | Create and update experiments |
feature_flag:read | Read Feature Flags | Read feature flags |
feature_flag:write | Write Feature Flags | Create and update feature flags |
insight:read | Read Insights | Read insights |
insight:write | Write Insights | Create and update insights |
group:read | Read Groups | Read groups and group types |
group:write | Write Groups | Create and update group properties |
person:read | Read Persons | Read person profiles |
person:write | Write Persons | Update and delete person profiles |
organization:read | Read Organizations | Read organizations and discover projects |
user:read | Read Users | Read the current user profile |
project:read | Read Projects | Read project settings |
project:write | Write Projects | Update project settings |
session_recording:read | Read Session Recordings | Read session recording metadata |
survey:read | Read Surveys | Read surveys |
survey:write | Write Surveys | Create and update surveys |
event_definition:read | Read Event Definitions | Read event definitions |
property_definition:read | Read Property Definitions | Read property definitions |
query:read | Read Query | Run HogQL queries |
Personal API Key
To connect, a person enters these values:
apiKey: Personal API key (starts with phx_)projectToken(optional): Project API key/token for event capture and flag evaluation
Setup settings
Whichever method you pick, setup also asks for:
region(optional): PostHog cloud region or self-hosted One of "us", "eu", "self-hosted".instanceUrl(optional): Custom instance URL for self-hosted PostHog (e.g. https://posthog.example.com). Required when region is self-hosted.projectId(optional): PostHog project ID. Required for most private API endpoints.
Use your own PostHog OAuth app
With your own OAuth app, people see your company's name on the PostHog consent screen, and the client ID and secret belong to you.
Start the credentials in Metorial
In the dashboard, select Settings, then Organization Settings. Under Integrations and MCP, select Provider Auth, then Create Auth Credentials. Choose PostHog and copy the Redirect URI.
Register the app with PostHog
Create an OAuth app or client in PostHog and add the redirect URI from Metorial as its redirect or callback URL.
Finish in Metorial
Copy the app's client ID and client secret. Back in Metorial, enter a Name, the Client ID and the Client Secret, review Scopes, and select Create. Then pick these credentials for the PostHog integration.
Admin: share PostHog in a portal
In the dashboard
Open Shared Resources
Open Workforce, choose the portal, and select Shared Resources under Access.
Share a new integration
Select Share a Resource, then New Integration, and choose PostHog. Under Auth Method, keep OAuth 2.0 or pick another. For how members connect, choose Each person connects, so everyone signs in to PostHog as themselves.
Limit the tools
Under Tool Filters, set the write and destructive groups to Reject if agents should only read from PostHog.
Choose who gets it
Add the access groups that should see PostHog. When a person asks for access from the portal, the request appears under Access Requests.
With the CLI
The CLI cannot create the per-user PostHog integration. Once it exists, check which groups have it:
Employee: connect PostHog
In the portal
Open PostHog in the catalog
Sign in to your portal and open PostHog. The status reads Available.
Authenticate
Under Quick setup, select Authenticate. A PostHog sign-in tab opens. Sign in and approve the permissions listed.
Confirm
The status changes to Configured. If it later reads Needs reconnect, select Reconnect and sign in again.
With the CLI
catalog search prints the catalog item ID. metorial setup uses OAuth 2.0. To connect with Personal API Key instead, find its ID with metorial catalog get <catalog-item-id> and add --auth-method <auth-method-id>.
Add it to your AI client
metorial install adds your PostHog connection to a local MCP client such as Claude Code, Cursor or Codex. metorial list prints the integration ID and metorial client list the client identifiers.
For a client that takes a server URL, such as ChatGPT, metorial install custom <integration-id> creates an installation token and shows the endpoint details.
Make it read-only
Open the integration's Tool Filters and set the write and destructive groups to Reject. Agents keep the 30 read-only tools, such as run_query and find_group, and lose the 17 write tools, such as create_group or capture_event, and the 9 destructive tools, such as delete_action or delete_cohort.
Employees see the result on the integration's page in the portal under Tool access. For the full walkthrough, see Tool permissions.
Check it worked
metorial tools lists the 56 tools, minus any you rejected. get_current_user takes no input. It retrieves the current PostHog user, current organization, and current team/project context.
To see every input a tool takes, run metorial schema <integration-id> <tool-key>.
Tools
Read-only tools (30)
Show all 30 read-only tools
list_session_recordings: List session recording metadata.list_insights: List analytics insights (trends, funnels, retention, paths, stickiness, lifecycle).list_property_definitions: List all property definitions in the project.list_cohorts: List all cohorts in the project.get_feature_flag: Retrieve detailed information about a specific feature flag by its ID. NeedsflagId.get_experiment: Retrieve detailed information about a specific A/B test experiment including its configuration, metrics, and results. NeedsexperimentId.get_insight: Retrieve detailed information and results for a specific insight by its ID. NeedsinsightId.list_projects: List projects accessible with the current credentials.list_event_definitions: List all event definitions in the project.list_persons: Search and list person profiles in PostHog.get_dashboard: Retrieve detailed information about a specific dashboard by its ID, including its tiles and configuration. NeedsdashboardId.list_feature_flags: List all feature flags in the project.get_session_recording: Retrieve metadata about a specific session recording by its ID. NeedsrecordingId.list_annotations: List annotations on charts/dashboards.evaluate_feature_flags: Evaluate all feature flags for a specific user (distinct ID). NeedsdistinctId.get_person: Retrieve detailed information about a specific person by their PostHog person ID. NeedspersonId.get_survey: Retrieve detailed information about a specific survey by its ID, including questions, targeting, and status. NeedssurveyId.list_experiments: List A/B test experiments in the project.get_cohort: Retrieve detailed information about a specific cohort by its ID. NeedscohortId.list_surveys: List all surveys in the project with their configuration, questions, and status.list_dashboards: List all dashboards in the project.run_query: Execute an ad-hoc HogQL query against your PostHog data. Needsquery.get_annotation: Retrieve a specific PostHog annotation by ID. NeedsannotationId.get_action: Retrieve a specific PostHog action by ID, including its step rules. NeedsactionId.list_actions: List PostHog actions.list_group_types: List configured PostHog group types.list_groups: List groups for a specific PostHog group type. NeedsgroupTypeIndex.get_current_user: Retrieve the current PostHog user, current organization, and current team/project context.list_organizations: List PostHog organizations accessible with the current credentials.find_group: Find a specific PostHog group by group type index and group key. NeedsgroupTypeIndexandgroupKey.
Write tools (17)
create_experiment: Create a new A/B test experiment. Needsname.capture_event: Send one or more events to PostHog. Needsevents.create_dashboard: Create a new dashboard for organizing insights and analytics visualizations. Needsname.create_cohort: Create a new cohort. Needsname.update_dashboard: Update an existing dashboard's name, description, pinned status, or tags. NeedsdashboardId.update_experiment: Update an existing A/B test experiment's name, description, dates, or configuration. NeedsexperimentId.update_survey: Update an existing survey's name, description, questions, targeting, or dates. NeedssurveyId.create_survey: Create a new survey with questions and optional targeting. Needsname.create_annotation: Create a new annotation to mark a significant event or deployment on PostHog charts and dashboards. NeedscontentanddateMarker.update_feature_flag: Update an existing feature flag's name, active status, rollout percentage, or targeting configuration. NeedsflagId.create_feature_flag: Create a new feature flag. Needskey.update_group_property: Set or update properties for a PostHog group. NeedsgroupTypeIndex,groupKeyandgroupProperties.create_action: Create a PostHog action from event, selector, URL, or property matching steps. Needsname.create_group: Create or update a PostHog group for a configured group type. NeedsgroupTypeIndexandgroupKey.update_annotation: Update an annotation's content, date marker, or scope. NeedsannotationId.update_cohort: Update an existing cohort's name, description, static state, or filter groups. NeedscohortId.update_action: Update a PostHog action's metadata, tags, deletion state, or step rules. NeedsactionId.
Destructive tools (9)
delete_feature_flag: Permanently delete a feature flag. NeedsflagId.delete_survey: Permanently delete a survey. NeedssurveyId.delete_annotation: Delete an annotation from charts/dashboards. NeedsannotationId.delete_dashboard: Permanently delete a dashboard. NeedsdashboardId.delete_person: Permanently delete a person profile from PostHog. NeedspersonId.delete_cohort: Permanently delete a cohort from PostHog. NeedscohortId.delete_action: Delete a PostHog action. NeedsactionId.delete_experiment: Permanently delete an experiment from PostHog. NeedsexperimentId.delete_group_property: Delete one or more properties from a PostHog group. NeedsgroupTypeIndexandgroupKey.
Triggers
PostHog has 3 triggers, which fire on events in PostHog:
feature_flag_changes: Triggers when feature flags are created or updated.inbound_webhooknew_events: Triggers when new events are captured in PostHog.
Next steps
- Claude Code, Cursor, Codex and ChatGPT: connect each client to your portal and use PostHog there
- Create custom OAuth credentials: the Provider Auth screens in more detail
- Tool permissions: tool filters and what employees see
- PostHog on metorial.com: the integration overview