Skip to main content
Glama

get_metadata

Retrieve available dimensions and metrics for Google Analytics 4 to identify reportable data fields before running analysis queries.

Instructions

利用可能なディメンションとメトリクスの一覧を取得します。run_reportで使える項目を確認できます。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyIdNoGA4プロパティID(省略時は環境変数を使用)

Implementation Reference

  • The core handler function that retrieves GA4 metadata (dimensions and metrics) using the Google Analytics Data API client, processes the response, and returns formatted lists.
    export async function getMetadata(input: PropertyId): Promise<GetMetadataOutput> { const propertyId = getPropertyId(input.propertyId); const property = formatPropertyPath(propertyId); const client = getDataClient(); const [response] = await client.getMetadata({ name: `${property}/metadata`, }); const dimensions: MetadataItem[] = []; const metrics: MetadataItem[] = []; // ディメンション情報を整形 for (const dim of response.dimensions || []) { dimensions.push({ apiName: dim.apiName || "", uiName: dim.uiName || "", description: dim.description || "", category: dim.category || "", }); } // メトリクス情報を整形 for (const metric of response.metrics || []) { metrics.push({ apiName: metric.apiName || "", uiName: metric.uiName || "", description: metric.description || "", category: metric.category || "", }); } return { dimensions, metrics }; }
  • src/server.ts:188-202 (registration)
    Tool registration in the tools array, defining name, description, and input schema for 'get_metadata'.
    { name: "get_metadata", description: "利用可能なディメンションとメトリクスの一覧を取得します。run_reportで使える項目を確認できます。", inputSchema: { type: "object" as const, properties: { propertyId: { type: "string", description: "GA4プロパティID(省略時は環境変数を使用)", }, }, required: [], }, },
  • src/server.ts:614-617 (registration)
    Handler dispatch in the switch statement for executing 'get_metadata' tool.
    case "get_metadata": return await getMetadata({ propertyId: args.propertyId as string | undefined, });
  • TypeScript interfaces defining the output schema for get_metadata: MetadataItem and GetMetadataOutput.
    // get_metadata export interface MetadataItem { apiName: string; uiName: string; description: string; category: string; } export interface GetMetadataOutput { dimensions: MetadataItem[]; metrics: MetadataItem[]; }
  • src/server.ts:10-16 (registration)
    Import statement registering the getMetadata handler into the server module.
    import { listAccounts, getPropertyDetails, runReport, runRealtimeReport, getMetadata, } from "./tools/basic/index.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