Skip to main content
Glama
Shin-sibainu

GA4 MCP Server

by Shin-sibainu

get_property_details

Retrieve detailed information about a Google Analytics 4 property, including name, timezone, and currency settings, by providing the property ID.

Instructions

指定したGA4プロパティの詳細情報(名前、タイムゾーン、通貨など)を取得します。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyIdYesGA4プロパティID(例: 123456789)

Implementation Reference

  • Core handler function implementing the get_property_details tool logic. Fetches GA4 property details via admin client, formats timestamps, and returns structured PropertyDetails.
    export async function getPropertyDetails(
      input: GetPropertyDetailsInput
    ): Promise<PropertyDetails> {
      const client = getAdminClient();
      const propertyPath = formatPropertyPath(input.propertyId);
      
      const [property] = await client.getProperty({
        name: propertyPath,
      });
      
      if (!property) {
        throw new Error(`プロパティが見つかりません: ${input.propertyId}`);
      }
      
      return {
        propertyId: input.propertyId,
        displayName: property.displayName || "",
        timeZone: property.timeZone || "",
        currencyCode: property.currencyCode || "",
        industryCategory: property.industryCategory
          ? String(property.industryCategory)
          : undefined,
        serviceLevel: property.serviceLevel
          ? String(property.serviceLevel)
          : undefined,
        createTime: property.createTime
          ? new Date(
              Number(property.createTime.seconds) * 1000
            ).toISOString()
          : undefined,
        updateTime: property.updateTime
          ? new Date(
              Number(property.updateTime.seconds) * 1000
            ).toISOString()
          : undefined,
      };
    }
  • TypeScript interfaces defining the input (GetPropertyDetailsInput) and output (PropertyDetails) types for the tool.
    // get_property_details
    export interface GetPropertyDetailsInput extends PropertyId {
      propertyId: string;
    }
    
    export interface PropertyDetails {
      propertyId: string;
      displayName: string;
      timeZone: string;
      currencyCode: string;
      industryCategory?: string;
      serviceLevel?: string;
      createTime?: string;
      updateTime?: string;
    }
  • src/server.ts:72-86 (registration)
    Tool registration in the tools array, including name, description, and input JSON schema.
    {
      name: "get_property_details",
      description:
        "指定したGA4プロパティの詳細情報(名前、タイムゾーン、通貨など)を取得します。",
      inputSchema: {
        type: "object" as const,
        properties: {
          propertyId: {
            type: "string",
            description: "GA4プロパティID(例: 123456789)",
          },
        },
        required: ["propertyId"],
      },
    },
  • src/server.ts:574-577 (registration)
    Dispatch handler in the switch statement that calls the getPropertyDetails function with parsed arguments.
    case "get_property_details":
      return await getPropertyDetails({
        propertyId: args.propertyId as string,
      });
  • Re-export of the getPropertyDetails handler from its implementation file.
    export { getPropertyDetails } from "./getPropertyDetails.js";

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