by PostHog
Provides a Model Context Protocol server that enables AI assistants to query PostHog analytics, feature flags, error tracking, dashboards, experiments, LLM usage and documentation search directly from your development environment.
The Posthog MCP Server acts as a bridge between AI models and a PostHog instance, exposing data‑driven tools (flags, insights, errors, dashboards, experiments, LLM analytics, docs search) through the Model Context Protocol. This lets developers and AI assistants retrieve actionable information without writing custom API calls.
npx @posthog/wizard@latest mcp add
to automatically add the server configuration to supported desktop clients (Cursor, Claude, VS Code, Zed, etc.).mcpServers
config, providing your personal PostHog API key via the POSTHOG_AUTH_HEADER
environment variable.pnpm docker:build
or docker build -t posthog-mcp .
and run it using the supplied docker
command configuration.https://mcp.posthog.com/mcp
) with http://localhost:8787/mcp
when developing locally (pnpm run dev
).?features=flags,workspace
).POSTHOG_BASE_URL
to point to a custom PostHog instance.Q: Do I need Node.js installed locally?
A: No. The Docker installation runs the server in a container, and the npx
quick‑install method does not require a permanent Node environment.
Q: What environment variables are required?
A: POSTHOG_AUTH_HEADER
(Bearer token) is mandatory. POSTHOG_REMOTE_MCP_URL
is optional and defaults to https://mcp.posthog.com/mcp
. For self‑hosted setups, set POSTHOG_BASE_URL
.
Q: Can I restrict which tools are exposed?
A: Yes. Append ?features=
with a comma‑separated list to the MCP URL.
Q: How do I add new tools?
A: Follow the guide in typescript/src/tools/README.md
and run pnpm run schema:build:json
to update shared schemas.
Q: Is any sensitive data stored outside my region? A: The server runs on a Cloudflare worker; it does not persist sensitive data outside your cloud region.
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_API_KEY>" } } } }
Discover more MCP servers with similar functionality and use cases
by zed-industries
Provides real-time collaborative editing powered by Rust, enabling developers to edit code instantly across machines with a responsive, GPU-accelerated UI.
by cline
Provides autonomous coding assistance directly in the IDE, enabling file creation, editing, terminal command execution, browser interactions, and tool extension with user approval at each step.
by continuedev
Provides continuous AI assistance across IDEs, terminals, and CI pipelines, offering agents, chat, inline editing, and autocomplete to accelerate software development.
by github
Enables AI agents, assistants, and chatbots to interact with GitHub via natural‑language commands, providing read‑write access to repositories, issues, pull requests, workflows, security data and team activity.
by block
Automates engineering tasks by installing, executing, editing, and testing code using any large language model, providing end‑to‑end project building, debugging, workflow orchestration, and external API interaction.
by RooCodeInc
An autonomous coding agent that lives inside VS Code, capable of generating, refactoring, debugging code, managing files, running terminal commands, controlling a browser, and adapting its behavior through custom modes and instructions.
by lastmile-ai
A lightweight, composable framework for building AI agents using Model Context Protocol and simple workflow patterns.
by firebase
Provides a command‑line interface to manage, test, and deploy Firebase projects, covering hosting, databases, authentication, cloud functions, extensions, and CI/CD workflows.
by gptme
Empowers large language models to act as personal AI assistants directly inside the terminal, providing capabilities such as code execution, file manipulation, web browsing, vision, and interactive tool usage.