PostHog Integration
Read PostHog organizations, projects, insights, flags, and analytics data
The PostHog integration provides access to read PostHog organizations, projects, insights, flags, and analytics data through the Integrate MCP server.
Installation
The PostHog integration is included with the SDK:
import { posthogIntegration } from "integrate-sdk/server";Setup
1. Create a PostHog OAuth App
- Create an OAuth application for PostHog
- Configure your redirect URI
- Note your Client ID and Client Secret
2. Configure the Integration on Your Server
Add the PostHog integration to your server configuration. The integration automatically reads POSTHOG_CLIENT_ID and POSTHOG_CLIENT_SECRET from your environment variables:
import { createMCPServer, posthogIntegration } from "integrate-sdk/server";
export const { client: serverClient } = createMCPServer({
apiKey: process.env.INTEGRATE_API_KEY,
integrations: [
posthogIntegration({
scopes: ["openid", "profile", "email", "organization:read", "project:read", "user:read", "query:read", "insight:read", "dashboard:read", "feature_flag:read", "experiment:read", "annotation:read", "cohort:read", "person:read", "event_definition:read", "property_definition:read", "session_recording:read", "action:read"], // Optional
}),
],
});You can override the environment variables by passing explicit values:
posthogIntegration({
clientId: process.env.CUSTOM_POSTHOG_ID,
clientSecret: process.env.CUSTOM_POSTHOG_SECRET,
scopes: ["openid", "profile", "email", "organization:read", "project:read", "user:read", "query:read", "insight:read", "dashboard:read", "feature_flag:read", "experiment:read", "annotation:read", "cohort:read", "person:read", "event_definition:read", "property_definition:read", "session_recording:read", "action:read"], // Optional
});3. Client-Side Usage
The default client automatically includes all integrations. You can use it directly:
import { client } from "integrate-sdk";
await client.authorize("posthog");
const result = await client.posthog.getCurrentUser({});
console.log(result);If you're using a custom client, add the integration to the integrations array:
import { createMCPClient, posthogIntegration } from "integrate-sdk";
const customClient = createMCPClient({
integrations: [posthogIntegration()],
});Configuration Options
export interface PostHogIntegrationConfig {
/** PostHog OAuth client ID (defaults to POSTHOG_CLIENT_ID env var) */
clientId?: string;
Default Scopes
These defaults are applied unless you override scopes in the integration config:
openidprofileemailorganization:readproject:readuser:readquery:readinsight:readdashboard:readfeature_flag:readexperiment:readannotation:readcohort:readperson:readevent_definition:readproperty_definition:readsession_recording:readaction:read
Tools
posthog_get_current_user
Get current user
No parameters.
posthog_list_organizations
List organizations
export interface PosthogListOrganizationsParams { limit?: number;
posthog_get_organization
Get organization
export interface PosthogGetOrganizationParams { organization_id: string }
posthog_list_projects
List projects
export interface PosthogListProjectsParams { organization_id: string;
posthog_get_project
Get project
export interface PosthogGetProjectParams { organization_id: string;
posthog_run_hogql_query
Run hogql query
export interface PosthogRunHogqlQueryParams { project_id: string | number;
posthog_list_insights
List insights
export interface PosthogListInsightsParams { project_id: string | number;
posthog_get_insight
Get insight
export interface PosthogGetInsightParams { project_id: string | number;
posthog_list_dashboards
List dashboards
export interface PosthogListDashboardsParams { project_id: string | number;
posthog_get_dashboard
Get dashboard
export interface PosthogGetDashboardParams { project_id: string | number;
posthog_list_feature_flags
List feature flags
export interface PosthogListFeatureFlagsParams { project_id: string | number;
posthog_get_feature_flag
Get feature flag
export interface PosthogGetFeatureFlagParams { project_id: string | number;
posthog_list_experiments
List experiments
export interface PosthogListExperimentsParams { project_id: string | number;
posthog_get_experiment
Get experiment
export interface PosthogGetExperimentParams { project_id: string | number;
posthog_list_annotations
List annotations
export interface PosthogListAnnotationsParams { project_id: string | number;
posthog_get_annotation
Get annotation
export interface PosthogGetAnnotationParams { project_id: string | number;
posthog_list_cohorts
List cohorts
export interface PosthogListCohortsParams { project_id: string | number;
posthog_get_cohort
Get cohort
export interface PosthogGetCohortParams { project_id: string | number;
posthog_list_event_definitions
List event definitions
export interface PosthogListEventDefinitionsParams { project_id: string | number;
posthog_get_event_definition
Get event definition
export interface PosthogGetEventDefinitionParams { project_id: string | number;
posthog_list_property_definitions
List property definitions
export interface PosthogListPropertyDefinitionsParams { project_id: string | number;
posthog_get_property_definition
Get property definition
export interface PosthogGetPropertyDefinitionParams { project_id: string | number;
posthog_list_persons
List persons
export interface PosthogListPersonsParams { project_id: string | number;
posthog_get_person
Get person
export interface PosthogGetPersonParams { project_id: string | number;
posthog_list_session_recordings
List session recordings
export interface PosthogListSessionRecordingsParams { project_id: string | number;
posthog_get_session_recording
Get session recording
export interface PosthogGetSessionRecordingParams { project_id: string | number;
Notes
- Category: Analytics
- Authentication mode: OAuth