posthog-toolkit-mcp
Provides tools for interacting with a PostHog instance, including HogQL queries, event and property definitions, session replays, project listing, and general REST API access with read-only by default and optional write support.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@posthog-toolkit-mcpRun a HogQL query for daily active users over the last 7 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
posthog-toolkit-mcp
An MCP server for PostHog, on PostHog Cloud or a self-hosted instance: HogQL queries, event and property definitions, session replays and the REST API — with guards that keep an agent from sending the API key elsewhere or writing by accident.
Tools
Tool | What it does |
| Runs a HogQL query. Refuses insight placeholders like |
| Event names seen in the project, with last-seen time; optional substring |
| Event or person property names with their types. |
| Session recordings of a |
| Projects of the organization. Works with personal API keys scoped to specific projects. |
| GET any PostHog REST endpoint; |
| Any method, including writes. Registered only with |
Related MCP server: pg-readonly-mcp
Configuration
Variable | |
| Required. |
| Required. A personal API key ( |
| Default project for the tools and for |
|
|
| Cap on a tool response. Default |
| Request timeout. Default |
The key needs read access to the project (and user read access for posthog_projects; without it the tool falls
back to the organization project list).
Install
{
"mcpServers": {
"posthog": {
"command": "npx",
"args": ["-y", "posthog-toolkit-mcp"],
"env": {
"POSTHOG_HOST": "https://posthog.example.com",
"POSTHOG_API_KEY": "${POSTHOG_API_KEY}",
"POSTHOG_PROJECT_ID": "1"
}
}
}
}In Claude Code this block goes into the project's .mcp.json; keep the key itself out of the file, e.g. in the
env block of .claude/settings.local.json, and pin the version (posthog-toolkit-mcp@0.1.0) so every machine runs
the same server.
Security
Read-only by default; writes need
POSTHOG_ALLOW_WRITE.Requests go only to the
POSTHOG_HOSTorigin: a path like//other-host/...is refused before the API key could leave with it.Project ids are validated as numbers before they reach a URL.
Development
npm install
npm run typecheck # tsc --noEmit
npm run build # esbuild bundles src/index.ts into dist/server.mjs with no runtime dependencies
npm run smoke # stdio checks: configuration errors, tool list, guards that fire before any network call
npm run check # all threeFile | |
| Entry point: builds the server from the environment and connects stdio. |
| Reads and validates environment variables. |
| PostHog API client; refuses paths that would leave |
| Zod input schemas of the tools; handler argument types are inferred from them. |
| Tool registration and result formatting. |
| HogQL literals, insight placeholder detection, the recordings query. |
The bundle is a single file on purpose: npx starts it without installing any dependencies.
License
MIT — see LICENSE. Dependencies bundled into dist/server.mjs keep their own licenses, listed in
THIRD_PARTY_NOTICES.md.
Related MCP Connectors
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides secure read-only SQL access to PostgreSQL and ClickHouse databases with built-in safety features like read-only enforcement, timeouts, and managed result files.MIT
- FlicenseAqualityCmaintenanceEnables read-only exploration of a Postgres database using natural language, with multiple safety layers to prevent any modifications.5-
- FlicenseNot gradedqualityCmaintenanceEnables running read-only SQL queries and exploring DuckDB databases through MCP tools like listing tables, describing schemas, and fetching paginated data.-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to query PostgreSQL, inspect schemas, and explain queries, designed for local and development databases with read-only safety by default.36 npmMIT