KosmoKrator

analytics

Google Analytics MCP Integration for Claude Agent SDK

Connect Google Analytics to Claude Agent SDK 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 Claude Agent SDK

Give Claude Agent SDK workflows access to KosmoKrator integrations through a local MCP server.

Add a KosmoKrator stdio MCP server to the Claude Agent SDK options. The gateway is local, scoped to this integration, and starts with --write=deny so Claude Agent SDK can inspect read-capable tools without receiving write access by default.

Google Analytics MCP Config for Claude Agent SDK

Use a narrow integration list so the agent does not load unrelated tools.

{
  "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 Claude Agent SDK

Claude Agent SDK 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