Skip to main content
Glama
googleanalytics

Google Analytics MCP Server

Official

list_google_ads_links

Retrieve a list of Google Ads accounts linked to a specific Google Analytics property by providing the property ID.

Instructions

Returns a list of links to Google Ads accounts for a property.

Args: property_id: The Google Analytics property ID. Accepted formats are: - A number - A string consisting of 'properties/' followed by a number

Input Schema

NameRequiredDescriptionDefault
property_idYes

Input Schema (JSON Schema)

{ "properties": { "property_id": { "anyOf": [ { "type": "integer" }, { "type": "string" } ], "title": "Property Id" } }, "required": [ "property_id" ], "title": "list_google_ads_linksArguments", "type": "object" }

Implementation Reference

  • The handler function for the 'list_google_ads_links' MCP tool. It constructs a request to list Google Ads links for the given property using the Google Analytics Admin API v1beta, paginates through all results asynchronously, converts protobuf responses to dictionaries, and returns the list.
    @mcp.tool(title="List links to Google Ads accounts") async def list_google_ads_links(property_id: int | str) -> List[Dict[str, Any]]: """Returns a list of links to Google Ads accounts for a property. Args: property_id: The Google Analytics property ID. Accepted formats are: - A number - A string consisting of 'properties/' followed by a number """ request = admin_v1beta.ListGoogleAdsLinksRequest( parent=construct_property_rn(property_id) ) # Uses an async list comprehension so the pager returned by # list_google_ads_links retrieves all pages. links_pager = await create_admin_api_client().list_google_ads_links( request=request ) all_pages = [proto_to_dict(link_page) async for link_page in links_pager] return all_pages
  • Registers the 'list_google_ads_links' tool with MCP using the @mcp.tool decorator, providing a display title.
    @mcp.tool(title="List links to Google Ads accounts")

Other Tools

Related 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/googleanalytics/google-analytics-mcp'

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