list_google_ads_links
Retrieve all Google Ads links associated with a Google Analytics property to manage cross-platform advertising connections.
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
| Name | Required | Description | Default |
|---|---|---|---|
| property_id | Yes |
Implementation Reference
- analytics_mcp/tools/admin/info.py:41-59 (handler)The core handler function for the 'list_google_ads_links' tool. It takes a property_id, constructs a ListGoogleAdsLinksRequest, calls the Admin API's list_google_ads_links method synchronously via asyncio.to_thread, and returns the results as a list of dictionaries.
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) ) def _sync_call(): links_pager = create_admin_api_client().list_google_ads_links( request=request ) return [proto_to_dict(link_page) for link_page in links_pager] return await asyncio.to_thread(_sync_call) - The function signature defines the input schema: it accepts a 'property_id' parameter of type int or str, and returns a List[Dict[str, Any]]. The docstring describes the accepted formats for property_id.
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 """ - analytics_mcp/coordinator.py:32-37 (registration)The import of list_google_ads_links from analytics_mcp.tools.admin.info into the coordinator module.
from analytics_mcp.tools.admin.info import ( get_account_summaries, list_google_ads_links, get_property_details, list_property_annotations, ) - analytics_mcp/coordinator.py:66-75 (registration)The tool is registered as a FunctionTool(list_google_ads_links) within the 'tools' list, making it available as an MCP tool in the server.
tools = [ FunctionTool(get_account_summaries), FunctionTool(list_google_ads_links), FunctionTool(get_property_details), FunctionTool(list_property_annotations), FunctionTool(get_custom_dimensions_and_metrics), run_report_with_description, run_realtime_report_with_description, run_funnel_report_with_description, ] - analytics_mcp/tools/utils.py:22-44 (helper)The construct_property_rn helper function used by the handler to convert the user-provided property_id to the 'properties/{number}' resource name format required by the Admin API.
def construct_property_rn(property_value: int | str) -> str: """Returns a property resource name in the format required by APIs.""" property_num = None if isinstance(property_value, int): property_num = property_value elif isinstance(property_value, str): property_value = property_value.strip() if property_value.isdigit(): property_num = int(property_value) elif property_value.startswith("properties/"): numeric_part = property_value.split("/")[-1] if numeric_part.isdigit(): property_num = int(numeric_part) if property_num is None: raise ValueError( ( f"Invalid property ID: {property_value}. " "A valid property value is either a number or a string starting " "with 'properties/' and followed by a number." ) ) return f"properties/{property_num}"