Skip to main content
Glama
wonyoungseong

GA4 MCP Server

ga4_account_summaries

Retrieve a list of all Google Analytics 4 accounts and their properties accessible to the authenticated user. This tool helps users quickly identify available GA4 resources for reporting and management.

Instructions

Retrieves information about the user's Google Analytics accounts and properties. Returns a list of all GA4 accounts and their associated properties that the authenticated user has access to.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The getAccountSummaries function implements the actual tool logic. It retrieves account summaries from Google Analytics Admin API using pagination, collects all summaries, and returns a success response with the count and data.
    export async function getAccountSummaries(): Promise<ToolResponse> {
      try {
        const client = await getAnalyticsAdminClient();
        const allSummaries: unknown[] = [];
        let pageToken: string | undefined | null = undefined;
    
        do {
          const response: { data: AccountSummariesResponse } = await client.accountSummaries.list({
            pageToken: pageToken || undefined,
            pageSize: 200,
          });
    
          const data = response.data;
          if (data.accountSummaries) {
            allSummaries.push(...data.accountSummaries);
          }
          pageToken = data.nextPageToken;
        } while (pageToken);
    
        return createSuccessResponse({
          accountSummaries: allSummaries,
          totalCount: allSummaries.length,
        });
      } catch (error) {
        return createErrorResponse("Failed to get account summaries", error);
      }
    }
  • Tool registration and schema definition for ga4_account_summaries. Defines the tool name, description, and input schema (which has no required properties).
      name: "ga4_account_summaries",
      description: "Retrieves information about the user's Google Analytics accounts and properties. Returns a list of all GA4 accounts and their associated properties that the authenticated user has access to.",
      inputSchema: {
        type: "object" as const,
        properties: {},
        required: [],
      },
    },
  • Handler routing in the switch statement that maps 'ga4_account_summaries' tool calls to the getAccountSummaries() function.
    case "ga4_account_summaries":
      return await getAccountSummaries();
  • createSuccessResponse helper function used by getAccountSummaries to format the successful MCP response with JSON data.
    export function createSuccessResponse(data: unknown): ToolResponse {
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }
  • createErrorResponse helper function used by getAccountSummaries to format error responses with detailed error messages.
    export function createErrorResponse(message: string, error?: unknown): ToolResponse {
      let errorMessage = message;
    
      if (error) {
        if (error instanceof Error) {
          errorMessage += `: ${error.message}`;
        } else if (typeof error === "string") {
          errorMessage += `: ${error}`;
        } else {
          errorMessage += `: ${JSON.stringify(error)}`;
        }
      }
    
      return {
        content: [
          {
            type: "text",
            text: errorMessage,
          },
        ],
        isError: true,
      };
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that this is a read operation ('Retrieves') and mentions authentication context ('authenticated user has access to'), but doesn't describe behavioral traits like pagination, rate limits, error conditions, or response format. The description adds some value but lacks comprehensive 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?

Two sentences that are front-loaded with the core purpose, followed by return value clarification. Zero waste - every word contributes to understanding the tool's function and scope.

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 no annotations, no output schema, and a read-only operation with 0 parameters, the description is adequate but has gaps. It explains what the tool retrieves but doesn't describe the structure of returned data, potential limitations, or error handling. For a tool that returns 'a list of all GA4 accounts and their associated properties,' more detail about the response format would be helpful.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the baseline is 4. The description appropriately doesn't discuss parameters since none exist, and instead focuses on what the tool does and returns.

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

Purpose5/5

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

The description clearly states the specific verb ('Retrieves information') and resource ('Google Analytics accounts and properties'), with explicit scope ('all GA4 accounts and their associated properties that the authenticated user has access to'). It distinguishes from siblings like ga4_run_report (which runs reports) and ga4_property_details (which gets details for specific properties).

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

Usage Guidelines4/5

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

The description provides clear context about when to use it ('to get information about GA4 accounts and properties the user can access'), but doesn't explicitly state when not to use it or name specific alternatives. For example, it doesn't contrast with ga4_property_details for getting detailed info about a specific property.

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/wonyoungseong/ga4-mcp-server'

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