Skip to main content
Glama
deadrime

posthog-toolkit-mcp

by deadrime

Run a HogQL query

posthog_query
Read-only

Execute HogQL queries against PostHog data to analyze events, persons, sessions, groups, and session replays. Filter and aggregate with SQL-like syntax for custom insights.

Instructions

Runs a HogQL (ClickHouse SQL dialect) query: tables events, persons, sessions, groups, raw_session_replay_events. Example: SELECT event, count() FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY 2 DESC LIMIT 20.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesHogQL query text
project_idNoProject id; defaults to POSTHOG_PROJECT_ID

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With readOnlyHint and openWorldHint already annotated, the description doesn't need to restate the read-only or open-world traits. It adds valuable behavioral context by enumerating accessible tables (events, persons, sessions, groups, raw_session_replay_events) and showing a concrete query pattern, which helps an agent understand what to expect.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long: the first states the core function and data sources, the second provides an illustrative example. It is front-loaded with the action and resource, and every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a generic query tool, the description provides everything an agent needs: the dialect, the available tables, and a full sample query. Since no output schema is present, return format expectations are appropriately left open, and the annotations handle read-only and open-world behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema only describes the query parameter as 'HogQL query text', but the description adds concreteness by listing the exact tables and providing a working example query. This goes beyond the schema's generic description and gives the agent a clearer model for constructing valid inputs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool runs a HogQL query against a defined set of tables Aleksandrov, and the example makes the exact syntax concrete. It is easily distinguished from siblings like posthog_event_definitions and posthog_property_definitions, which serve narrower metadata retrieval purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context for when to use the tool: for writing arbitrary HogQL queries over the listed tables. It doesn't explicitly state when not to use it or explicitly name the sibling alternatives, but the table list implies that this is a general-purpose query tool rather than a structured endpoint.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.