ga4_property_details
Retrieve comprehensive configuration details for a Google Analytics 4 property, including name, time zone, currency, and industry settings, to understand and manage property setup.
Instructions
Returns details about a specific GA4 property including its name, display name, time zone, currency, industry category, and other settings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | The Google Analytics property ID. Accepted formats: '123456789', '123456789', or 'properties/123456789' |
Implementation Reference
- src/tools/admin.ts:44-60 (handler)The getPropertyDetails function that implements the ga4_property_details tool. It gets the Analytics Admin client, constructs the property resource name, and calls the GA4 Admin API to retrieve property details./** * Returns details about a specific GA4 property. */ export async function getPropertyDetails(propertyId: string): Promise<ToolResponse> { try { const client = await getAnalyticsAdminClient(); const propertyName = constructPropertyResourceName(propertyId); const response = await client.properties.get({ name: propertyName, }); return createSuccessResponse(response.data); } catch (error) { return createErrorResponse(`Failed to get property details for ${propertyId}`, error); } }
- src/tools/index.ts:40-53 (registration)Tool registration schema definition for ga4_property_details, including name, description, and input schema with propertyId parameter.{ name: "ga4_property_details", description: "Returns details about a specific GA4 property including its name, display name, time zone, currency, industry category, and other settings.", inputSchema: { type: "object" as const, properties: { propertyId: { type: "string", description: "The Google Analytics property ID. Accepted formats: '123456789', '123456789', or 'properties/123456789'", }, }, required: ["propertyId"], }, },
- src/tools/index.ts:259-260 (registration)Tool routing case that maps the ga4_property_details tool name to the getPropertyDetails handler function.case "ga4_property_details": return await getPropertyDetails(args.propertyId as string);
- src/utils/helpers.ts:10-41 (helper)Helper function that constructs a properly formatted property resource name from various input formats (numeric, string, or properties/ prefix) for use with GA4 API calls./** * Constructs a property resource name in the format required by GA4 APIs. * Accepts formats: "123456789", 123456789, or "properties/123456789" * Returns: "properties/123456789" */ export function constructPropertyResourceName(propertyId: string | number): string { let propertyNum: number | null = null; if (typeof propertyId === "number") { propertyNum = propertyId; } else if (typeof propertyId === "string") { const trimmed = propertyId.trim(); if (/^\d+$/.test(trimmed)) { propertyNum = parseInt(trimmed, 10); } else if (trimmed.startsWith("properties/")) { const numericPart = trimmed.split("/")[1]; if (numericPart && /^\d+$/.test(numericPart)) { propertyNum = parseInt(numericPart, 10); } } } if (propertyNum === null) { throw new Error( `Invalid property ID: ${propertyId}. ` + "A valid property value is either a number or a string starting " + "with 'properties/' and followed by a number." ); } return `properties/${propertyNum}`; }
- src/utils/helpers.ts:1-8 (schema)ToolResponse interface type definition that defines the standard response format for all MCP tools, including ga4_property_details.// Tool response type for MCP export interface ToolResponse { content: Array<{ type: "text"; text: string; }>; isError?: boolean; }