{"_id":"@andrew_eragon/mcp-server-posthog","name":"@andrew_eragon/mcp-server-posthog","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@andrew_eragon/mcp-server-posthog","version":"0.1.0","private":false,"description":"PostHog MCP stdio bridge CLI for npx and global installs","main":"dist/mcp-server-posthog.js","bin":{"mcp-server-posthog":"dist/mcp-server-posthog.js"},"type":"module","engines":{"node":">=18"},"scripts":{"prepare":"husky && npm run build","dev":"node dist/mcp-server-posthog.js --help","build":"node scripts/build.js","watch":"node scripts/build.js --watch","prepublishOnly":"npm run build","inspector":"npx @modelcontextprotocol/inspector npx -y mcp-remote@latest https://mcp.posthog.com/mcp","format":"biome format --write","lint":"biome lint --fix","start":"node server.js"},"keywords":["posthog","mcp","model-context-protocol","cli","agents","analytics"],"author":{"name":"PostHog Inc."},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/posthog/mcp-posthog.git"},"bugs":{"url":"https://github.com/posthog/mcp-posthog/issues"},"homepage":"https://github.com/posthog/mcp-posthog#readme","publishConfig":{"access":"public"},"dependencies":{"execa":"^9.4.0","yargs":"^17.7.2"},"devDependencies":{"@biomejs/biome":"1.9.4","husky":"^9.1.7","tsx":"^4.20.3","esbuild":"^0.23.1"},"_id":"@andrew_eragon/mcp-server-posthog@0.1.0","gitHead":"2691502bac6a9f7c48eccdab32fdad0048fa9e21","_nodeVersion":"20.15.1","_npmVersion":"10.8.3","dist":{"integrity":"sha512-bcCLxgV3osUUCiOmmA7QBxp5Grnq+5+Ra4xS2hrsgPU/P+su8VzSTDoXBDNN61erYKaESbYeWF1m6h1KY1lm1w==","shasum":"4b82bdac3634e35ad114808fa8dea60adefffe47","tarball":"https://registry.npmjs.org/@andrew_eragon/mcp-server-posthog/-/mcp-server-posthog-0.1.0.tgz","fileCount":5,"unpackedSize":452137,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHri1rlOJYxVYtY8AcDtMxL1YF62NsO/nsDj22RHAEMrAiB4hn/yvXA3eV/ODuQqpb43Y1Za5PykF63UUfrY4G0ZqQ=="}]},"_npmUser":{"name":"andrew_eragon","email":"andrew@eragon.ai"},"directories":{},"maintainers":[{"name":"andrew_eragon","email":"andrew@eragon.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-server-posthog_0.1.0_1759178473705_0.4222086934267417"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-29T20:41:13.605Z","0.1.0":"2025-09-29T20:41:13.897Z","modified":"2025-09-29T20:41:14.282Z"},"maintainers":[{"name":"andrew_eragon","email":"andrew@eragon.ai"}],"description":"PostHog MCP stdio bridge CLI for npx and global installs","homepage":"https://github.com/posthog/mcp-posthog#readme","keywords":["posthog","mcp","model-context-protocol","cli","agents","analytics"],"repository":{"type":"git","url":"git+https://github.com/posthog/mcp-posthog.git"},"author":{"name":"PostHog Inc."},"bugs":{"url":"https://github.com/posthog/mcp-posthog/issues"},"license":"MIT","readme":"# PostHog MCP\n\nDocumentation: https://posthog.com/docs/model-context-protocol\n\n## Use the MCP Server\n\n### Quick install\n\nYou can install the MCP server automatically into Cursor, Claude, Claude Code, VS Code and Zed by running the following command:\n\n```\nnpx @posthog/wizard@latest mcp add\n```\n\n### Manual install\n\n1. Obtain a personal API key using the MCP Server preset [here](https://app.posthog.com/settings/user-api-keys?preset=mcp_server).\n\n2. Add the MCP configuration to your desktop client (e.g. Cursor, Windsurf, Claude Desktop) and add your personal API key\n\n```json\n{\n  \"mcpServers\": {\n    \"posthog\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote@latest\",\n        \"https://mcp.posthog.com/mcp\", // You can replace this with https://mcp.posthog.com/sse if your client does not support Streamable HTTP\n        \"--header\",\n        \"Authorization:${POSTHOG_AUTH_HEADER}\"\n      ],\n      \"env\": {\n        \"POSTHOG_AUTH_HEADER\": \"Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}\"\n      }\n    }\n  }\n}\n```\n\n### Docker install\n\nIf you prefer to use Docker instead of running npx directly:\n\n1. Build the Docker image:\n```bash\npnpm docker:build\n# or\ndocker build -t posthog-mcp .\n```\n\n2. Configure your MCP client with Docker:\n```json\n{\n  \"mcpServers\": {\n    \"posthog\": {\n      \"type\": \"stdio\",\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\",\n        \"-i\",\n        \"--rm\",\n        \"--env\",\n        \"POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER}\",\n        \"--env\",\n        \"POSTHOG_REMOTE_MCP_URL=${POSTHOG_REMOTE_MCP_URL:-https://mcp.posthog.com/mcp}\",\n        \"posthog-mcp\"\n      ],\n      \"env\": {\n        \"POSTHOG_AUTH_HEADER\": \"Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}\",\n        \"POSTHOG_REMOTE_MCP_URL\": \"https://mcp.posthog.com/mcp\"\n      }\n    }\n  }\n}\n```\n\n3. Test Docker with MCP Inspector:\n```bash\npnpm docker:inspector\n# or\nnpx @modelcontextprotocol/inspector docker run -i --rm --env POSTHOG_AUTH_HEADER=${POSTHOG_AUTH_HEADER} posthog-mcp\n```\n\n**Environment Variables:**\n- `POSTHOG_AUTH_HEADER`: Your PostHog API token (required)\n- `POSTHOG_REMOTE_MCP_URL`: The MCP server URL (optional, defaults to `https://mcp.posthog.com/mcp`)\n\nThis approach allows you to use the PostHog MCP server without needing Node.js or npm installed locally.\n\n### Example Prompts\n- What feature flags do I have active?\n- Add a new feature flag for our homepage redesign\n- What are my most common errors?\n- Show me my LLM costs this week\n\n### Feature Filtering\n\nYou can limit which tools are available by adding query parameters to the MCP URL:\n\n```\nhttps://mcp.posthog.com/mcp?features=flags,workspace\n```\n\nAvailable features:\n- `workspace` - Organization and project management\n- `error-tracking` - [Error monitoring and debugging](https://posthog.com/docs/errors)\n- `dashboards` - [Dashboard creation and management](https://posthog.com/docs/product-analytics/dashboards)\n- `insights` - [Analytics insights and SQL queries](https://posthog.com/docs/product-analytics/insights)\n- `experiments` - [A/B testing experiments](https://posthog.com/docs/experiments)\n- `flags` - [Feature flag management](https://posthog.com/docs/feature-flags)\n- `llm-analytics` - [LLM usage and cost tracking](https://posthog.com/docs/llm-analytics)\n- `docs` - PostHog documentation search\n\nTo view which tools are available per feature, see our [documentation](https://posthog.com/docs/model-context-protocol) or alternatively check out `schema/tool-definitions.json`,\n\n### Data processing\n\nThe 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.\n\n### Using self-hosted instances\n\nIf you're using a self-hosted instance of PostHog, you can specify a custom base URL by adding the `POSTHOG_BASE_URL` [environment variable](https://developers.cloudflare.com/workers/configuration/environment-variables) when running the MCP server locally or on your own infrastructure, e.g. `POSTHOG_BASE_URL=https://posthog.example.com`\n\n# Development\n\nTo run the MCP server locally, run the following command:\n\n```\npnpm run dev\n```\n\nAnd replace `https://mcp.posthog.com/mcp` with `http://localhost:8787/mcp` in the MCP configuration.\n\n## Project Structure\n\nThis repository is organized to support multiple language implementations:\n\n- `typescript/` - TypeScript implementation of the MCP server & tools\n- `schema/` - Shared schema files generated from TypeScript\n\n### Development Commands\n\n- `pnpm run dev` - Start development server\n- `pnpm run schema:build:json` - Generate JSON schema for other language implementations\n- `pnpm run lint && pnpm run format` - Format and lint code\n\n### Adding New Tools\n\nSee the [tools documentation](typescript/src/tools/README.md) for a guide on adding new tools to the MCP server.\n\n### Environment variables\n\n- Create `.dev.vars` in the root\n- Add Inkeep API key to enable `docs-search` tool (see `Inkeep API key - mcp`)\n\n```\nINKEEP_API_KEY=\"...\"\n```\n\n\n### Configuring the Model Context Protocol Inspector\n\nDuring development you can directly inspect the MCP tool call results using the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector).\n\nYou can run it using the following command:\n\n```bash\nnpx @modelcontextprotocol/inspector npx -y mcp-remote@latest http://localhost:8787/mcp --header \"\\\"Authorization: Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}\\\"\"\n```\n\nAlternatively, you can use the following configuration in the MCP Inspector:\n\nUse transport type `STDIO`.\n\n**Command:**\n\n```\nnpx\n```\n\n**Arguments:**\n\n```\n-y mcp-remote@latest http://localhost:8787/mcp --header \"Authorization: Bearer {INSERT_YOUR_PERSONAL_API_KEY_HERE}\"\n```\n\n## CLI usage via npx\n\nYou can run the PostHog MCP server locally via stdio using npx, similar to the Salesforce MCP example.\n\n```bash\n# Fast path inside containers (no -y):\nnpx @andrew_eragon/mcp-server-posthog\n\n# Outside containers, allow auto-confirm with -y:\nnpx -y @andrew_eragon/mcp-server-posthog\n```\n\nEnvironment variables:\n\n- `POSTHOG_REMOTE_MCP_URL` (default: `https://mcp.posthog.com/mcp`)\n- `POSTHOG_API_TOKEN` (required; same as `Authorization: Bearer <token>`)\n- `POSTHOG_FEATURES` (optional comma-separated list to limit tools)\n- `POSTHOG_SESSION_ID` (optional session identifier)\n\nFlags (override env):\n\n```bash\nnpx -y @andrew_eragon/mcp-server-posthog \\\n  --token \"$POSTHOG_API_TOKEN\" \\\n  --url \"https://mcp.posthog.com/mcp\" \\\n  --features \"org,insights\" \\\n  --session \"abcd-1234\"\n```\n\nThis 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.\n","readmeFilename":"README.md","_rev":"1-1fddeb038183896d93dcb4891da6287e"}