Skip to main content
Glama
ruchernchong

mcp-server-google-analytics

by ruchernchong

getUserBehavior

Retrieve user behavior metrics such as session duration and bounce rate from Google Analytics 4 data for specified date ranges to analyze website engagement patterns.

Instructions

Get user behavior metrics like session duration and bounce rate

Input Schema

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

Implementation Reference

  • Handler for the getUserBehavior tool. Extracts date range from arguments, validates it, and fetches analytics data for average session duration, bounce rate, sessions per user, grouped by date.
    case "getUserBehavior": {
      const { startDate, endDate } = args as {
        startDate: string;
        endDate: string;
      };
    
      validateDateRange(startDate, endDate);
    
      return fetchAnalyticsData({
        dateRanges: [{ startDate, endDate }],
        metrics: [
          { name: "averageSessionDuration" },
          { name: "bounceRate" },
          { name: "sessionsPerUser" },
        ],
        dimensions: [{ name: "date" }],
      });
    }
  • src/index.ts:240-258 (registration)
    Registration of the getUserBehavior tool in the listTools handler, including name, description, and input schema requiring startDate and 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 implies a read-only operation ('Get') but doesn't specify permissions, rate limits, data freshness, or what happens if date ranges are invalid. For a tool with zero annotation coverage, this is a significant gap in behavioral context.

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 with no wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (2 required parameters) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits, usage guidelines, and return values, which are important for an agent to use it correctly without structured metadata.

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 both parameters ('startDate' and 'endDate') documented in the schema. The description doesn't add any parameter-specific details beyond what the schema provides, such as format constraints or usage examples, so it meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Get') and resource ('user behavior metrics'), and provides examples of metrics like 'session duration and bounce rate'. However, it doesn't explicitly differentiate from sibling tools like 'getActiveUsers' or 'getEvents', which might also retrieve user-related data.

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 'getActiveUsers', 'getEvents', or 'runReport'. It doesn't mention prerequisites, exclusions, or specific contexts for usage, leaving the agent to infer based on tool names alone.

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