by PostHog
Provides a Model Context Protocol server that exposes PostHog analytics, feature flags, error tracking, dashboards, experiments, LLM usage analytics, and documentation search to AI assistants and other client tools.
Posthog Mcp offers a ready‑to‑use MCP server that bridges PostHog’s product‑analytics ecosystem with AI models. By exposing tools such as feature‑flag management, error monitoring, dashboard queries, experiment results, LLM cost tracking, and docs search, it enables conversational assistants to retrieve and act on real‑time product data.
npx @posthog/wizard@latest mcp add
The wizard adds the necessary MCP configuration to supported desktop clients (Cursor, Claude, VS Code, Zed, etc.).
Add the following JSON to your client’s mcpServers configuration, replacing {INSERT_YOUR_PERSONAL_API_KEY_HERE} with a personal API key obtained from PostHog:
{
"mcpServers": {
"posthog": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://mcp.posthog.com/mcp",
"--header",
"Authorization:${POSTHOG_AUTH_HEADER}"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}"
}
}
}
}
# Build the image
pnpm docker:build # or: docker build -t posthog-mcp .
# Run via MCP client configuration
{
"mcpServers": {
"posthog": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--env",
"POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER}",
"--env",
"POSTHOG_REMOTE_MCP_URL=${POSTHOG_REMOTE_MCP_URL:-https://mcp.posthog.com/mcp}",
"posthog-mcp"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}",
"POSTHOG_REMOTE_MCP_URL": "https://mcp.posthog.com/mcp"
}
}
}
}
Test the Docker image with the MCP Inspector:
pnpm docker:inspector
# or
npx @modelcontextprotocol/inspector docker run -i --rm --env POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER} posthog-mcp
?features=flags,workspace.POSTHOG_BASE_URL to point to a private PostHog instance.POSTHOG_AUTH_HEADER (required) and optional POSTHOG_REMOTE_MCP_URL.Q: Do I need Node.js installed locally?
A: No. The quick‑install command uses npx, which downloads the package on‑the‑fly. Docker is also supported for completely node‑free environments.
Q: How do I obtain an API key? A: Generate a personal API key from PostHog → Settings → User API keys, selecting the MCP Server preset.
Q: Can I run the server on my own infrastructure?
A: Yes. Set POSTHOG_BASE_URL to your self‑hosted PostHog URL when starting the server (via Cloudflare Workers or Docker). The server will route requests to that instance.
Q: Which tools are available by default?
A: All listed under Key features are enabled. You can restrict them with the features query parameter in the MCP URL.
Q: What if I only want feature‑flag management?
A: Use https://mcp.posthog.com/mcp?features=flags (or add additional comma‑separated features as needed).
Q: Is any sensitive data stored outside my region? A: The MCP server runs on a Cloudflare worker and does not persist sensitive data; it only proxies requests to your PostHog instance.
Q: How do I add new tools?
A: Follow the guidance in typescript/src/tools/README.md and regenerate the shared schema with pnpm run schema:build:json.
Documentation: https://posthog.com/docs/model-context-protocol
You can install the MCP server automatically into Cursor, Claude, Claude Code, VS Code and Zed by running the following command:
npx @posthog/wizard@latest mcp add
Obtain a personal API key using the MCP Server preset here.
Add the MCP configuration to your desktop client (e.g. Cursor, Windsurf, Claude Desktop) and add your personal API key
{
"mcpServers": {
"posthog": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://mcp.posthog.com/mcp", // You can replace this with https://mcp.posthog.com/sse if your client does not support Streamable HTTP
"--header",
"Authorization:${POSTHOG_AUTH_HEADER}"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}"
}
}
}
}
If you prefer to use Docker instead of running npx directly:
pnpm docker:build
# or
docker build -t posthog-mcp .
{
"mcpServers": {
"posthog": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--env",
"POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER}",
"--env",
"POSTHOG_REMOTE_MCP_URL=${POSTHOG_REMOTE_MCP_URL:-https://mcp.posthog.com/mcp}",
"posthog-mcp"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}",
"POSTHOG_REMOTE_MCP_URL": "https://mcp.posthog.com/mcp"
}
}
}
}
pnpm docker:inspector
# or
npx @modelcontextprotocol/inspector docker run -i --rm --env POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER} posthog-mcp
Environment Variables:
POSTHOG_AUTH_HEADER: Your PostHog API token (required)POSTHOG_REMOTE_MCP_URL: The MCP server URL (optional, defaults to https://mcp.posthog.com/mcp)This approach allows you to use the PostHog MCP server without needing Node.js or npm installed locally.
You can limit which tools are available by adding query parameters to the MCP URL:
https://mcp.posthog.com/mcp?features=flags,workspace
Available features:
workspace - Organization and project managementerror-tracking - Error monitoring and debuggingdashboards - Dashboard creation and managementinsights - Analytics insights and SQL queriesexperiments - A/B testing experimentsflags - Feature flag managementllm-analytics - LLM usage and cost trackingdocs - PostHog documentation searchTo view which tools are available per feature, see our documentation or alternatively check out schema/tool-definitions.json,
The MCP server is hosted on a Cloudflare worker which can be located outside of the EU / US, for this reason the MCP server does not store any sensitive data outside of your cloud region.
If you're using a self-hosted instance of PostHog, you can specify a custom base URL by adding the POSTHOG_BASE_URL environment variable when running the MCP server locally or on your own infrastructure, e.g. POSTHOG_BASE_URL=https://posthog.example.com
To run the MCP server locally, run the following command:
pnpm run dev
And replace https://mcp.posthog.com/mcp with http://localhost:8787/mcp in the MCP configuration.
This repository is organized to support multiple language implementations:
typescript/ - TypeScript implementation of the MCP server & toolsschema/ - Shared schema files generated from TypeScriptpnpm run dev - Start development serverpnpm run schema:build:json - Generate JSON schema for other language implementationspnpm run lint && pnpm run format - Format and lint codeSee the tools documentation for a guide on adding new tools to the MCP server.
.dev.vars in the rootdocs-search tool (see Inkeep API key - mcp)INKEEP_API_KEY="..."
During development you can directly inspect the MCP tool call results using the MCP Inspector.
You can run it using the following command:
npx @modelcontextprotocol/inspector npx -y mcp-remote@latest http://localhost:8787/mcp --header "\"Authorization: Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}\""
Alternatively, you can use the following configuration in the MCP Inspector:
Use transport type STDIO.
Command:
npx
Arguments:
-y mcp-remote@latest http://localhost:8787/mcp --header "Authorization: Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}"
Please log in to share your review and rating for this MCP.
{
"mcpServers": {
"posthog": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://mcp.posthog.com/mcp",
"--header",
"Authorization:${POSTHOG_AUTH_HEADER}"
],
"env": {
"POSTHOG_AUTH_HEADER": "Bearer <YOUR_PERSONAL_API_KEY>"
}
}
}
}claude mcp add posthog npx -y mcp-remote@latest https://mcp.posthog.com/mcp --header Authorization:${POSTHOG_AUTH_HEADER}Explore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.