Skip to main content
Glama
Shin-sibainu

GA4 MCP Server

by Shin-sibainu

list_accounts

Retrieve Google Analytics 4 accounts and properties to identify which property ID to use for data analysis.

Instructions

GA4のアカウントとプロパティの一覧を取得します。どのプロパティIDを使うべきか確認する際に便利です。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that fetches and processes GA4 accounts and their properties using the admin client, returning structured output.
    export async function listAccounts(): Promise<ListAccountsOutput> {
      const client = getAdminClient();
      
      const accounts: Account[] = [];
      
      // アカウント一覧を取得
      const [accountsResponse] = await client.listAccounts({});
      
      for (const account of accountsResponse || []) {
        if (!account.name || !account.displayName) continue;
        
        const accountId = account.name.replace("accounts/", "");
        const accountData: Account = {
          accountId,
          accountName: account.displayName,
          properties: [],
        };
        
        // このアカウントのプロパティ一覧を取得
        try {
          const [propertiesResponse] = await client.listProperties({
            filter: `parent:accounts/${accountId}`,
          });
          
          for (const property of propertiesResponse || []) {
            if (!property.name || !property.displayName) continue;
            
            accountData.properties.push({
              propertyId: extractPropertyId(property.name),
              propertyName: property.displayName,
            });
          }
        } catch (error) {
          // プロパティの取得に失敗しても続行
          console.error(`Failed to fetch properties for account ${accountId}:`, error);
        }
        
        accounts.push(accountData);
      }
      
      return { accounts };
    }
  • src/server.ts:62-71 (registration)
    Registers the list_accounts tool in the MCP server's tools array, including name, description, and input schema (empty object).
    {
      name: "list_accounts",
      description:
        "GA4のアカウントとプロパティの一覧を取得します。どのプロパティIDを使うべきか確認する際に便利です。",
      inputSchema: {
        type: "object" as const,
        properties: {},
        required: [],
      },
    },
  • Defines the output schema for list_accounts tool, including Account, Property interfaces and ListAccountsOutput type.
    // list_accounts
    export interface Account {
      accountId: string;
      accountName: string;
      properties: Property[];
    }
    
    export interface Property {
      propertyId: string;
      propertyName: string;
    }
    
    export interface ListAccountsOutput {
      accounts: Account[];
    }
  • src/server.ts:571-572 (registration)
    Dispatches the list_accounts tool call to the listAccounts handler function in the server's handleToolCall switch statement.
    case "list_accounts":
      return await listAccounts();
  • Re-exports the listAccounts function for easy import from the basic tools index.
    export { listAccounts } from "./listAccounts.js";
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 describes a read operation ('取得します' - get/retrieve), which implies it's non-destructive, but doesn't mention any behavioral traits like permissions needed, rate limits, pagination, or what the output looks like. For a tool with zero annotation coverage, this is a significant gap, though it at least implies a safe read.

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 appropriately sized and front-loaded: it states the core purpose in the first sentence and adds usage context in the second. Every sentence earns its place by providing essential information without waste, making it highly concise and well-structured.

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 low complexity (0 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It explains the purpose and usage context adequately, but without annotations or output schema, it lacks details on behavioral aspects like response format or limitations. This makes it minimally viable but not fully comprehensive.

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, and the schema description coverage is 100% (since there are no parameters to describe). In such cases, the baseline is 4, as there's no need for the description to compensate for parameter documentation. The description doesn't add parameter info, which is fine here.

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: 'GA4のアカウントとプロパティの一覧を取得します' (Get a list of GA4 accounts and properties). It specifies the verb ('取得します' - get/retrieve) and the resources (accounts and properties). However, it doesn't explicitly differentiate from siblings like 'get_property_details' or 'get_metadata', which might also retrieve property-related information, so it doesn't reach a perfect 5.

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 for when to use this tool: 'どのプロパティIDを使うべきか確認する際に便利です' (Useful when checking which property ID to use). This gives a practical scenario, but it doesn't explicitly state when not to use it or name alternatives among the sibling tools, so it falls short of a 5.

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

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