npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

posthog-toolkit-mcp

v0.1.0

Published

MCP server for PostHog, cloud or self-hosted: HogQL, event and property definitions, session replays and the REST API.

Readme

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 | |---|---| | posthog_query | Runs a HogQL query. Refuses insight placeholders like {filters} before sending, and says when PostHog cut the results at its default LIMIT 100. | | posthog_event_definitions | Event names seen in the project, with last-seen time; optional substring search. | | posthog_property_definitions | Event or person property names with their types. | | posthog_replays | Session recordings of a distinct_id in a time window, newest first, with links. | | posthog_projects | Projects of the organization. Works with personal API keys scoped to specific projects. | | posthog_api_get | GET any PostHog REST endpoint; {project_id} in the path is filled in. | | posthog_api_request | Any method, including writes. Registered only with POSTHOG_ALLOW_WRITE. |

Configuration

| Variable | | |---|---| | POSTHOG_HOST | Required. https://us.posthog.com, https://eu.posthog.com, or your self-hosted URL. | | POSTHOG_API_KEY | Required. A personal API key (phx_...). A project token (phc_...) is rejected at startup — it can only send events. | | POSTHOG_PROJECT_ID | Default project for the tools and for {project_id} in paths. | | POSTHOG_ALLOW_WRITE | 1, true or yes registers posthog_api_request. Off by default. | | POSTHOG_MAX_RESPONSE_CHARS | Cap on a tool response. Default 100000. | | POSTHOG_TIMEOUT_MS | Request timeout. Default 120000. |

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 ([email protected]) so every machine runs the same server.

Security

  • Read-only by default; writes need POSTHOG_ALLOW_WRITE.
  • Requests go only to the POSTHOG_HOST origin: 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 three

| File | | |---|---| | src/index.ts | Entry point: builds the server from the environment and connects stdio. | | src/config.ts | Reads and validates environment variables. | | src/posthog-client.ts | PostHog API client; refuses paths that would leave POSTHOG_HOST. | | src/schemas.ts | Zod input schemas of the tools; handler argument types are inferred from them. | | src/server.ts | Tool registration and result formatting. | | src/hogql.ts | 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.