Skip to main content
Glama
wonyoungseong

GA4 MCP Server

ga4_google_ads_links

List Google Ads accounts connected to a GA4 property to view data sharing links and manage advertising integrations.

Instructions

Returns a list of links to Google Ads accounts for a GA4 property. Shows which Google Ads accounts are connected to the property for data sharing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyIdYesThe Google Analytics property ID. Accepted formats: '123456789' or 'properties/123456789'

Implementation Reference

  • The main handler function listGoogleAdsLinks that implements the tool logic. It retrieves Google Ads links for a GA4 property by calling the Analytics Admin API, handles pagination, and returns a formatted response with the links array and total count.
    export async function listGoogleAdsLinks(propertyId: string): Promise<ToolResponse> { try { const client = await getAnalyticsAdminClient(); const propertyName = constructPropertyResourceName(propertyId); const allLinks: unknown[] = []; let pageToken: string | undefined | null = undefined; do { const response: { data: GoogleAdsLinksResponse } = await client.properties.googleAdsLinks.list({ parent: propertyName, pageToken: pageToken || undefined, pageSize: 200, }); const data = response.data; if (data.googleAdsLinks) { allLinks.push(...data.googleAdsLinks); } pageToken = data.nextPageToken; } while (pageToken); return createSuccessResponse({ googleAdsLinks: allLinks, totalCount: allLinks.length, }); } catch (error) { return createErrorResponse(`Failed to list Google Ads links for ${propertyId}`, error); } }
  • Tool registration and schema definition for ga4_google_ads_links. Defines the tool name, description, and input schema requiring a propertyId parameter.
    { name: "ga4_google_ads_links", description: "Returns a list of links to Google Ads accounts for a GA4 property. Shows which Google Ads accounts are connected to the property for data sharing.", inputSchema: { type: "object" as const, properties: { propertyId: { type: "string", description: "The Google Analytics property ID. Accepted formats: '123456789' or 'properties/123456789'", }, }, required: ["propertyId"], }, },
  • Tool routing that connects the ga4_google_ads_links tool name to its handler function listGoogleAdsLinks, extracting and casting the propertyId argument.
    case "ga4_google_ads_links": return await listGoogleAdsLinks(args.propertyId as string);

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

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