Use Logs over PostHog MCP

Contents

The PostHog MCP server gives coding agents direct access to your logs. Ask your agent to search, filter, and analyze log data without leaving your editor, then fix the bug in the same session.

This works in any MCP client – Cursor, Codex, Claude Code, Windsurf, VS Code, and others.

What you can do here

Through MCP tools, your agent can:

  • Query and count logs – filter by severity, service, time range, and free text, and pull counts or sparklines to see how a problem is trending.
  • Discover what's available – list log attributes and their values, and list the services sending logs with their volume and error rate, so it can build a targeted query instead of guessing.
  • Break counts down by facet – group matching logs by any attribute to see where a spike is concentrated.
  • Mine and diff patterns – group similar log lines into templates, and compare two time ranges to see which patterns are new or spiking.
  • Manage alerts – create, read, update, and delete log alerts, attach or remove Slack, webhook, and Teams destinations, read an alert's event history, and simulate a threshold against historical logs before committing to it.

Saved views, sampling rules, and metric rules aren't exposed over MCP – manage those in the web app or with the Logs API.

For the full list of tools and how to scope a session to a subset, see the MCP tools reference.

Example prompts

GoalAsk your agent
TriageShow me all error logs from the last hour
Narrow by serviceWhat services are logging errors? Search for error logs from the payments service
Follow a requestFind logs related to trace ID abc123
Explore the schemaWhat log attributes are available? Show me the values for service.name
Spot what changedCompare log patterns from today against yesterday and show me what's new
Cut noiseShow me warning and error logs from the last 24 hours, excluding debug noise

Because your agent has both your codebase and your logs in one session, it can connect a log line to the exact code path that emitted it and draft the fix.

A useful order of operations: list attributes and their values to learn the schema, count matching logs to check the result set is a sane size, then query. Log records carry trace and span IDs, so your agent can follow a single request across services.

Set up

Connect the PostHog MCP server to your AI tool of choice, then grant it access to your project. The MCP overview covers install and authentication for each client.

To browse logs visually, mine patterns interactively, or watch the session replay behind a log line, use the web app.

Community questions

Was this page useful?