Skip to main content
Glama
ruchernchong

mcp-server-google-analytics

by ruchernchong

getActiveUsers

Retrieve active user metrics from Google Analytics 4 for specified date ranges to analyze engagement and traffic patterns.

Instructions

Get active users metrics for a specific date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateYesStart date in YYYY-MM-DD format
endDateYesEnd date in YYYY-MM-DD format

Implementation Reference

  • The handler logic for the 'getActiveUsers' tool. It validates the input dates and calls fetchAnalyticsData with specific metrics for activeUsers and newUsers, grouped by date.
    case "getActiveUsers": {
      const { startDate, endDate } = args as {
        startDate: string;
        endDate: string;
      };
    
      validateDateRange(startDate, endDate);
    
      return fetchAnalyticsData({
        dateRanges: [{ startDate, endDate }],
        metrics: [{ name: "activeUsers" }, { name: "newUsers" }],
        dimensions: [{ name: "date" }],
      });
    }
  • The input schema and registration details for the 'getActiveUsers' tool, defining required startDate and endDate parameters.
    {
      name: "getActiveUsers",
      description: "Get active users metrics for a specific date range",
      inputSchema: {
        type: "object",
        properties: {
          startDate: {
            type: "string",
            description: "Start date in YYYY-MM-DD format",
          },
          endDate: {
            type: "string",
            description: "End date in YYYY-MM-DD format",
          },
        },
        required: ["startDate", "endDate"],
      },
    },
  • src/index.ts:130-261 (registration)
    The listTools request handler that registers the 'getActiveUsers' tool among others.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "runReport",
            description: "Run a report to get analytics data",
            inputSchema: {
              type: "object",
              properties: {
                startDate: {
                  type: "string",
                  description: "Start date in YYYY-MM-DD format",
                },
                endDate: {
                  type: "string",
                  description: "End date in YYYY-MM-DD format",
                },
                dimensions: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      name: { type: "string" },
                    },
                    required: ["name"],
                  },
                  description: "Dimensions to group by (e.g., page, country)",
                },
                metrics: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      name: { type: "string" },
                    },
                    required: ["name"],
                  },
                  description: "Metrics to include in the report",
                },
                dimensionFilter: {
                  type: "object",
                  description: "Filter for dimensions",
                },
              },
              required: ["startDate", "endDate", "metrics", "dimensions"],
            },
          },
          {
            name: "getPageViews",
            description: "Get page view metrics for a specific date range",
            inputSchema: {
              type: "object",
              properties: {
                startDate: {
                  type: "string",
                  description: "Start date in YYYY-MM-DD format",
                },
                endDate: {
                  type: "string",
                  description: "End date in YYYY-MM-DD format",
                },
                dimensions: {
                  type: "array",
                  items: { type: "string" },
                  description: "Dimensions to group by (e.g., page, country)",
                },
              },
              required: ["startDate", "endDate"],
            },
          },
          {
            name: "getActiveUsers",
            description: "Get active users metrics for a specific date range",
            inputSchema: {
              type: "object",
              properties: {
                startDate: {
                  type: "string",
                  description: "Start date in YYYY-MM-DD format",
                },
                endDate: {
                  type: "string",
                  description: "End date in YYYY-MM-DD format",
                },
              },
              required: ["startDate", "endDate"],
            },
          },
          {
            name: "getEvents",
            description: "Get event metrics for a specific date range",
            inputSchema: {
              type: "object",
              properties: {
                startDate: {
                  type: "string",
                  description: "Start date in YYYY-MM-DD format",
                },
                endDate: {
                  type: "string",
                  description: "End date in YYYY-MM-DD format",
                },
                eventName: {
                  type: "string",
                  description: "Specific event name to filter by (optional)",
                },
              },
              required: ["startDate", "endDate"],
            },
          },
          {
            name: "getUserBehavior",
            description:
              "Get user behavior metrics like session duration and bounce rate",
            inputSchema: {
              type: "object",
              properties: {
                startDate: {
                  type: "string",
                  description: "Start date in YYYY-MM-DD format",
                },
                endDate: {
                  type: "string",
                  description: "End date in YYYY-MM-DD format",
                },
              },
              required: ["startDate", "endDate"],
            },
          },
        ],
      };
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves metrics but doesn't describe what 'active users' entails (e.g., definition of 'active', data format, potential rate limits, or authentication needs). For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior and constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by specifying the metrics and date range context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that likely returns complex metrics data. It doesn't explain what 'active users metrics' includes (e.g., counts, trends, or breakdowns), how results are structured, or any limitations. For a metrics retrieval tool with no structured output information, this leaves the agent guessing about return values and usage context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for both parameters ('startDate' and 'endDate') in the input schema. The description adds no additional meaning beyond implying a date range is required, which is already covered by the schema. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't enhance parameter understanding further.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('active users metrics'), specifying the action and target. It distinguishes itself from siblings like 'getEvents' or 'getPageViews' by focusing on user metrics rather than events or views. However, it doesn't explicitly differentiate from 'getUserBehavior' or 'runReport', which might also involve user-related data, leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'getUserBehavior' or 'runReport'. It mentions a date range but doesn't clarify if this is the only way to retrieve user metrics or if there are specific use cases (e.g., monitoring daily activity vs. detailed analysis). Without explicit when/when-not instructions, the agent must infer usage from context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ruchernchong/mcp-server-google-analytics'

If you have feedback or need assistance with the MCP directory API, please join our Discord server