Subchapter 80.10
references/mcp.mdMarkdown4 KBView on GitHub
AI agents: this is one page from PostHog’s docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt (opens in a new tab)
The PostHog MCP server (opens in a new tab) 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.
Through MCP tools, your agent can:
Saved views, sampling rules, and metric rules aren’t exposed over MCP – manage those in the web app (opens in a new tab) or with the Logs API (opens in a new tab).
For the full list of tools and how to scope a session to a subset, see the MCP tools reference (opens in a new tab).
| Goal | Ask your agent |
|---|---|
| Triage | Show me all error logs from the last hour |
| Narrow by service | What services are logging errors? Search for error logs from the payments service |
| Follow a request | Find logs related to trace ID abc123 |
| Explore the schema | What log attributes are available? Show me the values for service.name |
| Spot what changed | Compare log patterns from today against yesterday and show me what's new |
| Cut noise | Show 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.
Connect the PostHog MCP server to your AI tool of choice, then grant it access to your project. The MCP overview (opens in a new tab) 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 (opens in a new tab).
Ask PostHog AI
HelpfulCould be better