Skip to main content
Back to the PostHog MCP server

MCP Gateway · Cursor

PostHog icon

Connect PostHog to Cursor

Instrumentation code is easier to write when the editor knows what is already tracked. Cursor can list PostHog's event definitions before you add a capture call, tidy up flags nobody evaluates anymore, and turn a saved query into an API endpoint with a typed client. Speakeasy sees every Cursor prompt and PostHog tool call through hooks, and if its check can't complete, the call doesn't run.

Category
Data & analytics
Tools
172
Authentication
API key
Cursor
Editor and terminal

Behind the MCP Gateway

Run PostHog MCP behind the MCP Gateway

One URL for every agent, sign-in through your IdP, RBAC down to the tool, and every PostHog call inspected and logged.

Deploy on MCP Gateway

Set up

Add PostHog to Cursor in 4 steps

  1. 01

    Add PostHog from the catalog

    An admin finds PostHog in the MCP Catalog (MCP Gateway > MCP > Catalog) and clicks Add. Speakeasy registers the vendor's server as a remote MCP server and proxies sessions to it. Nothing is copied or re-hosted.

    PostHog authenticates with an API key. Enter it under Upstream headers in the install dialog, or later on the server's Settings tab. The key is stored on the server, sent with every upstream request, and never reaches anyone's client configuration.

    Where MCP-scoped policies are enabled, the install offers a recommended risk policy for the new server that detects secrets and PII and inspects tool requests and responses.

  2. 02

    Choose who can use PostHog

    Give teams the mcp:connect scope on the PostHog server through team access or a role. The organization gateway works out each person's servers from their live access, so granting access adds PostHog to their gateway on the next call, and removing it takes it away.

  3. 03

    Connect Cursor

    Add the gateway to Cursor in one click from the Organization Gateway page.

    On the Organization Gateway page in Speakeasy, choose Cursor under Install.

    Click Add to Cursor to add the gateway to Cursor's MCP settings, then sign in when Cursor prompts you.

  4. 04

    Sign in and use PostHog from Cursor

    The first time Cursor connects, it opens a browser so the person can sign in to Speakeasy through your identity provider.

    From then on, PostHog's tools appear in Cursor, limited to what the person's access allows, and every call lands in the gateway's tool logs.

For a whole team, a Cursor team admin imports the plugin marketplace under Settings > Plugins > Import and turns on Serve Marketplace From Cursor, so members install without GitHub access.

Use cases

What Cursor users do with PostHog

Check events before instrumenting

Before adding a new capture call, Cursor lists existing event definitions and their properties, so you reuse an event name instead of creating a near duplicate.

event-definitions-listproperties-list

Remove stale feature flags

Cursor finds flags marked stale, checks that no other active flag depends on them, and then you delete the checks from the code.

feature-flag-get-allfeature-flags-status-retrievefeature-flags-dependent-flags-retrieve

Expose a query as an API endpoint

Turn a HogQL query into a PostHog endpoint and fetch its OpenAPI spec, so Cursor can generate a typed client for it in your codebase.

endpoint-createendpoint-openapi-spec

Tools

172 tools

Each PostHog tool can be allowed or denied per team and role at the MCP Gateway before Cursor sees it.

experiment-get-all

Get all experiments in the project.

experiment-create

Create a comprehensive A/B test experiment. , ['product_view', 'add_to_cart', 'purchase']) and use funnel_steps parameter 6) Configure variants (default 50/50 control/test unless they specify otherwise) 7) Set targeting criteria if needed.

experiment-delete

Delete an experiment by ID.

experiment-update

Update an existing experiment by ID. Can update name, description, lifecycle state, variants, metrics, and other properties. RESTART WORKFLOW: To restart a concluded experiment, set end_date=null, conclusion=null, conclusion_comment=null, and optionally set a new start_date.

experiment-get

Get details of a specific experiment by ID.

See all 172 tools

Control

What Speakeasy can see and stop in Cursor

The gateway covers every client the same way. The rest depends on what Cursor exposes to Speakeasy.

Tool logs

Gateway

Every PostHog call is logged with the person and the client that made it.

Access by role

Gateway

People reach only the PostHog tools their team or role allows.

Request and response blocking

Gateway

A risk policy scoped to PostHog can reject a tool request before it reaches the server, or withhold a result from Cursor. MCP-scoped policies are enabled per organization.

Prompt and tool-call blocking

Cursor

Cursor hooks send each prompt and tool call to Speakeasy, which allows or denies it before Cursor runs it, and fail closed.

User attribution

Cursor

Every Cursor hook event carries the user's email.

Budgets

Cursor

Spend limits can block Cursor traffic once a budget is reached. Connect the Cursor Admin API for dollar spend.

Device agent and MDM

Cursor

The device agent installs the marketplace and plugins and reapplies them every minute.

  • Cursor Cloud agents need a checked-in .cursor/hooks.json. Session and MCP-specific hooks don't run there.
  • After a plugin update, members run Developer: Reload Window.

Questions

Frequently asked questions

Is PostHog activity in Cursor attributed to a person?
Yes. Every Cursor hook event carries the user's email, and each PostHog tool call is logged at the gateway against a named employee.
What do Cursor users do after the PostHog plugin is updated?
Members run Developer: Reload Window. On managed laptops, the device agent reapplies the marketplace and plugins every minute.
How do Cursor users get PostHog?
An admin adds PostHog from the Speakeasy MCP Catalog and grants access by team or role. Add the gateway to Cursor in one click from the Organization Gateway page. Each person then sees only the PostHog tools their access allows.
Are PostHog calls from Cursor logged?
Yes. PostHog calls go through the MCP Gateway, which logs each tool call and attributes it to the person and the client that made it.

Connect more

PostHog in other clients

AI everywhere.

Control here.