MetorialDocs

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

Sign-in methods

MethodTypeWhat a person provides
OAuth 2.0 (default)OAuthSigns in to PostHog after entering instanceUrl and projectToken
Personal API KeyAPI tokenapiKey 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:

ScopeNameWhat it allows
openidOpenIDOpenID Connect authentication
profileProfileAccess user profile information
action:readRead ActionsRead actions
action:writeWrite ActionsCreate and update actions
activity_log:readRead Activity LogRead activity log entries
annotation:readRead AnnotationsRead annotations
annotation:writeWrite AnnotationsCreate and update annotations
cohort:readRead CohortsRead cohorts
cohort:writeWrite CohortsCreate and update cohorts
dashboard:readRead DashboardsRead dashboards
dashboard:writeWrite DashboardsCreate and update dashboards
experiment:readRead ExperimentsRead experiments (A/B tests)
experiment:writeWrite ExperimentsCreate and update experiments
feature_flag:readRead Feature FlagsRead feature flags
feature_flag:writeWrite Feature FlagsCreate and update feature flags
insight:readRead InsightsRead insights
insight:writeWrite InsightsCreate and update insights
group:readRead GroupsRead groups and group types
group:writeWrite GroupsCreate and update group properties
person:readRead PersonsRead person profiles
person:writeWrite PersonsUpdate and delete person profiles
organization:readRead OrganizationsRead organizations and discover projects
user:readRead UsersRead the current user profile
project:readRead ProjectsRead project settings
project:writeWrite ProjectsUpdate project settings
session_recording:readRead Session RecordingsRead session recording metadata
survey:readRead SurveysRead surveys
survey:writeWrite SurveysCreate and update surveys
event_definition:readRead Event DefinitionsRead event definitions
property_definition:readRead Property DefinitionsRead property definitions
query:readRead QueryRun 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:

metorial-admin portals access list <portal-id> --type provider_template --search posthog

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

metorial catalog search posthog
metorial setup <catalog-item-id>

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.

metorial list posthog
metorial client list
metorial install <client-identifier> <integration-id>

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 list posthog
metorial tools <integration-id>
metorial call <integration-id> get_current_user -d '{}'

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. Needs flagId.
  • get_experiment: Retrieve detailed information about a specific A/B test experiment including its configuration, metrics, and results. Needs experimentId.
  • get_insight: Retrieve detailed information and results for a specific insight by its ID. Needs insightId.
  • 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. Needs dashboardId.
  • list_feature_flags: List all feature flags in the project.
  • get_session_recording: Retrieve metadata about a specific session recording by its ID. Needs recordingId.
  • list_annotations: List annotations on charts/dashboards.
  • evaluate_feature_flags: Evaluate all feature flags for a specific user (distinct ID). Needs distinctId.
  • get_person: Retrieve detailed information about a specific person by their PostHog person ID. Needs personId.
  • get_survey: Retrieve detailed information about a specific survey by its ID, including questions, targeting, and status. Needs surveyId.
  • list_experiments: List A/B test experiments in the project.
  • get_cohort: Retrieve detailed information about a specific cohort by its ID. Needs cohortId.
  • 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. Needs query.
  • get_annotation: Retrieve a specific PostHog annotation by ID. Needs annotationId.
  • get_action: Retrieve a specific PostHog action by ID, including its step rules. Needs actionId.
  • list_actions: List PostHog actions.
  • list_group_types: List configured PostHog group types.
  • list_groups: List groups for a specific PostHog group type. Needs groupTypeIndex.
  • 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. Needs groupTypeIndex and groupKey.

Write tools (17)

  • create_experiment: Create a new A/B test experiment. Needs name.
  • capture_event: Send one or more events to PostHog. Needs events.
  • create_dashboard: Create a new dashboard for organizing insights and analytics visualizations. Needs name.
  • create_cohort: Create a new cohort. Needs name.
  • update_dashboard: Update an existing dashboard's name, description, pinned status, or tags. Needs dashboardId.
  • update_experiment: Update an existing A/B test experiment's name, description, dates, or configuration. Needs experimentId.
  • update_survey: Update an existing survey's name, description, questions, targeting, or dates. Needs surveyId.
  • create_survey: Create a new survey with questions and optional targeting. Needs name.
  • create_annotation: Create a new annotation to mark a significant event or deployment on PostHog charts and dashboards. Needs content and dateMarker.
  • update_feature_flag: Update an existing feature flag's name, active status, rollout percentage, or targeting configuration. Needs flagId.
  • create_feature_flag: Create a new feature flag. Needs key.
  • update_group_property: Set or update properties for a PostHog group. Needs groupTypeIndex, groupKey and groupProperties.
  • create_action: Create a PostHog action from event, selector, URL, or property matching steps. Needs name.
  • create_group: Create or update a PostHog group for a configured group type. Needs groupTypeIndex and groupKey.
  • update_annotation: Update an annotation's content, date marker, or scope. Needs annotationId.
  • update_cohort: Update an existing cohort's name, description, static state, or filter groups. Needs cohortId.
  • update_action: Update a PostHog action's metadata, tags, deletion state, or step rules. Needs actionId.

Destructive tools (9)

  • delete_feature_flag: Permanently delete a feature flag. Needs flagId.
  • delete_survey: Permanently delete a survey. Needs surveyId.
  • delete_annotation: Delete an annotation from charts/dashboards. Needs annotationId.
  • delete_dashboard: Permanently delete a dashboard. Needs dashboardId.
  • delete_person: Permanently delete a person profile from PostHog. Needs personId.
  • delete_cohort: Permanently delete a cohort from PostHog. Needs cohortId.
  • delete_action: Delete a PostHog action. Needs actionId.
  • delete_experiment: Permanently delete an experiment from PostHog. Needs experimentId.
  • delete_group_property: Delete one or more properties from a PostHog group. Needs groupTypeIndex and groupKey.

Triggers

PostHog has 3 triggers, which fire on events in PostHog:

  • feature_flag_changes: Triggers when feature flags are created or updated.
  • inbound_webhook
  • new_events: Triggers when new events are captured in PostHog.

Next steps