Lovable integration
Contents
The PostHog MCP lets Lovable query your analytics data, investigate errors, manage feature flags, and run experiments - all through natural language.
Connect PostHog to Lovable
Custom MCP servers require a paid Lovable plan.
- Go to Settings → Connectors → Personal connectors
- Click New MCP server
- Enter the name
PostHogand URLhttps://mcp.posthog.com/mcp - Under Authentication, select OAuth
- Click Add & authorize, then log in to PostHog when prompted
The PostHog MCP server is now available in your Lovable chats.
Set up PostHog in your project
Once connected, give Lovable this prompt to add PostHog to your app:
The agent will get your project credentials from the MCP, install posthog-js, and set up analytics with automatic pageview tracking, error capture, and autocapture.
What you can do with the MCP
Once connected, you can ask Lovable to interact with your PostHog data directly:
Query your analytics
Prompt: "How many unique users signed up in the last 7 days, broken down by day?"
The agent will run a trends query and return daily signup counts with a breakdown.
Prompt: "What's the conversion rate from signup to first purchase?"
The agent will build a funnel query and calculate the conversion percentage between those two events.
Investigate errors
Prompt: "What are the top 5 errors in my project this week?"
The agent will fetch error groups sorted by occurrence count, including how many users were affected.
Prompt: "Show me details about the most recent TypeError"
The agent will pull the stack trace, affected users, and browser/OS context for that error.
Manage feature flags
Prompt: "Create a feature flag called 'new-checkout' enabled for 10% of users"
The agent will create the flag with a 10% rollout and return the configuration with a link to the flag in PostHog.
Prompt: "Update the 'beta-features' flag to 50% rollout"
The agent will modify the existing flag and confirm the new rollout percentage.
Run experiments
Prompt: "Create an A/B test for the pricing page that measures conversion to checkout"
The agent will set up an experiment with control/test variants and configure a funnel metric measuring pricing page to checkout conversion.
See all available MCP tools for the complete list.
Troubleshooting
OAuth not refreshing
If the OAuth token expires and won't refresh, you can use a personal API key instead:
- Create a personal API key with the MCP Server preset
- In Lovable, edit the PostHog MCP connection
- Change authentication to Bearer and enter your API key
MCP not connecting
Try disconnecting and reconnecting the PostHog MCP server. Make sure you're logged into the correct PostHog account.
Next steps
- MCP tools reference - All available MCP tools
- Error tracking docs - Learn more about error tracking features
- Feature flags - Set up feature flags in your code
Have feedback or questions? Let us know on GitHub or ask a question.