Skip to main content
Glama
Shin-sibainu

GA4 MCP Server

by Shin-sibainu

get_metadata

Retrieve available dimensions and metrics for Google Analytics 4 reports to identify usable items in run_report analysis.

Instructions

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

Input Schema

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

Implementation Reference

  • The core handler function that fetches and formats GA4 metadata (dimensions and metrics) from the API.
    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 };
    }
  • TypeScript interfaces defining the output structure (GetMetadataOutput) and MetadataItem for the get_metadata tool.
    // get_metadata
    export interface MetadataItem {
      apiName: string;
      uiName: string;
      description: string;
      category: string;
    }
    
    export interface GetMetadataOutput {
      dimensions: MetadataItem[];
      metrics: MetadataItem[];
    }
  • src/server.ts:188-202 (registration)
    MCP tool registration including name, description, and input schema definition.
    {
      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)
    Dispatch handler in the server that calls the getMetadata function for the 'get_metadata' tool.
    case "get_metadata":
      return await getMetadata({
        propertyId: args.propertyId as string | undefined,
      });
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) which implies it's non-destructive, but doesn't mention any behavioral traits like authentication needs, rate limits, response format, or whether it's a safe operation. For a tool with zero annotation coverage, this is a significant gap in transparency, as it lacks details on how the tool behaves beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences that are front-loaded: the first states the core purpose, and the second adds usage context. There's no wasted text, and both sentences earn their place by providing essential information. However, it could be slightly more structured to explicitly separate purpose from guidelines, but it remains efficient and clear.

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 complexity (simple read operation with 1 optional parameter), no annotations, no output schema, and high schema coverage, the description is somewhat complete but has gaps. It explains what the tool does and hints at usage, but lacks behavioral details like response format or error handling. For a tool with no output schema, the description doesn't compensate by describing return values, making it minimally adequate but not fully comprehensive.

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

Parameters3/5

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

The input schema has 1 parameter with 100% description coverage, providing details on 'propertyId' as a GA4 property ID that defaults to an environment variable. The description doesn't add any parameter-specific information beyond what the schema already documents. According to the rules, with high schema coverage (>80%), the baseline score is 3 even without param info in the description, which applies here as the description doesn't compensate with additional semantics.

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: '利用可能なディメンションとメトリクスの一覧を取得します' (Get a list of available dimensions and metrics). It specifies the verb '取得します' (get) and resource 'ディメンションとメトリクスの一覧' (list of dimensions and metrics), but doesn't explicitly differentiate from sibling tools like 'get_property_details' or 'list_accounts' that might also retrieve metadata. The second sentence adds context about usage with 'run_report' but doesn't fully distinguish it from other metadata-related tools.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: 'run_reportで使える項目を確認できます' (You can check items usable in run_report). This suggests the tool is for preparing to use 'run_report', but it doesn't explicitly state when to use this tool versus alternatives like 'get_property_details' or when not to use it. No explicit alternatives or exclusions are mentioned, leaving some ambiguity about its specific context among the sibling tools.

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