KosmoKrator

analytics

Google Analytics MCP Integration for LangGraph

Connect Google Analytics to LangGraph through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.

4 functions 4 read 0 write OAuth browser flow auth

Connect Google Analytics to LangGraph

Run KosmoKrator integration calls from LangGraph nodes while preserving local credentials and permissions.

Use a graph node that calls the KosmoKrator CLI for deterministic steps or an MCP client for dynamic tool selection. The gateway is local, scoped to this integration, and starts with --write=deny so LangGraph can inspect read-capable tools without receiving write access by default.

Google Analytics MCP Config for LangGraph

Headless CLI calls fit repeatable graph edges; MCP fits exploratory agent nodes.

{
  "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

Scoped tools

Expose only Google Analytics instead of a broad multi-service tool list.

Local credentials

Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.

Write policy

Start read-only, then opt into ask or allow for trusted workspaces.

Google Analytics Tools Visible to LangGraph

LangGraph sees stable MCP tool names generated from the Google Analytics integration catalog.

MCP toolSource functionTypeDescription
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.

Related Google Analytics Pages