Skip to main content
Glama
googleanalytics

Google Analytics MCP Server

Official

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

TableJSON Schema
NameRequiredDescriptionDefault
property_idYes

Implementation Reference

  • 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
        """
  • 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,
    )
  • 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,
    ]
  • 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}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It does not disclose behaviors like error handling, empty results, authentication requirements, or that it is a read operation.

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

Conciseness5/5

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

Two concise sentences with no wasted words. The first sentence states the purpose, the second explains the argument. Ideal length for a simple tool.

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?

For a one-parameter tool with no output schema, the description should hint at the return structure (e.g., account names, IDs). It only says 'links,' which is vague. Adequate but incomplete.

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

Parameters4/5

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

With 0% schema coverage, the description adds significant value by explaining accepted formats for property_id (number or string with 'properties/' prefix), clarifying the ambiguous schema type.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it returns a list of links to Google Ads accounts for a property. This is specific and distinct from sibling tools like run_report or get_property_details.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., get_account_summaries). The description only states what it does, not when it's appropriate.

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

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