@andrew_eragon/mcp-server-posthog

中文文档
0.1.0发布于 2025/09/30MITES Module近 30 天下载 2006

PostHog MCP stdio bridge CLI for npx and global installs

原始使用文档
文档目录14 节
  1. Use the MCP Server
  2. Quick install
  3. Manual install
  4. Docker install
  5. Example Prompts
  6. Feature Filtering
  7. Data processing
  8. Using self-hosted instances
  9. Project Structure
  10. Development Commands
  11. Adding New Tools
  12. Environment variables
  13. Configuring the Model Context Protocol Inspector
  14. CLI usage via npx

PostHog MCP

Documentation: https://posthog.com/docs/model-context-protocol

Use the MCP Server

Quick install

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

Manual install

  1. Obtain a personal API key using the MCP Server preset here.

  2. 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}"
      }
    }
  }
}

Docker install

If you prefer to use Docker instead of running npx directly:

  1. Build the Docker image:
pnpm docker:build
# or
docker build -t posthog-mcp .
  1. Configure your MCP client with Docker:
{
  "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"
      }
    }
  }
}
  1. Test Docker with MCP Inspector:
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.

Example Prompts

  • What feature flags do I have active?
  • Add a new feature flag for our homepage redesign
  • What are my most common errors?
  • Show me my LLM costs this week

Feature Filtering

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:

To view which tools are available per feature, see our documentation or alternatively check out schema/tool-definitions.json,

Data processing

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.

Using self-hosted instances

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

Development

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.

Project Structure

This repository is organized to support multiple language implementations:

  • typescript/ - TypeScript implementation of the MCP server & tools
  • schema/ - Shared schema files generated from TypeScript

Development Commands

  • pnpm run dev - Start development server
  • pnpm run schema:build:json - Generate JSON schema for other language implementations
  • pnpm run lint && pnpm run format - Format and lint code

Adding New Tools

See the tools documentation for a guide on adding new tools to the MCP server.

Environment variables

  • Create .dev.vars in the root
  • Add Inkeep API key to enable docs-search tool (see Inkeep API key - mcp)
INKEEP_API_KEY="..."

Configuring the Model Context Protocol Inspector

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}"

CLI usage via npx

You can run the PostHog MCP server locally via stdio using npx, similar to the Salesforce MCP example.

# Fast path inside containers (no -y):
npx @andrew_eragon/mcp-server-posthog

# Outside containers, allow auto-confirm with -y:
npx -y @andrew_eragon/mcp-server-posthog

Environment variables:

  • POSTHOG_REMOTE_MCP_URL (default: https://mcp.posthog.com/mcp)
  • POSTHOG_API_TOKEN (required; same as Authorization: Bearer <token>)
  • POSTHOG_FEATURES (optional comma-separated list to limit tools)
  • POSTHOG_SESSION_ID (optional session identifier)

Flags (override env):

npx -y @andrew_eragon/mcp-server-posthog \
  --token "$POSTHOG_API_TOKEN" \
  --url "https://mcp.posthog.com/mcp" \
  --features "org,insights" \
  --session "abcd-1234"

This CLI bridges stdio to the hosted PostHog MCP using mcp-remote, injecting the auth header and forwarding /sse as needed. It is suitable for tools that expect an MCP stdio server.

版本与发布记录

@andrew_eragon/mcp-server-posthog 共发布 1 个版本,首次发布于 2025/09/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0latest2025/09/301.1 年前

关于 @andrew_eragon/mcp-server-posthog 的常见问题

@andrew_eragon/mcp-server-posthog 是什么?

PostHog MCP stdio bridge CLI for npx and global installs

如何安装 @andrew_eragon/mcp-server-posthog?

在项目目录运行 npm install @andrew_eragon/mcp-server-posthog,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mcp-server-posthog,可以用 npx mcp-server-posthog 直接运行。

@andrew_eragon/mcp-server-posthog 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/andrew_eragon__mcp-server-posthog 是否存在。

@andrew_eragon/mcp-server-posthog 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@andrew_eragon/mcp-server-posthog 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@andrew_eragon/mcp-server-posthog 可以商用吗?

@andrew_eragon/mcp-server-posthog 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@andrew_eragon/mcp-server-posthog 的下载量有多少?

根据 npm 官方下载统计,@andrew_eragon/mcp-server-posthog 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,006 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@andrew_eragon/mcp-server-posthog 还在维护吗?

最新版本 0.1.0 发布于 2025/09/30(1.1 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/09/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。