analytics
Google Analytics MCP Integration for LangChain
Connect Google Analytics to LangChain through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.
Connect Google Analytics to LangChain
Bridge LangChain agents to local KosmoKrator integration tools through MCP or headless CLI calls.
Use the MCP gateway when the agent should discover tools, or wrap kosmo integrations:call for fixed chains. The gateway is local, scoped to this integration, and starts with
--write=deny so LangChain can inspect read-capable tools without receiving write access by default.
Google Analytics MCP Config for LangChain
Keep the gateway scoped to the integration and operation class needed by the chain.
{
"mcpServers": {
"kosmokrator-google_analytics": {
"type": "stdio",
"command": "kosmo",
"args": [
"mcp:serve",
"--integration=google_analytics",
"--write=deny"
]
}
}
} Run the Gateway Manually
kosmokrator mcp:serve --integration=google_analytics --write=deny Why Use KosmoKrator Here
Expose only Google Analytics instead of a broad multi-service tool list.
Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.
Start read-only, then opt into ask or allow for trusted workspaces.
Google Analytics Tools Visible to LangChain
LangChain sees stable MCP tool names generated from the Google Analytics integration catalog.
| MCP tool | Source function | Type | Description |
|---|---|---|---|
integration__google_analytics__google_analytics_list_properties | google_analytics.google_analytics_list_properties | Read | List all accessible GA4 properties with their IDs and names. Use this first to discover the propertyId needed for other Analytics tools. |
integration__google_analytics__google_analytics_metadata | google_analytics.google_analytics_metadata | Read | List all available dimensions and metrics for a GA4 property, including custom ones. Use this to discover what data can be queried in reports. |
integration__google_analytics__google_analytics_realtime | google_analytics.google_analytics_realtime | Read | Run a GA4 realtime report showing activity in the last 30 minutes. Common dimensions: country, city, deviceCategory, unifiedScreenName (page/screen), platform. Common metrics: activeUsers, screenPageViews, eventCount, conversions. |
integration__google_analytics__google_analytics_report | google_analytics.google_analytics_report | Read | Run a GA4 analytics report. Returns rows of dimension/metric data for the specified date range. Common dimensions: sessionSource, sessionMedium, sessionDefaultChannelGroup (traffic source); pagePath, pageTitle, landingPage (pages); country, city (geo); deviceCategory, browser, operatingSystem (device); date, dateHour, month (time); newVsReturning (user); eventName (events). Common metrics: sessions, totalUsers, newUsers, activeUsers (traffic); screenPageViews, bounceRate, averageSessionDuration, engagementRate, sessionsPerUser (engagement); eventCount, conversions (events); purchaseRevenue, totalRevenue (e-commerce). Dates: YYYY-MM-DD or relative: "today", "yesterday", "7daysAgo", "28daysAgo", "30daysAgo", "90daysAgo", "365daysAgo". Filter operators: exact, contains, begins_with, ends_with, regex, in_list. Metric filter operators: equal, less_than, greater_than, less_than_or_equal, greater_than_or_equal. |